Use Depot for Docker builds (#55)
Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
This commit is contained in:
parent
99ab993f2f
commit
0aa331cd4f
|
@ -4,4 +4,4 @@
|
|||
/.git
|
||||
/frontend/node_modules
|
||||
/frontend/.angular
|
||||
|
||||
/dist
|
||||
|
|
|
@ -20,25 +20,13 @@ jobs:
|
|||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Set Node.js 18.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18.x
|
||||
- name: Build Frontend
|
||||
run: |
|
||||
make frontend-build-${{ github.ref_name == 'sandbox' && 'sandbox' || 'prod' }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
image: 'tonistiigi/binfmt:latest'
|
||||
platforms: 'amd64,arm64'
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Set up depot.dev multi-arch runner
|
||||
uses: depot/setup-action@v1
|
||||
# Login against a Docker registry except on PR
|
||||
# https://github.com/docker/login-action
|
||||
- name: Log into registry ${{ env.REGISTRY }}
|
||||
|
@ -55,7 +43,7 @@ jobs:
|
|||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
flavor: |
|
||||
latest=false
|
||||
latest=${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
|
||||
tags: |
|
||||
type=ref,enable=true,event=branch
|
||||
type=ref,enable=true,event=tag
|
||||
|
@ -63,8 +51,9 @@ jobs:
|
|||
# Build and push Docker image with Buildx (don't push on PR)
|
||||
# https://github.com/docker/build-push-action
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v3
|
||||
uses: depot/build-push-action@v1
|
||||
with:
|
||||
project: vhwr5r7tw1
|
||||
platforms: linux/amd64,linux/arm64
|
||||
context: .
|
||||
file: Dockerfile
|
||||
|
@ -73,5 +62,3 @@ jobs:
|
|||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
FASTEN_ENV=${{ github.ref_name == 'sandbox' && 'sandbox' || 'prod' }}
|
||||
# cache-from: type=gha
|
||||
# cache-to: type=gha,mode=max
|
||||
|
|
|
@ -42,7 +42,7 @@ jobs:
|
|||
go install github.com/golang/mock/mockgen@v1.6.0
|
||||
go generate ./...
|
||||
make backend-test-coverage
|
||||
CGO_ENABLED=0 go build ./backend/cmd/fasten/
|
||||
CGO_ENABLED=0 go build -buildvcs=false ./backend/cmd/fasten/
|
||||
- name: Upload coverage
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
|
|
23
Dockerfile
23
Dockerfile
|
@ -1,21 +1,22 @@
|
|||
#########################################################################################################
|
||||
# Frontend Build
|
||||
#########################################################################################################
|
||||
# !!!! GAH !!!!
|
||||
# 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
|
||||
|
||||
#make sure you run `make frontend-build-sandbox` or `make frontend-build-main` before `docker build .`
|
||||
|
||||
#FROM node:18 as frontend-build
|
||||
#ARG FASTEN_ENV=sandbox
|
||||
#WORKDIR /usr/src/fastenhealth/frontend
|
||||
#COPY frontend/ ./
|
||||
#
|
||||
#RUN yarn install --frozen-lockfile && \
|
||||
# yarn run build -- --configuration ${FASTEN_ENV} --output-path=../dist
|
||||
# instead, we use https://depot.dev/ to do our multi-arch builds on native ARM and AMD nodes.
|
||||
|
||||
FROM node:18 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 yarn run build -- --configuration ${FASTEN_ENV} --output-path=../dist
|
||||
|
||||
#########################################################################################################
|
||||
# Backend Build
|
||||
|
@ -45,7 +46,7 @@ FROM gcr.io/distroless/static-debian11
|
|||
|
||||
WORKDIR /opt/fasten/
|
||||
COPY --from=backend-build /opt/fasten/ /opt/fasten/
|
||||
COPY dist/ /opt/fasten/web/
|
||||
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
|
||||
|
|
|
@ -117,3 +117,7 @@ Jason Kulatunga - Initial Development - @AnalogJ
|
|||
# Sponsors
|
||||
|
||||
Fasten is only possible with the help of my [Github Sponsors](https://github.com/sponsors/AnalogJ/) and Reddit supporters!
|
||||
|
||||
I'd also like to thank the following Corporate Sponsors:
|
||||
|
||||
<a href="https://depot.dev/"><img src="https://raw.githubusercontent.com/fastenhealth/docs/main/img/sponsors/depot.png" height="100px" /></a>
|
||||
|
|
Loading…
Reference in New Issue