feat: Add BASE_PATH support with -base image variant

This commit is contained in:
Yash 2026-01-29 00:15:19 +05:30
parent 860e6390f1
commit 2e10ceee0e
2 changed files with 31 additions and 15 deletions

View file

@ -23,6 +23,15 @@ jobs:
permissions: permissions:
contents: read contents: read
packages: write packages: write
strategy:
matrix:
include:
- type: standard
base_path: ""
suffix: ""
- type: base
base_path: "/umami"
suffix: "-base"
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
@ -55,6 +64,7 @@ jobs:
REF_TYPE="${{ github.ref_type }}" REF_TYPE="${{ github.ref_type }}"
REF_NAME="${{ github.ref_name }}" REF_NAME="${{ github.ref_name }}"
INCLUDE_LATEST="${{ github.event.inputs.include_latest }}" INCLUDE_LATEST="${{ github.event.inputs.include_latest }}"
SUFFIX="${{ matrix.suffix }}"
# Determine version source # Determine version source
if [[ -n "$INPUT" ]]; then if [[ -n "$INPUT" ]]; then
@ -74,30 +84,30 @@ jobs:
if [[ "$VERSION" == *-* ]]; then if [[ "$VERSION" == *-* ]]; then
# prerelease: only version tag # prerelease: only version tag
GHCR_TAGS="ghcr.io/${{ github.repository }}:$VERSION" GHCR_TAGS="ghcr.io/${{ github.repository }}:$VERSION$SUFFIX"
DOCKER_TAGS="umamisoftware/umami:$VERSION" DOCKER_TAGS="umamisoftware/umami:$VERSION$SUFFIX"
else else
# stable release: version + hierarchy # stable release: version + hierarchy
GHCR_TAGS="ghcr.io/${{ github.repository }}:$VERSION" GHCR_TAGS="ghcr.io/${{ github.repository }}:$VERSION$SUFFIX"
GHCR_TAGS="$GHCR_TAGS,ghcr.io/${{ github.repository }}:${MAJOR}.${MINOR}" GHCR_TAGS="$GHCR_TAGS,ghcr.io/${{ github.repository }}:${MAJOR}.${MINOR}$SUFFIX"
GHCR_TAGS="$GHCR_TAGS,ghcr.io/${{ github.repository }}:${MAJOR}" GHCR_TAGS="$GHCR_TAGS,ghcr.io/${{ github.repository }}:${MAJOR}$SUFFIX"
GHCR_TAGS="$GHCR_TAGS,ghcr.io/${{ github.repository }}:postgresql-latest" GHCR_TAGS="$GHCR_TAGS,ghcr.io/${{ github.repository }}:postgresql-latest$SUFFIX"
DOCKER_TAGS="umamisoftware/umami:$VERSION" DOCKER_TAGS="umamisoftware/umami:$VERSION$SUFFIX"
DOCKER_TAGS="$DOCKER_TAGS,umamisoftware/umami:${MAJOR}.${MINOR}" DOCKER_TAGS="$DOCKER_TAGS,umamisoftware/umami:${MAJOR}.${MINOR}$SUFFIX"
DOCKER_TAGS="$DOCKER_TAGS,umamisoftware/umami:${MAJOR}" DOCKER_TAGS="$DOCKER_TAGS,umamisoftware/umami:${MAJOR}$SUFFIX"
DOCKER_TAGS="$DOCKER_TAGS,umamisoftware/umami:postgresql-latest" DOCKER_TAGS="$DOCKER_TAGS,umamisoftware/umami:postgresql-latest$SUFFIX"
# Add latest tag based on trigger and input # Add latest tag based on trigger and input
if [[ "$REF_TYPE" == "tag" ]] || [[ "$INCLUDE_LATEST" == "true" ]]; then if [[ "$REF_TYPE" == "tag" ]] || [[ "$INCLUDE_LATEST" == "true" ]]; then
GHCR_TAGS="$GHCR_TAGS,ghcr.io/${{ github.repository }}:latest" GHCR_TAGS="$GHCR_TAGS,ghcr.io/${{ github.repository }}:latest$SUFFIX"
DOCKER_TAGS="$DOCKER_TAGS,umamisoftware/umami:latest" DOCKER_TAGS="$DOCKER_TAGS,umamisoftware/umami:latest$SUFFIX"
fi fi
fi fi
else else
# Non-tag build (e.g. from main branch) # Non-tag build (e.g. from main branch)
GHCR_TAGS="ghcr.io/${{ github.repository }}:${REF_NAME}" GHCR_TAGS="ghcr.io/${{ github.repository }}:${REF_NAME}$SUFFIX"
DOCKER_TAGS="umamisoftware/umami:${REF_NAME}" DOCKER_TAGS="umamisoftware/umami:${REF_NAME}$SUFFIX"
fi fi
echo "ghcr_tags=$GHCR_TAGS" >> $GITHUB_OUTPUT echo "ghcr_tags=$GHCR_TAGS" >> $GITHUB_OUTPUT
@ -112,6 +122,8 @@ jobs:
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ steps.compute.outputs.ghcr_tags }} tags: ${{ steps.compute.outputs.ghcr_tags }}
build-args: |
BASE_PATH=${{ matrix.base_path }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
@ -123,5 +135,7 @@ jobs:
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ steps.compute.outputs.docker_tags }} tags: ${{ steps.compute.outputs.docker_tags }}
build-args: |
BASE_PATH=${{ matrix.base_path }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max

View file

@ -16,7 +16,7 @@ COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
COPY docker/middleware.ts ./src COPY docker/middleware.ts ./src
ARG BASE_PATH ARG BASE_PATH=""
ENV BASE_PATH=$BASE_PATH ENV BASE_PATH=$BASE_PATH
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
@ -30,10 +30,12 @@ WORKDIR /app
ARG PRISMA_VERSION="6.19.0" ARG PRISMA_VERSION="6.19.0"
ARG NODE_OPTIONS ARG NODE_OPTIONS
ARG BASE_PATH=""
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_OPTIONS=$NODE_OPTIONS ENV NODE_OPTIONS=$NODE_OPTIONS
ENV BASE_PATH=$BASE_PATH
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs