diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5a54ff0..7012817 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,7 @@ on: - dev pull_request: branches: ['*'] + workflow_dispatch: name: Latest Release @@ -23,6 +24,11 @@ jobs: - uses: actions/setup-go@v4 with: go-version: '1.24' + + # Create a dummy directory to appease the go:embed typechecker + - name: Create dummy dist directory + run: mkdir -p src/web/dist && touch src/web/dist/index.html + - name: golangci-lint uses: golangci/golangci-lint-action@v8.0.0 with: @@ -87,32 +93,35 @@ jobs: fetch-depth: 0 - name: Login to ghcr.io - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Convert repository name to lowercase - run: | - REPO_LC=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') - echo "REPO_LC=$REPO_LC" >> $GITHUB_ENV + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=ref,event=tag + type=raw,value=latest - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build and push id: build-and-push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . push: true - tags: | - ghcr.io/${{ env.REPO_LC }}:latest - ghcr.io/${{ env.REPO_LC }}:${{ github.ref_name }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64,linux/arm/v7 build-args: | TARGETARCH @@ -135,26 +144,32 @@ jobs: fetch-depth: 0 - name: Login to ghcr.io - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Convert repository name to lowercase - run: echo "REPO_LC=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=dev - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build and push dev image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . push: true - tags: ghcr.io/${{ env.REPO_LC }}:dev + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64,linux/arm/v7 build-args: | TARGETARCH diff --git a/Dockerfile b/Dockerfile index 2fc7bdb..64f4a52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM node:20-alpine AS ui-builder +FROM --platform=$BUILDPLATFORM node:20-alpine AS ui-builder WORKDIR /app/src/web/frontend COPY src/web/frontend/package*.json ./ RUN npm ci COPY src/web/frontend/ ./ RUN npm run build -FROM golang:1.24-alpine AS builder +FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder # Set the working directory WORKDIR /app