Skip to content

Build release Linux binaries without cgo for Alpine compatibility? #169

@AnthonyMastrean

Description

@AnthonyMastrean

I have a simple Dockerfile that uses the binary from GitHub.

Dockerfile

FROM alpine

WORKDIR /root

RUN set -ex \
    && wget -q -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.3.0/mkcert-v1.3.0-linux-arm \
    && chmod +x mkcert \
    && ./mkcert -install \
    && ./mkcert localhost

When I build this locally, everything is OK.

$ docker image build --pull --tag example .
Sending build context to Docker daemon  75.26kB
Step 1/3 : FROM alpine
latest: Pulling from library/alpine
Digest: sha256:ca1c944a4f8486a153024d9965aafbe24f5723c1d5c02f4964c045a16d19dc54
Status: Image is up to date for alpine:latest
 ---> 4d90542f0623
Step 2/3 : WORKDIR /root
 ---> Using cache
 ---> f1df3106650a
Step 3/3 : RUN set -ex     && wget -q -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.3.0/mkcert-v1.3.0-linux-arm     && chmod +x mkcert     && ./mkcert -install     && ./mkcert localhost
 ---> Running in 7dce34e8bf2a
+ wget -q -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.3.0/mkcert-v1.3.0-linux-arm
+ chmod +x mkcert
+ ./mkcert -install
Created a new local CA at "/root/.local/share/mkcert" �
Installing to the system store is not yet supported on this Linux � but Firefox and/or Chrome/Chromium will still work.
You can also manually install the root certificate at "/root/.local/share/mkcert/rootCA.pem".

+ ./mkcert localhost
Using the local CA at "/root/.local/share/mkcert" ✨
Warning: the local CA is not installed in the system trust store! ⚠️
Run "mkcert -install" to avoid verification errors ‼️

Created a new certificate valid for the following names �
 - "localhost"

The certificate is at "./localhost.pem" and the key at "./localhost-key.pem" ✅

Removing intermediate container 7dce34e8bf2a
 ---> 8f5c4f5e7940
Successfully built 8f5c4f5e7940
Successfully tagged example:latest

But, when I run the same in a GitLab pipeline (uses Docker-in-Docker), it goes haywire!

.gitlab-ci.yml

image: docker:stable

services:
    - docker:stable-dind

build:
    stage: build
    script:
        - docker image build --pull --tag example .

Pipeline log

Running with gitlab-runner 12.0.0-rc1 (58d8360f)
  on docker-auto-scale 0277ea0f
Using Docker executor with image docker:stable ...
Starting service docker:stable-dind ...
Pulling docker image docker:stable-dind ...
Using docker image sha256:12adad4e12e25288e665131d5235d98a8edf2a39d26679dabbe2728442729e26 for docker:stable-dind ...
Waiting for services to be up and running...
Pulling docker image docker:stable ...
Using docker image sha256:805bea199b249bfed61cdcd7cdbfe240ee998d51f59bbf365674a15b619f5a86 for docker:stable ...
Running on runner-0277ea0f-project-13015620-concurrent-0 via runner-0277ea0f-srm-1561404020-8e640368...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/anthonymastrean/mkcert-example/.git/
Created fresh repository.
From https://gitlab.com/anthonymastrean/mkcert-example
 * [new branch]      master     -> origin/master
Checking out 61c5932f as master...

Skipping Git submodules setup
$ docker image build --pull --tag example .
Sending build context to Docker daemon  47.62kB

Step 1/3 : FROM alpine
latest: Pulling from library/alpine
921b31ab772b: Pulling fs layer
921b31ab772b: Verifying Checksum
921b31ab772b: Download complete
921b31ab772b: Pull complete
Digest: sha256:ca1c944a4f8486a153024d9965aafbe24f5723c1d5c02f4964c045a16d19dc54
Status: Downloaded newer image for alpine:latest
 ---> 4d90542f0623
Step 2/3 : WORKDIR /root
 ---> Running in 104eadb1c574
Removing intermediate container 104eadb1c574
 ---> 4de722b6deac
Step 3/3 : RUN set -ex     && wget -q -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.3.0/mkcert-v1.3.0-linux-arm     && chmod +x mkcert     && ./mkcert -install     && ./mkcert localhost
 ---> Running in 6c027ecfa62a
+ wget -q -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.3.0/mkcert-v1.3.0-linux-arm
+ chmod +x mkcert
+ ./mkcert -install
/bin/sh: ./mkcert: not found
The command '/bin/sh -c set -ex     && wget -q -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.3.0/mkcert-v1.3.0-linux-arm     && chmod +x mkcert     && ./mkcert -install     && ./mkcert localhost' returned a non-zero code: 127
ERROR: Job failed: exit code 127

Does anyone have any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions