diff --git a/Dockerfile b/Dockerfile index 09310fc..8468b42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,11 @@ RUN npm ci FROM node:20-bookworm-slim AS builder WORKDIR /app +ARG NEXT_PUBLIC_SUPABASE_URL +ARG NEXT_PUBLIC_SUPABASE_ANON_KEY +ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL +ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY + COPY --from=deps /app/node_modules ./node_modules COPY . . RUN npm run build diff --git a/Jenkinsfile b/Jenkinsfile index a308a64..347b7a9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,7 @@ pipeline { // Build + deploy stages require Docker CLI/daemon access on the Jenkins node. // Ensure this label maps to an agent with Docker installed and usable. + //update agent any environment { @@ -62,13 +63,23 @@ pipeline { stage('Build application') { steps { - sh 'npm run build' + withCredentials([ + string(credentialsId: 'supabase-public-url', variable: 'NEXT_PUBLIC_SUPABASE_URL'), + string(credentialsId: 'supabase-public-anon-key', variable: 'NEXT_PUBLIC_SUPABASE_ANON_KEY') + ]) { + sh 'npm run build' + } } } stage('Build Docker image') { steps { - sh 'docker build -t ${IMAGE_LATEST} -t ${IMAGE_BUILD} .' + withCredentials([ + string(credentialsId: 'supabase-public-url', variable: 'NEXT_PUBLIC_SUPABASE_URL'), + string(credentialsId: 'supabase-public-anon-key', variable: 'NEXT_PUBLIC_SUPABASE_ANON_KEY') + ]) { + sh 'docker build --build-arg NEXT_PUBLIC_SUPABASE_URL="$NEXT_PUBLIC_SUPABASE_URL" --build-arg NEXT_PUBLIC_SUPABASE_ANON_KEY="$NEXT_PUBLIC_SUPABASE_ANON_KEY" -t ${IMAGE_LATEST} -t ${IMAGE_BUILD} .' + } } }