silly-spring-18687
08/04/2023, 8:13 PM[docker]
build_args = ["GIT_COMMIT=local"]
[environments-preview.names]
osx = "//:local_osx"
linux_docker = "//:linux_docker"
BUILD
local_environment(name="local_osx", compatible_platforms=["macos_arm64"])
docker_environment(
name="linux_docker",
platform="linux_x86_64",
image="ubuntu:22.04",
)
go BUILD file
go_binary(name="bin", environment=parametrize("osx", "linux_docker"))
go_package()
Dockerfile
FROM golang:1.20
WORKDIR /app
COPY src.go.cmd.proglog/bin@environment=linux_docker /app/proglog
CMD [ "/app/proglog" ]
The error in question
pants package :: 1 ↵
16:23:47.94 [INFO] Initializing scheduler...
16:23:48.39 [INFO] Scheduler initialized.
16:23:58.09 [ERROR] 1 Exception encountered:
Engine traceback:
in `package` goal
IntrinsicError: Failed to start Docker container `cd7d8eee4e86c465bcffedfc161a2020d9798707b3ec219ecbdc66e3dbfdeed1` for image `sha256:0bced47fffa3361afa981854fcabcd4577cd43cebbb808cea2b1f33a3dd7f508`: JsonSerdeError { err: Error("expected value", line: 1, column: 1) }
silly-spring-18687
08/04/2023, 8:25 PMdocker run -ti --rm --platform=linux/amd64 ubuntu:22.04 /bin/bash
enough-analyst-54434
08/04/2023, 8:42 PMsilly-spring-18687
08/04/2023, 9:12 PMgo_binary
target and pants package ::
was successful. I was able to get a working docker build with this config. The only problem is it’s using the M1 mac compiled binary
[docker]
build_args = ["GIT_COMMIT=local"]
env_vars = [
"DOCKER_CONTEXT=default",
]
pants run src/go:docker-osx
17:11:28.28 [INFO] Completed: Building docker image docker-osx:latest
exec /app/proglog: exec format error
silly-spring-18687
08/12/2023, 9:46 PMDocker Desktop 4.21.1
and Pants 2.16.0
- I updated my pants.toml - [docker]
section to this
[docker]
build_args = ["GIT_COMMIT=local"]
env_vars = [
"DOCKER_CONTEXT=default",
"DOCKER_HOST=/var/run/docker.sock",
"USER=%(user)s",
"HOME=%(homedir)s",
"PATH"
]
tools = [
"sw_vers"
]
The root of the issue seems to be occurring when spinning up the docker environment. I’ve tried building the go binary myself to some success, but I would hate to lose the dependency inference (and squash this bug/misconfiguration :))
pants --keep-sandboxes=on_failure package src/go/cmd/proglog:bin@environment=linux_docker
Any thoughts would be helpful - This has become a blocker for one of my side projects and I would love to start working on it soon!careful-address-89803
08/13/2023, 12:57 AMsilly-spring-18687
08/13/2023, 1:46 PMenough-analyst-54434
08/13/2023, 3:45 PMsilly-spring-18687
08/13/2023, 3:46 PMhappy-kitchen-89482
08/13/2023, 10:41 PMnutritious-carpenter-5676
09/23/2023, 6:41 AMpants.toml
and the other in Docker Desktop (Advanced Settings) you should be g2g