From d53665d6da384ba367401130de7975861b26885a Mon Sep 17 00:00:00 2001 From: Unchained Date: Sun, 5 Apr 2026 11:24:01 +0200 Subject: [PATCH] build: pass env vars as build args to fix localhost:8000 error - Add ARG and ENV directives to Dockerfile for NEXT_PUBLIC_* vars - Pass build args in buildctl command with --opt build-arg - Fixes ERR_BLOCKED_BY_CLIENT on localhost:8000/graphql --- .gitea/workflows/build.yaml | 7 ++++++- Dockerfile | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 472e7a6..a5036d7 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -54,8 +54,13 @@ jobs: --frontend dockerfile.v0 \ --local context=/workspace \ --local dockerfile=/workspace \ + --opt build-arg:NEXT_PUBLIC_SALEOR_API_URL=https://api.manoonoils.com/graphql/ \ + --opt build-arg:NEXT_PUBLIC_SITE_URL=https://manoonoils.com \ + --opt build-arg:NEXT_PUBLIC_OPENPANEL_CLIENT_ID=fa61f8ae-0b5d-4187-a9b1-5a04b0025674 \ + --opt build-arg:NEXT_PUBLIC_RYBBIT_HOST=https://rybbit.nodecrew.me \ + --opt build-arg:NEXT_PUBLIC_RYBBIT_SITE_ID=1 \ --output type=image,name=ghcr.io/unchainedio/manoon-headless:latest,push=true - kubectl annotate kustomization -n flux-system manoonoils-storefront --overwrite reconcile.fluxcd.io/requestedAt="\1775369769" + kubectl annotate kustomization -n flux-system manoonoils-storefront --overwrite reconcile.fluxcd.io/requestedAt="$(date +%s)" echo "Done!" volumeMounts: - name: workspace diff --git a/Dockerfile b/Dockerfile index 60f1c74..4110870 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,25 @@ -# Multi-stage build for Next.js FROM node:20-slim AS builder WORKDIR /app -# Copy package files +ARG NEXT_PUBLIC_SALEOR_API_URL +ARG NEXT_PUBLIC_SITE_URL +ARG NEXT_PUBLIC_OPENPANEL_CLIENT_ID +ARG NEXT_PUBLIC_RYBBIT_HOST +ARG NEXT_PUBLIC_RYBBIT_SITE_ID + +ENV NEXT_PUBLIC_SALEOR_API_URL=${NEXT_PUBLIC_SALEOR_API_URL} +ENV NEXT_PUBLIC_SITE_URL=${NEXT_PUBLIC_SITE_URL} +ENV NEXT_PUBLIC_OPENPANEL_CLIENT_ID=${NEXT_PUBLIC_OPENPANEL_CLIENT_ID} +ENV NEXT_PUBLIC_RYBBIT_HOST=${NEXT_PUBLIC_RYBBIT_HOST} +ENV NEXT_PUBLIC_RYBBIT_SITE_ID=${NEXT_PUBLIC_RYBBIT_SITE_ID} + COPY package*.json ./ RUN npm install --prefer-offline --no-audit -# Copy source and build COPY . . RUN npm run build -# Production stage FROM node:20-slim AS runner WORKDIR /app @@ -20,7 +28,6 @@ ENV NODE_ENV=production ENV PORT=3000 ENV HOSTNAME=0.0.0.0 -# Copy necessary files from builder COPY --from=builder /app/public ./public COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static