2022-10-09 12:08:23 -06:00
|
|
|
#########################################################################################################
|
|
|
|
# Frontend Build
|
|
|
|
#########################################################################################################
|
2023-01-31 19:30:55 -07:00
|
|
|
# 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.
|
2023-01-26 04:08:13 -07:00
|
|
|
# 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
|
|
|
|
#
|
2023-01-31 19:30:55 -07:00
|
|
|
# instead, we use https://depot.dev/ to do our multi-arch builds on native ARM and AMD nodes.
|
2023-01-26 04:08:13 -07:00
|
|
|
|
2023-10-03 15:46:49 -06:00
|
|
|
FROM node:20 as frontend-build
|
2023-01-31 19:30:55 -07:00
|
|
|
ARG FASTEN_ENV=sandbox
|
|
|
|
WORKDIR /usr/src/fastenhealth/frontend
|
|
|
|
COPY frontend/package.json frontend/yarn.lock ./
|
2023-01-26 03:45:33 -07:00
|
|
|
|
2023-01-31 19:30:55 -07:00
|
|
|
RUN yarn install --frozen-lockfile
|
|
|
|
COPY frontend/ ./
|
2023-07-14 21:43:57 -06:00
|
|
|
RUN --mount=type=cache,target=/tmp/lock,sharing=locked \
|
|
|
|
yarn run build -- --configuration ${FASTEN_ENV} --output-path=../dist
|
2022-09-21 19:57:38 -06:00
|
|
|
|
2022-10-09 12:08:23 -06:00
|
|
|
#########################################################################################################
|
|
|
|
# Backend Build
|
|
|
|
#########################################################################################################
|
2023-10-03 15:46:49 -06:00
|
|
|
FROM golang:1.21 as backend-build
|
2022-11-01 00:08:42 -06:00
|
|
|
|
2023-08-27 18:09:46 -06:00
|
|
|
WORKDIR /go/src/github.com/fastenhealth/fasten-onprem
|
2022-09-21 19:57:38 -06:00
|
|
|
COPY . .
|
|
|
|
|
2023-07-14 21:43:57 -06:00
|
|
|
RUN --mount=type=cache,target=/tmp/lock,sharing=locked \
|
|
|
|
go mod vendor \
|
2022-09-21 19:57:38 -06:00
|
|
|
&& go install github.com/golang/mock/mockgen@v1.6.0 \
|
|
|
|
&& go generate ./... \
|
|
|
|
&& go vet ./... \
|
2023-11-08 09:31:34 -07:00
|
|
|
&& go build -ldflags "-extldflags=-static" -tags "static" -o /go/bin/fasten ./backend/cmd/fasten/
|
2022-09-21 19:57:38 -06:00
|
|
|
|
2022-09-26 23:14:29 -06:00
|
|
|
# create folder structure
|
|
|
|
RUN mkdir -p /opt/fasten/db \
|
2022-09-27 23:23:40 -06:00
|
|
|
&& mkdir -p /opt/fasten/web \
|
2022-12-17 16:10:19 -07:00
|
|
|
&& mkdir -p /opt/fasten/config
|
2022-09-21 19:57:38 -06:00
|
|
|
|
2022-10-09 12:08:23 -06:00
|
|
|
#########################################################################################################
|
|
|
|
# Distribution Build
|
|
|
|
#########################################################################################################
|
2022-12-17 16:10:19 -07:00
|
|
|
FROM gcr.io/distroless/static-debian11
|
2022-10-09 12:08:23 -06:00
|
|
|
|
2023-04-17 21:22:30 -06:00
|
|
|
EXPOSE 8080
|
2022-09-26 23:14:29 -06:00
|
|
|
WORKDIR /opt/fasten/
|
|
|
|
COPY --from=backend-build /opt/fasten/ /opt/fasten/
|
2023-01-31 19:30:55 -07:00
|
|
|
COPY --from=frontend-build /usr/src/fastenhealth/dist /opt/fasten/web
|
2022-09-21 19:57:38 -06:00
|
|
|
COPY --from=backend-build /go/bin/fasten /opt/fasten/fasten
|
2022-09-25 12:14:00 -06:00
|
|
|
COPY LICENSE.md /opt/fasten/LICENSE.md
|
2022-09-26 23:14:29 -06:00
|
|
|
COPY config.yaml /opt/fasten/config/config.yaml
|
2022-12-17 16:10:19 -07:00
|
|
|
CMD ["/opt/fasten/fasten", "start", "--config", "/opt/fasten/config/config.yaml"]
|
2022-10-09 12:08:23 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|