-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
68 lines (47 loc) · 1.19 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
FROM golang:1-alpine AS deps
RUN apk add --no-cache build-base
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download -x
###
FROM deps AS build
ARG LDFLAGS
COPY app ./app/
COPY cmd ./cmd/
COPY *.go ./
RUN CGO_ENABLED=1 \
GOFLAGS='-tags="sqlite_json"' \
GOOS=linux \
GOARCH=amd64 \
go build -x -ldflags="${LDFLAGS} -X 'github.com/infogulch/xtemplate/app.defaultWatchTemplates=false' -X 'github.com/infogulch/xtemplate/app.defaultListenAddress=0.0.0.0:80'" -o /build/xtemplate ./cmd
###
FROM alpine AS dist
ENV USER=appuser
ENV UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
WORKDIR /app
USER $USER:$USER
EXPOSE 80
COPY --from=build /build/xtemplate /app/xtemplate
ENTRYPOINT ["/app/xtemplate"]
###
FROM dist AS test
COPY ./test/templates /app/templates/
COPY ./test/data /app/data/
COPY ./test/migrations /app/migrations/
COPY ./test/config.json /app/
USER root:root
RUN mkdir /app/dataw
VOLUME /app/dataw
RUN ["/app/xtemplate", "--version"]
WORKDIR /app/dataw
CMD ["--loglevel", "-4", "--config-file", "../config.json"]
###
FROM dist as final