From 5a2fd5039fbba3c06b640be91a2c436bc23f74e8 Mon Sep 17 00:00:00 2001 From: Oleg Stepura Date: Tue, 26 Sep 2017 21:57:02 +0200 Subject: [PATCH] Dockerfile broken with old alpine version with old go (#409) * Dockerfile broken with old alpine version with old go 3.4 no longer works with error ``` package context: unrecognized import path "context" (import path does not begin with hostname) ``` 3.5 with no changes did not work with error ``` # runtime/cgo /tmp/go-build671992352/runtime/cgo/_obj/_cgo_export.c:2:20: fatal error: stdlib.h: No such file or directory #include ^ compilation terminated. ``` 3.6 with no changes did not work with error: ``` # github.com/xenolf/lego /usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 /usr/lib/gcc/x86_64-alpine-linux-musl/6.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find Scrt1.o: No such file or directory /usr/lib/gcc/x86_64-alpine-linux-musl/6.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory /usr/lib/gcc/x86_64-alpine-linux-musl/6.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lpthread /usr/lib/gcc/x86_64-alpine-linux-musl/6.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared collect2: error: ld returned 1 exit status ``` * Fix git tag to freeze successfully builded image. Fix git tag to freeze successfully builded image (prevents issues with newer versions in the future, plus uses stable release) * Update Dockerfile according to PR comments * Forgot /go in rm * Bump lego version --- Dockerfile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index c0396407..511e403c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,15 @@ -FROM alpine:3.4 +FROM alpine:3.6 ENV GOPATH /go +ENV LEGO_VERSION tags/v0.4.1 -RUN apk update && apk add ca-certificates go git && \ - rm -rf /var/cache/apk/* && \ +RUN apk update && apk add --no-cache --virtual run-dependencies ca-certificates && \ + apk add --no-cache --virtual build-dependencies go git musl-dev && \ go get -u github.com/xenolf/lego && \ - cd /go/src/github.com/xenolf/lego && \ + cd ${GOPATH}/src/github.com/xenolf/lego && \ + git checkout ${LEGO_VERSION} && \ go build -o /usr/bin/lego . && \ - apk del go git && \ - rm -rf /var/cache/apk/* && \ - rm -rf /go + apk del build-dependencies && \ + rm -rf ${GOPATH} ENTRYPOINT [ "/usr/bin/lego" ]