billowy-crowd-51528
09/20/2023, 11:33 PMpex
binary using CircleCI and getting the following error:
Engine traceback:
in `package` goal
IntrinsicError: Failed to obtain version from local Docker: error trying to connect: No such file or directory (os error 2)
The command I’m running:
REGISTRY=$ECR_REGISTRY_ID REGION=$ECR_REGION REPOSITORY=$ECR_REPOSITORY TAG=$CIRCLE_SHA1 pants package src/services/classifier/Dockerfile
I’ve looked through the slack here but couldn’t find much on this topic. Could use some help! 🙇♂️billowy-crowd-51528
09/20/2023, 11:34 PMecho $ECR_REGION
worksbillowy-crowd-51528
09/20/2023, 11:34 PM[GLOBAL]
pants_version = "2.17.0"
backend_packages = [
"pants.backend.python",
"pants.backend.python.lint.black",
"pants.backend.python.lint.isort",
"pants.backend.build_files.fmt.black",
"pants.backend.experimental.visibility",
"pants.backend.docker",
"pants.backend.docker.lint.hadolint",
]
# Custom macros
build_file_prelude_globs = ["pants-plugins/visibility_macro.py"]
pants_ignore = [
".*/",
"/dist/",
"__pycache__",
"pants-sandbox*",
]
[python]
interpreter_constraints = ['==3.11.*']
enable_resolves = true
[environments-preview.names]
python_bullseye = "//:python_bullseye"
[docker]
build_args = ["REPOSITORY", "REGISTRY", "REGION", "TAG"]
billowy-crowd-51528
09/20/2023, 11:35 PM# Default target of `<directory_name>`
python_sources()
# TODO config file for gunicorn so that staging & prod are diff
# README INSTALL PEX AND PANTS
pex_binary(
# This determines the output of the binary.
name="classifier-api",
# The command to run.
script="gunicorn",
args=["<http://services.classifier.app:app|services.classifier.app:app>", "-w=1", "-b=0.0.0.0", "--log-level=debug"],
# Essentially specifying the requirements.txt file.
dependencies=[
"//:shared_reqs#gunicorn", # need to explicitly add gunicorn because it's not part of imports.
":classifier", # need to add the "self" package so that it's included in the pex.
],
environment="python_bullseye",
)
# TODO this docker image stuff works local
# but not in CI; how to make it work with CI + ECR?
docker_image(
context_root="",
name="docker-classifier",
repository="{build_args.REPOSITORY}",
image_tags=["{build_args.TAG}"],
)
use_visibility_service(
name="classifier",
)
curved-television-6568
09/21/2023, 2:06 AMIntrinsicError: Failed to obtain version from local Docker
this error message is about a docker_environment
about pants not being able to connect to the docker daemon.billowy-crowd-51528
09/21/2023, 6:29 AMenvironment
part in the pex_binary
and I’ve progressed further… but now hitting:
stderr:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
billowy-crowd-51528
09/21/2023, 6:30 AM[environments-preview.names]
from pants.toml
• added env_vars = ["DOCKER_HOST"]
under docker
in pants.toml
And I’m still getting this error…billowy-crowd-51528
09/21/2023, 6:33 AM#!/usr/bin/env bash
# This command line should execute the same process as pants did internally.
cd /tmp/pants-sandbox-tj3l7i
env -i REPOSITORY=api-classifier TAG=e8c6c0721f0c61a4607a1e5f859210a868076f92 __UPSTREAM_IMAGE_IDS= /usr/bin/docker build $'--pull=False' --tag $'<redacted>.<http://dkr.ecr.us-west-1.amazonaws.com/api-classifier:e8c6c0721f0c61a4607a1e5f859210a868076f92|dkr.ecr.us-west-1.amazonaws.com/api-classifier:e8c6c0721f0c61a4607a1e5f859210a868076f92>' --build-arg REPOSITORY --build-arg TAG --file src/services/classifier/Dockerfile .
curved-television-6568
09/21/2023, 1:39 PMdocker version
report the server version? Seems like the docker daemon is either not running or not creating the /var/run/docker.sock
unix socket.billowy-crowd-51528
09/21/2023, 6:30 PMClient: Docker Engine - Community
Version: 20.10.22 API version: 1.41
Go version: go1.18.9
Git commit: 3a2c30b
Built: Thu Dec 15 22:28:04 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I wonder if it’s something to do with the circleci image?curved-television-6568
09/21/2023, 6:33 PMlittle-train-28371
09/21/2023, 8:36 PMcurved-television-6568
09/21/2023, 8:45 PMdocker_image
target, anything goes (only requires a workding docker
client) — for environments however, it may be that unix socket is the only way (depending on what support we have from the bollard
rust crate, and what we’re using of it)billowy-crowd-51528
09/22/2023, 8:04 PMsetup_remote_docker
step in the configcurved-television-6568
09/23/2023, 5:12 PM