diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..dcdeb98 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI - Quality Assurance + +on: + pull_request: + +jobs: + qa: + name: ๐Ÿงช QA + runs-on: docker + container: + image: catthehacker/ubuntu:act-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Setup pnpm + uses: pnpm/action-setup@v3 + with: + version: 10 + - name: ๐Ÿ” Registry Auth + run: | + echo "@mintel:registry=https://${{ vars.REGISTRY_HOST || 'npm.infra.mintel.me' }}" > .npmrc + echo "//${{ vars.REGISTRY_HOST || 'npm.infra.mintel.me' }}/:_authToken=${{ secrets.REGISTRY_PASS }}" >> .npmrc + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: ๐Ÿงช Parallel Checks + run: | + pnpm lint & + pnpm build & + wait diff --git a/Dockerfile b/Dockerfile index 98c2dba..4164efe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,59 +1,60 @@ -# Start from the pre-built Nextjs Base image +# Stage 1: Builder FROM registry.infra.mintel.me/mintel/nextjs:latest AS builder - WORKDIR /app -# Ensure we are in a clean environment and remove any stale files from the base image -RUN rm -rf packages apps pnpm-workspace.yaml 2>/dev/null || true +# Clean the workspace in case the base image is dirty +RUN rm -rf ./* -# Build-time environment variables for Next.js +# Arguments for build-time configuration ARG NEXT_PUBLIC_BASE_URL -ARG UMAMI_API_ENDPOINT ARG NEXT_PUBLIC_TARGET ARG DIRECTUS_URL +ARG UMAMI_API_ENDPOINT +ARG NPM_TOKEN +# Environment variables for Next.js build ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL -ENV UMAMI_API_ENDPOINT=$UMAMI_API_ENDPOINT ENV NEXT_PUBLIC_TARGET=$NEXT_PUBLIC_TARGET ENV DIRECTUS_URL=$DIRECTUS_URL +ENV UMAMI_API_ENDPOINT=$UMAMI_API_ENDPOINT +ENV SKIP_RUNTIME_ENV_VALIDATION=true ENV CI=true -ENV SENTRY_SUPPRESS_TURBOPACK_WARNING=1 # Enable pnpm RUN corepack enable -# Set pnpm home and store directory for caching -ENV PNPM_HOME="/pnpm" -ENV PATH="$PNPM_HOME:$PATH" -RUN mkdir -p /pnpm/store - -# Copy workspace configuration and manifests for better caching -COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc ./ +# Copy workspace files for dependency installation +COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc* ./ COPY apps/web/package.json ./apps/web/package.json -# Install dependencies with cache mount and NPM_TOKEN secret +# Install dependencies with cache mount RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ --mount=type=secret,id=NPM_TOKEN \ - export NPM_TOKEN=$(cat /run/secrets/NPM_TOKEN) && \ - pnpm install --no-frozen-lockfile + export NPM_TOKEN=$(cat /run/secrets/NPM_TOKEN 2>/dev/null || echo $NPM_TOKEN) && \ + pnpm install --frozen-lockfile -# Copy source +# Copy source code COPY . . -# Build the app with cache mount -RUN --mount=type=cache,target=/app/apps/web/.next/cache \ - pnpm --filter @mintel/web build +# Build application (monorepo filter) +RUN pnpm --filter @mintel/web build -# Production image +# Stage 2: Runner FROM registry.infra.mintel.me/mintel/runtime:latest AS runner WORKDIR /app +ENV HOSTNAME="0.0.0.0" +ENV PORT=3000 +ENV NODE_ENV=production + # Copy standalone output and static files (Monorepo paths) COPY --from=builder --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static +COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/cache ./apps/web/.next/cache USER nextjs +# Start from the app directory to ensure references solve correctly WORKDIR /app/apps/web CMD ["node", "server.js"]