forked from flatcar/nebraska
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
64 lines (47 loc) · 1.56 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
FROM golang:1.17 as base-build
ARG NEBRASKA_VERSION=""
ENV GOPATH=/go \
GOPROXY=https://proxy.golang.org \
GO111MODULE=on\
CGO_ENABLED=0\
GOOS=linux
# Backend build
FROM base-build as version-build
ARG NEBRASKA_VERSION=""
WORKDIR /app/
COPY ./.git ./.git
COPY ./backend ./backend
# We optionally allow to set the version to display for the image.
# This is mainly used because when copying the source dir, docker will
# ignore the files we requested it to, and thus produce a "dirty" build
# as git status returns changes (when effectively for the built source
# there's none).
ENV VERSION=${NEBRASKA_VERSION}
FROM version-build as backend-build
# make version uses the existing VERSION if set, otherwise gets it from git
RUN export VERSION=`make -f backend/Makefile version | tail -1` && echo "VERSION:$VERSION"
WORKDIR /app/backend
# COPY backend/go.mod backend/go.sum ./
# RUN go mod download
COPY ./backend ./
RUN make build
# Frontend build
FROM docker.io/library/node:15 as frontend-install
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
FROM frontend-install AS frontend-build
WORKDIR /app/frontend
COPY frontend ./
RUN npm run build
# Final Docker image
FROM alpine:3.15.0
RUN apk update && \
apk add ca-certificates tzdata
WORKDIR /nebraska
COPY --from=backend-build /app/backend/bin/nebraska ./
COPY --from=frontend-build /app/frontend/build/ ./static/
ENV NEBRASKA_DB_URL "postgres://postgres@postgres:5432/nebraska?sslmode=disable&connect_timeout=10"
EXPOSE 8000
USER nobody
CMD ["/nebraska/nebraska", "-http-static-dir=/nebraska/static"]