File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 3939 - name : Build and Push Docker image
4040 run : |
4141 IMAGE="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
42- docker build -t $IMAGE .
42+ docker build \
43+ --build-arg VITE_RECAPTCHA_SITE_KEY=${{ secrets.VITE_RECAPTCHA_SITE_KEY }} \
44+ -t $IMAGE .
4345 docker push $IMAGE
4446
4547 - name : Deploy to Cloud Run
Original file line number Diff line number Diff line change 1-
2-
31# Stage 1: Build frontend
42FROM node:20-alpine AS build-frontend
53WORKDIR /app/frontend
4+
5+ # Accept build-time environment variable
6+ ARG VITE_RECAPTCHA_SITE_KEY
7+ ENV VITE_RECAPTCHA_SITE_KEY=$VITE_RECAPTCHA_SITE_KEY
8+
69COPY frontend/package*.json ./
710RUN npm install
11+
812COPY frontend ./
913COPY frontend/.env.production .env.production
10- RUN npm run build
1114
12- # Accept build-time environment variable
13- ARG VITE_RECAPTCHA_SITE_KEY
14- ENV VITE_RECAPTCHA_SITE_KEY=$VITE_RECAPTCHA_SITE_KEY
15+ # Ensure Vite sees the environment variable
16+ RUN echo "VITE_RECAPTCHA_SITE_KEY=$VITE_RECAPTCHA_SITE_KEY" >> .env.production
17+
18+ RUN npm run build
1519
1620# Stage 2: Build backend
1721FROM node:20-alpine
@@ -22,10 +26,9 @@ COPY backend/package*.json ./backend/
2226RUN cd backend && npm install --omit=dev
2327COPY backend ./backend
2428
25- # Copy built frontend into backend’s public/dist folder (or wherever it expects)
29+ # Copy built frontend into backend’s public/dist folder
2630COPY --from=build-frontend /app/frontend/dist ./frontend/dist
2731
28- # Set working dir to backend and start the app
2932WORKDIR /app/backend
3033EXPOSE 8080
31- CMD ["node" , "server.js" ]
34+ CMD ["node" , "server.js" ]
You can’t perform that action at this time.
0 commit comments