This repository has been archived by the owner on Feb 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
47 lines (47 loc) · 1.83 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
# ------------------------------------------------------------------------------
# configure env and workdir - golang:1.12.7
# ------------------------------------------------------------------------------
FROM golang:1.12.7 AS pre-build
LABEL SQUAD="getninjas"
RUN useradd spot-ninja
ENV APP /home/spot-ninja
ENV FLEETIGNORED "fleet1,fleet2"
ENV SQSURL "https://sqs.example.com"
WORKDIR ${APP}/src/spot-ninja
COPY . ${APP}/src/spot-ninja
# ------------------------------------------------------------------------------
# test - test and conver
# ------------------------------------------------------------------------------
FROM pre-build AS test
LABEL SQUAD="getninjas"
RUN go mod download
RUN go test -cover ./config/ \
&& go test -cover ./pkg/logic/ \
&& go test -cover ./pkg/structure/ \
&& go test -cover ./pkg/api/ \
&& go vet ./pkg/api/ \
&& go vet ./cmd/spot-ninja/ \
&& go vet ./config/ \
&& go vet ./pkg/logic/ \
&& go vet ./pkg/structure/ \
&& go vet ./pkg/api/
# ------------------------------------------------------------------------------
# builder - build the binary
# ------------------------------------------------------------------------------
FROM test AS builder
LABEL SQUAD="getninjas"
ENV APP /home/spot-ninja
RUN CGO_ENABLED=0 GOOS=linux \
go build -o ${APP}/spot-ninja ./cmd/spot-ninja/main.go \
&& chmod +x ${APP}/spot-ninja \
&& echo "nobody:x:65534:65534:Nobody:/:" > ${APP}/etc_passwd
## ------------------------------------------------------------------------------
## runner - daemon image
## ------------------------------------------------------------------------------
FROM scratch AS runner
ENV APP /home/spot-ninja
COPY --from=builder /etc/ssl /etc/ssl
COPY --from=builder ${APP}/etc_passwd /etc/passwd
COPY --from=builder ${APP}/spot-ninja /spot-ninja
USER nobody
CMD ["/spot-ninja"]