-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (37 loc) · 1.42 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
# First container - does the build
FROM golang:1.17.7-alpine AS builder
RUN apk update && apk upgrade && \
apk add --no-cache git
WORKDIR /build/acnode-dashboard
# copy sources into container build environment
COPY . /build/acnode-dashboard/
RUN git status
RUN git rev-list -1 HEAD > version
RUN cat version
RUN go build
RUN cd bootstrapper && go build
RUN cd logwatcher && go build
RUN cd statuswatcher && go build
# Second container - build frontend
FROM node:17.6.0-alpine as nodebuilder
RUN apk add --no-cache git
WORKDIR /build/acnode-dashboard/frontend
COPY . /build/acnode-dashboard/
RUN npm install
# stop git thinking it's dirty because of this
RUN git checkout package-lock.json
RUN npm run build && cd dist && tar -cf ../bundle.tar static index.html
# Third container - this one actually runs the code
FROM alpine:latest
WORKDIR /opt/acnode-dashboard
COPY --from=builder /build/acnode-dashboard/acnode-dashboard acnode-dashboard
COPY --from=builder /build/acnode-dashboard/bootstrapper/bootstrapper bootstrapper
COPY --from=builder /build/acnode-dashboard/statuswatcher/statuswatcher statuswatcher
COPY --from=builder /build/acnode-dashboard/version version
COPY --from=nodebuilder /build/acnode-dashboard/frontend/bundle.tar frontend.tar
COPY static static
COPY templates templates
RUN cd static && tar -xf ../frontend.tar && rm -f ../frontend.tar
RUN adduser -S acnodedashboard
USER acnodedashboard
CMD ["./acnode-dashboard"]