generated from PackagrIO/goweb-template
-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Dockerfile
61 lines (48 loc) · 2.52 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
#########################################################################################################
# Frontend Build
#########################################################################################################
# Note, when running on Github, we cannot use standard Github Action runners, as ARM support is only via QEMU emulation
# (until https://github.com/actions/runner-images/issues/2187)
# QEMU emulation has a bunch of performance issues, as described in the links below.
# https://blog.thesparktree.com/docker-multi-arch-github-actions#q-i-enabled-multi-arch-builds-and-my-builds-take-1h-what-gives
# https://github.com/fastenhealth/fasten-onprem/issues/43
#
# instead, we use https://depot.dev/ to do our multi-arch builds on native ARM and AMD nodes.
FROM node:20 as frontend-build
ARG FASTEN_ENV=sandbox
WORKDIR /usr/src/fastenhealth/frontend
COPY frontend/package.json frontend/yarn.lock ./
RUN yarn install --frozen-lockfile
COPY frontend/ ./
RUN --mount=type=cache,target=/tmp/lock,sharing=locked \
yarn run build -- --configuration ${FASTEN_ENV} --output-path=../dist
#########################################################################################################
# Backend Build
#########################################################################################################
FROM golang:1.21 as backend-build
WORKDIR /go/src/github.com/fastenhealth/fasten-onprem
COPY . .
RUN --mount=type=cache,target=/tmp/lock,sharing=locked \
go mod vendor \
&& go install github.com/golang/mock/mockgen@v1.6.0 \
&& go generate ./... \
&& go vet ./... \
&& go test -timeout=20m ./... \
&& go build -ldflags "-extldflags=-static" -tags "static" -o /go/bin/fasten ./backend/cmd/fasten/
# create folder structure
RUN mkdir -p /opt/fasten/db \
&& mkdir -p /opt/fasten/web \
&& mkdir -p /opt/fasten/config
#########################################################################################################
# Distribution Build
#########################################################################################################
FROM gcr.io/distroless/static-debian11
EXPOSE 8080
WORKDIR /opt/fasten/
COPY --from=backend-build /opt/fasten/ /opt/fasten/
COPY --from=frontend-build /usr/src/fastenhealth/dist /opt/fasten/web
COPY --from=backend-build /go/bin/fasten /opt/fasten/fasten
COPY LICENSE.md /opt/fasten/LICENSE.md
COPY config.yaml /opt/fasten/config/config.yaml
RUN ["/opt/fasten/fasten", "--help"]
CMD ["/opt/fasten/fasten", "start", "--config", "/opt/fasten/config/config.yaml"]