-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
53 lines (34 loc) · 1.31 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Build image
FROM golang:1.14-alpine3.11 AS builder
ENV GOFLAGS="-mod=readonly"
RUN apk add --update --no-cache ca-certificates make git curl mercurial bzr
RUN mkdir -p /workspace
WORKDIR /workspace
ARG GOPROXY
COPY go.* ./
RUN go mod download
ARG BUILD_TARGET
COPY Makefile *.mk ./
RUN if [[ "${BUILD_TARGET}" == "debug" ]]; then make build-debug-deps; else make build-release-deps; fi
COPY . .
RUN set -xe && \
if [[ "${BUILD_TARGET}" == "debug" ]]; then \
cd /tmp; GOBIN=/workspace/build/debug go get github.com/go-delve/delve/cmd/dlv; cd -; \
make build-debug; \
mv build/debug /build; \
else \
make build-release; \
mv build/release /build; \
fi
# Final image
FROM alpine:3.11
RUN apk add --update --no-cache ca-certificates tzdata bash curl
SHELL ["/bin/bash", "-c"]
# set up nsswitch.conf for Go's "netgo" implementation
# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-424546457
RUN test ! -e /etc/nsswitch.conf && echo 'hosts: files dns' > /etc/nsswitch.conf
ARG BUILD_TARGET
RUN if [[ "${BUILD_TARGET}" == "debug" ]]; then apk add --update --no-cache libc6-compat; fi
COPY --from=builder /build/* /usr/local/bin/
EXPOSE 8000 8001 10000
CMD ["modern-go-bootstrap", "--telemetry-addr", ":10000", "--http-addr", ":8000", "--grpc-addr", ":8001"]