-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
46 lines (35 loc) · 1.2 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
FROM node:18.17.0 AS node
ENV PUBLIC_PATH /
WORKDIR /app
COPY ./portal/package*.json ./
RUN npm install
COPY ./portal/ ./
RUN npm run build
RUN for e in css csv html js json map svg txt; do find . -iname '*.$e' -exec gzip -k9 {} \; ; done
FROM golang:latest AS golang
WORKDIR /app
COPY ./server/ ./
RUN mkdir -p build
RUN ls -alh api
RUN mkdir -p api
RUN cd cmd/server && go build -o /app/build/server -ldflags '-extldflags "-static"' *.go
RUN cd cmd/ingester && go build -o /app/build/ingester -ldflags '-extldflags "-static"' *.go
FROM alpine:latest AS env
ARG GIT_HASH=missing
ARG VERSION=missing
WORKDIR /app
RUN echo "export GIT_HASH=$GIT_HASH" > static.env
RUN echo "export FIELDKIT_VERSION=$VERSION" >> static.env
RUN cat static.env
FROM scratch
COPY --from=golang /app/build/server /
COPY --from=golang /app/build/ingester /
COPY --from=node /app/build /portal
COPY --from=golang /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=env /app/static.env /etc/
COPY --from=golang /app/api /api/
# Downstream Dockerfile's require this. I'd like to use the above paths, though.
COPY --from=golang /etc/ssl/certs/ca-certificates.crt /
COPY --from=env /app/static.env /
EXPOSE 80
ENTRYPOINT ["/server"]