goxx
goxx copied to clipboard
goxx-apt-get install doesn't resolve dpkg-dev when building linux/amd64 -> linux/arm64
Support guidelines
- [X] I've read the support guidelines
I've found a bug and checked that ...
- [X] ... the documentation does not mention anything about my problem
- [X] ... there are no open or closed issues that are related to my problem
Description
My application requires pkg-config
due to the use of CGO, however when building, I get this error:
#12 23.76 Please install dpkg-dev to use pkg-config when cross-building
#12 23.76 aarch64-linux-gnu-pkg-config: exit status 1
My dockerfile calls it out as a requirement:
FROM --platform=$BUILDPLATFORM docker-hub.repo.splunkdev.net/crazymax/goxx AS build
ENV CGO_ENABLED=1
WORKDIR /go/src/app
ARG TARGETPLATFORM
ARG BINARY_NAME
ARG VERSION
RUN goxx-apt-get update && \
goxx-apt-get install -y binutils gcc dpkg-dev pkg-config libpcsclite-dev # dpkg-dev specified here
RUN --mount=type=bind,source=. \
--mount=type=secret,id=_netrc,dst=/root/.netrc \
goxx-go env && goxx-go build -v -o /out/$BINARY_NAME -ldflags="-X main.Version=$VERSION" .
FROM scratch AS artifact
COPY --from=build /out/$BINARY_NAME /
FROM scratch
COPY --from=build /out/$BINARY_NAME /
ENTRYPOINT [ "/$BINARY_NAME" ]
But when goxx-apt-get install
runs, it excludes dpkg-dev
:
#10 7.507 Reading package lists...
#10 22.30 + exec apt-get install -y binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu pkg-config-aarch64-linux-gnu libpcsclite-dev:arm64
It's worth noting that this same dockerfile works on a linux/arm64 node.
Expected behaviour
Building on a linux/amd64 host for a linux/arm64 binary succeeds.
Actual behaviour
Building on a linux/amd64 host for a linux/arm64 binary fails.
Steps to reproduce
See description
Docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.10.4
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.17.2
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 3
Running: 1
Paused: 0
Stopped: 2
Images: 33
Server Version: 23.0.6
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 31aa4358a36870b21a992d3ad2bef29e1d693bec
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
Kernel Version: 5.4.0-1101-aws
Operating System: Ubuntu 18.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.35GiB
Name: runner-sfxftlit-production-1684440269-ee1b8f70
ID: WD4W:EZTB:G4Z7:HNNT:T3U7:YLGM:E4AM:4HBI:CI5R:5G6T:U7T5:TJ5E
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
provider=amazonec2
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
Logs
See description
Additional info
This is running in Gitlab CI using the docker+machine executor