-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
44 lines (33 loc) · 1.35 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
####################
## Build frontend ## ---------------------------------------------------------
####################
FROM node:lts-alpine AS frontend
WORKDIR /app
ADD ./internal/webui/frontend /app
RUN npm install && npm run build
#####################
## Build nighshift ## ---------------------------------------------------------
#####################
FROM docker.io/golang:1.21 AS nightshift
ARG CODE=github.com/joyrex2001/nightshift
ADD . /go/src/${CODE}/
COPY --from=frontend /app/dist /go/src/${CODE}/internal/webui/frontend/dist
RUN cd /go/src/${CODE} \
&& go get github.com/go-bindata/go-bindata/... \
&& go install github.com/go-bindata/go-bindata/... \
&& go generate ./internal/... \
&& go test ./... \
&& CGO_ENABLED=0 go build -ldflags \
"-X github.com/joyrex2001/nightshift/internal/config.Date=`date -u +%Y%m%d-%H%M%S` \
-X github.com/joyrex2001/nightshift/internal/config.Build=`git rev-list -1 HEAD` \
-X github.com/joyrex2001/nightshift/internal/config.Version=`git describe --tags`" \
-o /app/nightshift
#################
## Final image ## ------------------------------------------------------------
#################
FROM docker.io/busybox:latest
COPY --from=nightshift /app /app
COPY --from=nightshift /usr/share/zoneinfo /usr/share/zoneinfo
WORKDIR /app
ENTRYPOINT ["/app/nightshift"]
CMD ["--stderrthreshold", "info"]