-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
30 lines (25 loc) · 1.04 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# This Dockerfile is a demo of using go-dev to build a go binary using multi stage build
# It is based on
# https://docs.docker.com/v17.09/engine/userguide/eng-image/dockerfile_best-practices/#use-multi-stage-builds
#
# The builder-image go-dev can be found in hack/go-dev
# Versions can be found on https://hub.docker.com/r/dyweb/go-dev/tags
FROM dyweb/go-dev:1.13.6 as builder
LABEL maintainer="[email protected]"
ARG PROJECT_ROOT=/go/src/github.com/dyweb/gommon/
WORKDIR $PROJECT_ROOT
# Copy all project and build it
COPY . $PROJECT_ROOT
RUN make install
# NOTE: use ubuntu instead of alphine
#
# When using alpine I saw standard_init_linux.go:190: exec user process caused "no such file or directory",
# because I didn't compile go with static flag
# https://stackoverflow.com/questions/49535379/binary-compiled-in-prestage-doesnt-work-in-scratch-container
FROM ubuntu:18.04 as runner
LABEL maintainer="[email protected]"
LABEL github="github.com/dyweb/gommon"
WORKDIR /usr/bin
COPY --from=builder /go/bin/gommon .
ENTRYPOINT ["gommon"]
CMD ["help"]