forked from banzaicloud/cloudinfo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
71 lines (43 loc) · 1.61 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# UI build image
FROM node:12.3.1 as frontend
WORKDIR /web
COPY web/package.json web/package-lock.json /web/
RUN npm install
COPY web/ /web/
RUN npm run build-prod
# 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.* /workspace/
RUN go mod download
COPY Makefile main-targets.mk /workspace/
COPY --from=frontend /web/dist/web /workspace/web/dist/web
COPY . /workspace
ARG BUILD_TARGET
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.12
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/
COPY configs /etc/cloudinfo/serviceconfig
RUN sed -i "s|dataLocation: ./configs/|dataLocation: /etc/cloudinfo/serviceconfig/|g" /etc/cloudinfo/serviceconfig/services.yaml
ENV CLOUDINFO_SERVICELOADER_SERVICECONFIGLOCATION "/etc/cloudinfo/serviceconfig"
CMD ["cloudinfo"]