Skip to content

incorrect version of gcc #511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stvoidit opened this issue Feb 7, 2024 · 4 comments
Closed

incorrect version of gcc #511

stvoidit opened this issue Feb 7, 2024 · 4 comments

Comments

@stvoidit
Copy link

stvoidit commented Feb 7, 2024

When installing the "alpine-sdk" package, for some reason i586-alpine-linux-musl-gcc is installed.
I'm using this image https://github.com/docker-library/golang/blob/893a2c96ba6154de2ad3663d087998bfda0a04e9/1.22/alpine3.19/Dockerfile

There is no such problem in the previous version https://github.com/docker-library/golang/blob/893a2c96ba6154de2ad3663d087998bfda0a04e9/1.21/alpine3.19/Dockerfile

At the same time, if I install the "alpine-sdk" package simply on the alpine3.19 image, then the gcc package puts the correct version of x86_64-alpine-linux-musl-gcc

Command for check 1.22:
docker run --rm golang:1.22-alpine3.19 sh -c 'apk add --update --no-cache alpine-sdk && find / -name "*-alpine-linux-musl-gcc" && uname -m'
Result:

/usr/bin/i586-alpine-linux-musl-gcc
x86_64

Command for check 1.21:
docker run --rm golang:1.21-alpine3.19 sh -c 'apk add --update --no-cache alpine-sdk && find / -name "*-alpine-linux-musl-gcc"' && uname -m
Result:

/usr/bin/x86_64-alpine-linux-musl-gcc
x86_64

This is important to me, because my build stage looks something like this:

FROM golang:1.22-alpine AS backend
RUN apk add --update --no-cache alpine-sdk
WORKDIR /build
COPY src/ .
ENV CC=/usr/bin/x86_64-alpine-linux-musl-gcc
ENV CGO_ENABLED=1 GOARCH=amd64 GOOS=linux GOFLAGS=-mod=vendor
RUN go build -ldflags "-s -w" -o ./my_program ./main.go

UPD:
I did an inspection of the golang image:1.22 is alpine 3.19 and it shows "Architecture": "386".

inspect: docker image inspect golang:1.22-alpine3.19
result:

[
    {
        "Id": "sha256:6492fb3676d49badc7bc34c2485ade7e1afb195f12a878784ea62ad758e64252",
        "RepoTags": [
            "golang:1.22-alpine3.19"
        ],
        "RepoDigests": [
            "golang@sha256:298646364548cc5e1372e2612a6a2aaa53d44bed00284ecbc89b7aa8a83ad602"
        ],
        "Parent": "",
        "Comment": "buildkit.dockerfile.v0",
        "Created": "2024-02-06T23:26:32Z",
        "Container": "",
        "ContainerConfig": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": null,
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "DockerVersion": "",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "GOLANG_VERSION=1.22.0",
                "GOTOOLCHAIN=local",
                "GOPATH=/go"
            ],
            "Cmd": [
                "/bin/sh"
            ],
            "Image": "",
            "Volumes": null,
            "WorkingDir": "/go",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "386",
        "Os": "linux",
        "Size": 223193944,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/612209b5171e1df4300e2014676835eb3c93b31a28b6155ba298752c3e421c78/diff:/var/lib/docker/overlay2/09d9133ef3b26630687e663dabb6d38dd6b5618eb01b39cf1a5fed070be47c5c/diff:/var/lib/docker/overlay2/6da2eef2568bbe5fe63fd4610192c8beb84d798f5a0b45c3d6f6d08373d2244d/diff:/var/lib/docker/overlay2/f340a27f27bd6dd655be30aacdc48a7c83de014e1f961862213cfcc4f9f063a4/diff",
                "MergedDir": "/var/lib/docker/overlay2/e5d262fe2b5c50d6ffd2d593a2b5cac6e172cbe56d7afb11996474720d5782c4/merged",
                "UpperDir": "/var/lib/docker/overlay2/e5d262fe2b5c50d6ffd2d593a2b5cac6e172cbe56d7afb11996474720d5782c4/diff",
                "WorkDir": "/var/lib/docker/overlay2/e5d262fe2b5c50d6ffd2d593a2b5cac6e172cbe56d7afb11996474720d5782c4/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:72c06eca0d42d013af591706f7a2daee01131555396b59dfc9ef59d60cb9cabf",
                "sha256:6549b66bbde1f546d6c42fb91755c1e98a5dd90b9da433e425e8d1448ca0876b",
                "sha256:008360906b7faadca9a0a111e566208b6b9ecdaf7804ce62e7444c9109f32e91",
                "sha256:9a997b9be9607fe60404fa56ca03d6444b9e238b13c5945cd455bc22f4630e8f",
                "sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]
@viktorasm
Copy link

Will definitely be related to #509 . AMD64 not there yet.

@stvoidit
Copy link
Author

stvoidit commented Feb 7, 2024

Определенно будет иметь отношение к #509 . AMD64 еще нет.

https://hub.docker.com/layers/library/golang/1.22.0-alpine3.19/images/sha256-c3a0659f8f61439fa9c8edb612fa385c34309c05d0306058c1913ccf3433da40
Oh, yes, I see... It is very sad that docker downloads any available architecture.

@stvoidit stvoidit closed this as completed Feb 7, 2024
@stvoidit
Copy link
Author

stvoidit commented Feb 7, 2024

This is a solution for those who are faced with the same problem.
Add the architecture specification to your Dockerfile.

FROM amd64/golang:1.22-alpine

@tianon
Copy link
Member

tianon commented Feb 7, 2024

Just to clarify, it won't download any architecture, but only compatible ones (which is why you'd get 386 on amd64, just like you'd get arm32 on an arm64 machine, or armv5 on an armv6).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants