A local-first personal finance app
Improve edge image build times (#147)
Jed Foxab9f77182989
diff --git a/.github/workflows/docker-edge.yml b/.github/workflows/docker-edge.ymlindex 6981cc0e8e..75661ba9b6 100644--- a/.github/workflows/docker-edge.yml+++ b/.github/workflows/docker-edge.yml@@ -8,9 +8,16 @@ on:paths-ignore:- README.md- LICENSE.txt+ pull_request:+ branches:+ - masterschedule:- cron: '0 0 * * *'+permissions:+ contents: read+ packages: write+env:IMAGES: |jlongster/actual-server@@ -25,6 +32,9 @@ jobs:build:name: Build Docker imageruns-on: ubuntu-latest+ strategy:+ matrix:+ os: [ubuntu, alpine]steps:- uses: actions/checkout@v3@@ -40,16 +50,9 @@ jobs:with:# Push to both Docker Hub and Github Container Registryimages: ${{ env.IMAGES }}+ flavor: ${{ matrix.os == 'ubuntu' && '' || format('suffix={0}', matrix.os) }}tags: ${{ env.TAGS }}- - name: Docker meta for Alpine image- id: alpine-meta- uses: docker/metadata-action@v4- with:- images: ${{ env.IMAGES }}- flavor: suffix=-alpine- tags: $${{ env.TAGS }}-- name: Login to Docker Hubuses: docker/login-action@v2with:@@ -63,20 +66,13 @@ jobs:username: ${{ github.repository_owner }}password: ${{ secrets.GITHUB_TOKEN }}- - name: Build and push standard image+ - name: Build and push imageuses: docker/build-push-action@v4with:context: .- push: true- file: docker/edge-ubuntu.Dockerfile+ push: ${{ github.event_name != 'pull_request' }}+ file: docker/edge-${{ matrix.os }}.Dockerfileplatforms: linux/amd64,linux/arm64tags: ${{ steps.meta.outputs.tags }}-- - name: Build and push Alpine image- uses: docker/build-push-action@v4- with:- context: .- push: true- file: docker/edge-alpine.Dockerfile- platforms: linux/amd64,linux/arm64- tags: ${{ steps.alpine-meta.outputs.tags }}+ build-args: |+ GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}diff --git a/docker/edge-alpine.Dockerfile b/docker/edge-alpine.Dockerfileindex 47ce0fbf52..ce66c44c3a 100644--- a/docker/edge-alpine.Dockerfile+++ b/docker/edge-alpine.Dockerfile@@ -1,25 +1,23 @@FROM alpine:3.17 as base-RUN apk add --no-cache nodejs yarn npm python3 openssl build-base+RUN apk add --no-cache nodejs yarn npm python3 openssl build-base jq curlWORKDIR /appADD .yarn ./.yarnADD yarn.lock package.json .yarnrc.yml ./RUN yarn workspaces focus --all --production-# Since we’re just using static files, use the Ubuntu image to build the frontend-# (otherwise electron fails to build)-FROM node:16-bullseye as frontend-WORKDIR /frontend-# Rebuild whenever there are new commits to the frontend-ADD "https://api.github.com/repos/actualbudget/actual/commits" /tmp/actual-commit.json-RUN git clone --depth=1 https://github.com/actualbudget/actual /frontend-RUN yarn install-RUN ./bin/package-browser+RUN mkdir /public+ADD "https://api.github.com/repos/actualbudget/actual/actions/artifacts?name=actual-web&per_page=100" /tmp/artifacts.json+RUN jq -r '[.artifacts[] | select(.workflow_run.head_branch == "master")][0]' /tmp/artifacts.json > /tmp/latest-build.json++ARG GITHUB_TOKEN+RUN curl -L -o /tmp/desktop-client.zip --header "Authorization: Bearer ${GITHUB_TOKEN}" $(jq -r '.archive_download_url' /tmp/latest-build.json)+RUN unzip /tmp/desktop-client.zip -d /publicFROM alpine:3.17 as prodRUN apk add --no-cache nodejs tiniWORKDIR /appCOPY --from=base /app/node_modules /app/node_modules-COPY --from=frontend /frontend/packages/desktop-client/build /public+COPY --from=base /public /publicADD package.json app.js ./ADD src ./srcENTRYPOINT ["/sbin/tini","-g", "--"]diff --git a/docker/edge-ubuntu.Dockerfile b/docker/edge-ubuntu.Dockerfileindex 02596be497..70edffcdf1 100644--- a/docker/edge-ubuntu.Dockerfile+++ b/docker/edge-ubuntu.Dockerfile@@ -1,23 +1,23 @@FROM node:16-bullseye as base-RUN apt-get update && apt-get install -y openssl+RUN apt-get update && apt-get install -y openssl jqWORKDIR /appADD .yarn ./.yarnADD yarn.lock package.json .yarnrc.yml ./RUN yarn workspaces focus --all --production-FROM node:16-bullseye as frontend-WORKDIR /frontend-# Rebuild whenever there are new commits to the frontend-ADD "https://api.github.com/repos/actualbudget/actual/commits" /tmp/actual-commit.json-RUN git clone --depth=1 https://github.com/actualbudget/actual /frontend-RUN yarn install-RUN ./bin/package-browser+RUN mkdir /public+ADD "https://api.github.com/repos/actualbudget/actual/actions/artifacts?name=actual-web&per_page=100" /tmp/artifacts.json+RUN jq -r '[.artifacts[] | select(.workflow_run.head_branch == "master")][0]' /tmp/artifacts.json > /tmp/latest-build.json++ARG GITHUB_TOKEN+RUN curl -L -o /tmp/desktop-client.zip --header "Authorization: Bearer ${GITHUB_TOKEN}" $(jq -r '.archive_download_url' /tmp/latest-build.json)+RUN unzip /tmp/desktop-client.zip -d /publicFROM node:16-bullseye-slim as prodRUN apt-get update && apt-get install tini && apt-get clean -y && rm -rf /var/lib/apt/lists/*WORKDIR /appCOPY --from=base /app/node_modules /app/node_modules-COPY --from=frontend /frontend/packages/desktop-client/build /public+COPY --from=base /public /publicADD package.json app.js ./ADD src ./srcENTRYPOINT ["/usr/bin/tini","-g", "--"]