Optimize github build workflow

This commit is contained in:
Karmaa
2025-03-16 20:36:22 -05:00
parent 0ccf3b42e4
commit 6f601483b5
2 changed files with 29 additions and 14 deletions

View File

@@ -18,12 +18,26 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
buildkitd-flags: --debug
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
driver-opts: |
image=moby/buildkit:v0.12.0
image=moby/buildkit:master
network=host
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache Docker layers
uses: actions/cache@v3
@@ -34,7 +48,7 @@ jobs:
${{ runner.os }}-buildx-
- name: Login to Docker Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
@@ -51,18 +65,21 @@ jobs:
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Build and Push Multi-Arch Docker Image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ env.REPO_OWNER }}/termix:${{ env.IMAGE_TAG }}
labels: org.opencontainers.image.source=https://github.com/${{ github.repository }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
outputs: type=registry,compression=zstd,compression-level=19
# Temp fix for https://github.com/docker/build-push-action/issues/252
- name: Move cache

View File

@@ -2,7 +2,8 @@
FROM --platform=$BUILDPLATFORM node:18-alpine AS frontend-builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
# Install all dependencies including dev dependencies needed for build
RUN npm ci
COPY . .
RUN npm run build
@@ -22,7 +23,7 @@ RUN apk add --no-cache python3 make g++ \
&& rm -rf /root/.npm
# Stage 4: Final production image
FROM ubuntu:20.04 as base
FROM ubuntu:20.04-slim as base
# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive \
@@ -47,15 +48,12 @@ RUN apt-get update && \
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list && \
# Add Node.js repo
wget -qO- https://deb.nodesource.com/setup_${NODE_VERSION} | bash - && \
# Install Node.js and MongoDB
# Install Node.js and MongoDB (minimal install)
apt-get update && \
apt-get install -y --no-install-recommends \
nodejs \
mongodb-org=${MONGO_VERSION} \
mongodb-org-server=${MONGO_VERSION} \
mongodb-org-shell=${MONGO_VERSION} \
mongodb-org-mongos=${MONGO_VERSION} \
mongodb-org-tools=${MONGO_VERSION} && \
mongodb-org-shell=${MONGO_VERSION} && \
# Cleanup
apt-get clean && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/* /root/.npm /tmp/* && \