Use Depot for Docker builds (#55)

Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
This commit is contained in:
Jason Kulatunga 2023-01-31 18:30:55 -08:00 committed by GitHub
parent 99ab993f2f
commit 0aa331cd4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 32 deletions

View File

@ -4,4 +4,4 @@
/.git /.git
/frontend/node_modules /frontend/node_modules
/frontend/.angular /frontend/.angular
/dist

View File

@ -20,25 +20,13 @@ jobs:
permissions: permissions:
contents: read contents: read
packages: write packages: write
id-token: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Set Node.js 18.x - name: Set up depot.dev multi-arch runner
uses: actions/setup-node@v3 uses: depot/setup-action@v1
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
# Login against a Docker registry except on PR # Login against a Docker registry except on PR
# https://github.com/docker/login-action # https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }} - name: Log into registry ${{ env.REGISTRY }}
@ -55,7 +43,7 @@ jobs:
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4
with: with:
flavor: | flavor: |
latest=false latest=${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
tags: | tags: |
type=ref,enable=true,event=branch type=ref,enable=true,event=branch
type=ref,enable=true,event=tag type=ref,enable=true,event=tag
@ -63,8 +51,9 @@ jobs:
# Build and push Docker image with Buildx (don't push on PR) # Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action # https://github.com/docker/build-push-action
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v3 uses: depot/build-push-action@v1
with: with:
project: vhwr5r7tw1
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
context: . context: .
file: Dockerfile file: Dockerfile
@ -73,5 +62,3 @@ jobs:
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
build-args: | build-args: |
FASTEN_ENV=${{ github.ref_name == 'sandbox' && 'sandbox' || 'prod' }} FASTEN_ENV=${{ github.ref_name == 'sandbox' && 'sandbox' || 'prod' }}
# cache-from: type=gha
# cache-to: type=gha,mode=max

View File

@ -42,7 +42,7 @@ jobs:
go install github.com/golang/mock/mockgen@v1.6.0 go install github.com/golang/mock/mockgen@v1.6.0
go generate ./... go generate ./...
make backend-test-coverage 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 - name: Upload coverage
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:

View File

@ -1,21 +1,22 @@
######################################################################################################### #########################################################################################################
# Frontend Build # 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://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 # 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 && \ # instead, we use https://depot.dev/ to do our multi-arch builds on native ARM and AMD nodes.
# yarn run build -- --configuration ${FASTEN_ENV} --output-path=../dist
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 # Backend Build
@ -45,7 +46,7 @@ FROM gcr.io/distroless/static-debian11
WORKDIR /opt/fasten/ WORKDIR /opt/fasten/
COPY --from=backend-build /opt/fasten/ /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 --from=backend-build /go/bin/fasten /opt/fasten/fasten
COPY LICENSE.md /opt/fasten/LICENSE.md COPY LICENSE.md /opt/fasten/LICENSE.md
COPY config.yaml /opt/fasten/config/config.yaml COPY config.yaml /opt/fasten/config/config.yaml

View File

@ -117,3 +117,7 @@ Jason Kulatunga - Initial Development - @AnalogJ
# Sponsors # Sponsors
Fasten is only possible with the help of my [Github Sponsors](https://github.com/sponsors/AnalogJ/) and Reddit supporters! 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>