forked from goethite/gostint
/
Dockerfile
67 lines (56 loc) · 1.86 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
##############################################
# Build:
# docker build -t gostint .
#
# Run:
# docker run --name gostint -p 3333:3232 \
# --privileged=true \
# -v /srv/gostint/lib:/var/lib/gostint \
# -e VAULT_ADDR="$VAULT_ADDR" \
# -e GOSTINT_DBAUTH_TOKEN="$token" \
# -e GOSTINT_ROLEID="$roleid" \
# -e GOSTINT_ROLENAME="gostint-role" \
# -e GOSTINT_DBURL="dbhost:27017" \
# gostint
#
# cert.pem and key.pm are needed in /srv/gostint/lib, these can be redirected to
# another location using GOSTINT_SSL_CERT and GOSTINT_SSL_KEY respectively.
##############################################
# Build stage
FROM golang:1.12.7 as builder
WORKDIR /go/src/github.com/gbevan/gostint
COPY main.go banner.go Gopkg* ./
COPY v1 ./v1/
COPY approle ./approle/
COPY authenticate ./authenticate/
COPY apierrors ./apierrors/
COPY cleanup ./cleanup/
COPY health ./health/
COPY metrics ./metrics/
COPY jobqueues ./jobqueues/
COPY logmsg ./logmsg/
COPY pingclean ./pingclean/
COPY state ./state/
COPY ui ./ui/
RUN \
go get github.com/golang/dep/cmd/dep && \
dep ensure -v --vendor-only && \
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o gostint .
##############################################
# Exe stage
FROM alpine
# FROM alpine:3.3
COPY --from=builder /go/src/github.com/gbevan/gostint/gostint /usr/bin
WORKDIR /app
COPY start-image.sh .
# apk add --no-cache docker jq curl openssl sudo && \
# TODO: look at pinning the docker version to match Gopkg.toml constraint
RUN \
apk add --no-cache docker sudo curl && \
adduser -S -D -H -G docker -h /app gostint && \
mkdir -p /var/lib/gostint && \
chown gostint /var/lib/gostint && \
echo "gostint ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
# sudo priv is removed immediately after dockerd starts, see start-image.sh
USER gostint
ENTRYPOINT ["/app/start-image.sh"]