Skip to content

Commit 10779fd

Browse files
committed
make docker image smaller
1 parent ffdc963 commit 10779fd

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

prod/Dockerfile

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.6
1+
FROM alpine:3.7
22

33
LABEL com.github.pottava.application="aws-s3-proxy" \
44
com.github.pottava.usage="docker run -d -p 8080:80 -e AWS_S3_BUCKET pottava/s3-proxy" \
@@ -9,31 +9,17 @@ ENV AWS_REGION=us-east-1 \
99

1010
RUN apk add --no-cache ca-certificates
1111

12-
RUN apk --no-cache add --virtual build-dependencies bash gcc musl-dev openssl go git \
13-
14-
# Install go 1.9
15-
&& GOLANG_VERSION=1.9.1 \
16-
&& GOLANG_SRC_URL=https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \
17-
&& GOLANG_SRC_SHA256=a84afc9dc7d64fe0fa84d4d735e2ece23831a22117b50dafc75c1484f1cb550e \
18-
&& export GOROOT_BOOTSTRAP="$(go env GOROOT)" \
19-
&& wget -q "$GOLANG_SRC_URL" -O golang.tar.gz \
20-
&& echo "$GOLANG_SRC_SHA256 golang.tar.gz" | sha256sum -c - \
21-
&& tar -C /usr/local -xzf golang.tar.gz \
22-
&& wget -q https://raw.githubusercontent.com/docker-library/golang/master/1.9/alpine3.6/no-pic.patch \
23-
&& cd /usr/local/go/src \
24-
&& patch -p2 -i /no-pic.patch \
25-
&& ./make.bash \
12+
RUN apk --no-cache add --virtual build-dependencies gcc musl-dev go git \
2613
&& export GOPATH=/go \
27-
&& mkdir -p /go/src /go/bin \
28-
&& chmod -R 777 /go \
29-
30-
# Compile s3-proxy
14+
&& export PATH=$GOPATH/bin:$PATH \
15+
&& mkdir $GOPATH \
16+
&& chmod -R 777 $GOPATH \
3117
&& go get -u github.com/pottava/aws-s3-proxy \
32-
&& mv /go/bin/aws-s3-proxy /usr/bin \
33-
34-
# Clean up
18+
&& cd /go/src/github.com/pottava/aws-s3-proxy \
19+
&& go build -ldflags "-s -w" \
20+
&& mv aws-s3-proxy /usr/bin \
3521
&& apk del --purge -r build-dependencies \
36-
&& rm -rf /usr/local/go /usr/lib/go /go /golang.tar.gz /*.patch
22+
&& rm -rf /go
3723

3824
EXPOSE 80
3925

0 commit comments

Comments
 (0)