[solved] Dockerfile often wait infinitely on apk --no-cache add

Hello,
At the end I was able to run drone inside k8s, it was an issue related to the DRONE_PROTOCL, but now I’m facing another issues.
Most of the time, when I build a docker image the application wait infinitely on two particular steps that are related to apk --no-cache add
The Dockerfile is the following (it’s a little bit more than a test):

 # Build stage
    FROM golang:1.14-alpine3.12 AS build
    # Support CGO and SSL
    RUN apk --no-cache add gcc g++ make ca-certificates git
    WORKDIR /go/src/bitbucket.org/organization/app/
    # Copy each service
    COPY . /go/src/bitbucket.org/organization/app/
    # Compile them
    RUN go install bitbucket.org//organization/app
    # Production build stage
    FROM alpine:3.12
    RUN apk --no-cache add ca-certificates
    WORKDIR /usr/bin
    # Copy built binaries
    COPY --from=build /go/bin/app
    EXPOSE 8080
    CMD [ "app", "serve" ]

The drone build wait on step 2 or in step 7, I was thinking that the image had an error, but from time to time the drone pipeline creates successful the image.
drone build logs

  • /usr/local/bin/dockerd --data-root /var/lib/docker --host=unix:///var/run/docker.sock
    2 Detected registry credentials
    3 + /usr/local/bin/docker version
    4 Client: Docker Engine - Community
    5 Version: 19.03.8
    6 API version: 1.40
    7 Go version: go1.12.17
    8 Git commit: afacb8b7f0
    9 Built: Wed Mar 11 01:22:56 2020
    10 OS/Arch: linux/amd64
    11 Experimental: false
    12
    13 Server: Docker Engine - Community
    14 Engine:
    15 Version: 19.03.8
    16 API version: 1.40 (minimum version 1.12)
    17 Go version: go1.12.17
    18 Git commit: afacb8b7f0
    19 Built: Wed Mar 11 01:30:32 2020
    20 OS/Arch: linux/amd64
    21 Experimental: false
    22 containerd:
    23 Version: v1.2.13
    24 GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
    25 runc:
    26 Version: 1.0.0-rc10
    27 GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
    28 docker-init:
    29 Version: 0.18.0
    30 GitCommit: fec3683
    31 + /usr/local/bin/docker info
    32 Client:
    33 Debug Mode: false
    34
    35 Server:
    36 Containers: 0
    37 Running: 0
    38 Paused: 0
    39 Stopped: 0
    40 Images: 0
    41 Server Version: 19.03.8
    42 Storage Driver: overlay2
    43 Backing Filesystem:
    44 Supports d_type: true
    45 Native Overlay Diff: true
    46 Logging Driver: json-file
    47 Cgroup Driver: cgroupfs
    48 Plugins:
    49 Volume: local
    50 Network: bridge host ipvlan macvlan null overlay
    51 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
    52 Swarm: inactive
    53 Runtimes: runc
    54 Default Runtime: runc
    55 Init Binary: docker-init
    56 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
    57 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
    58 init version: fec3683
    59 Security Options:
    60 seccomp
    61 Profile: default
    62 Kernel Version: 4.9.0-11-amd64
    63 Operating System: Alpine Linux v3.11 (containerized)
    64 OSType: linux
    65 Architecture: x86_64
    66 CPUs: 2
    67 Total Memory: 3.805GiB
    68 Name: drone-ip4w8a19ew1vxvim4o7z
    69 ID: JBUP:FK7B:YQDQ:LJFF:I3XI:IF2V:RBJI:NFP2:CHJH:H2OK:MQZU:P6CG
    70 Docker Root Dir: /var/lib/docker
    71 Debug Mode: false
    72 Registry: https://index.docker.io/v1/
    73 Labels:
    74 Experimental: false
    75 Insecure Registries:
    76 127.0.0.0/8
    77 Live Restore Enabled: false
    78 Product License: Community Engine
    79
    80 WARNING: No swap limit support
    81 WARNING: bridge-nf-call-iptables is disabled
    82 WARNING: bridge-nf-call-ip6tables is disabled
    83 + /usr/local/bin/docker build --rm=true -f Dockerfile -t 31e5106e3e4fa1664b448010078aa9e5746c6eab . --pull=true --label org.label-schema.schema-version=1.0 --label org.label-schema.build-date=2020-06-16T20:20:28Z --label org.label-schema.vcs-ref=31e5106e3e4fa1664b448010078aa9e5746c6eab --label org.label-schema.vcs-url=https://bitbucket.org/placemakeio/api-gateway.git
    84 Sending build context to Docker daemon 792.1kB
    85 Step 1/15 : FROM golang:1.14-alpine3.12 AS build
    86 1.14-alpine3.12: Pulling from library/golang
    87 df20fa9351a1: Pulling fs layer
    88 ed8968b2872e: Pulling fs layer
    89 a92cc7c5fd73: Pulling fs layer
    90 9e0cccf56431: Pulling fs layer
    91 cbe0275821fc: Pulling fs layer
    92 9e0cccf56431: Waiting
    93 cbe0275821fc: Waiting
    94 ed8968b2872e: Verifying Checksum
    95 ed8968b2872e: Download complete
    96 a92cc7c5fd73: Verifying Checksum
    97 a92cc7c5fd73: Download complete
    98 df20fa9351a1: Verifying Checksum
    99 df20fa9351a1: Download complete
    100 df20fa9351a1: Pull complete
    101 ed8968b2872e: Pull complete
    102 cbe0275821fc: Verifying Checksum
    103 cbe0275821fc: Download complete
    104 a92cc7c5fd73: Pull complete
    105 9e0cccf56431: Download complete
    106 9e0cccf56431: Pull complete
    107 cbe0275821fc: Pull complete
    108 Digest: sha256:6042b9cfb4eb303f3bdcbfeaba79b45130d170939318de85ac5b9508cb6f0f7e
    109 Status: Downloaded newer image for golang:1.14-alpine3.12
    110 —> 3289bf11c284
    111 Step 2/15 : RUN apk --no-cache add gcc g++ make ca-certificates git
    112 —> Running in ab289365ff04
    113 fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz

drone configuration file

kind: pipeline
type: kubernetes
name: default

steps:

  • name: publish
    image: plugins/ecr
    settings:
    access_key:
    from_secret: access_key
    secret_key:
    from_secret: secret_key
    repo: my_repo/my_repo
    registry: my_registry
    region: eu-west-2
    tags:
    - test
    In local, using my mbp it works as always. Am I missing something?

See the following thread to learn more: