diff --git a/Dockerfile b/Dockerfile index e7c2c3d..d2aade3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,12 @@ RUN npm ci # Copy all files COPY . . +# Copy .env file if it exists +COPY .env* ./ + +# Print environment for debugging (will be removed in production) +RUN if [ -f .env ]; then cat .env; fi + # Build the app RUN npm run build diff --git a/cloudbuild.yaml b/cloudbuild.yaml index cfa1221..23c1aa8 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,5 +1,16 @@ steps: - # Build the container image + # Access secrets and create a .env file for the build + - name: 'gcr.io/cloud-builders/gcloud' + entrypoint: 'bash' + args: + - '-c' + - | + gcloud secrets versions access latest --secret=GOOGLE_CLIENT_ID > /workspace/google_client_id.txt + echo "VITE_GOOGLE_CLIENT_ID=$(cat /workspace/google_client_id.txt)" > /workspace/.env + echo "VITE_API_URL=${_VITE_API_URL}" >> /workspace/.env + cat /workspace/.env + + # Build the container image with access to the .env file - name: 'gcr.io/cloud-builders/docker' args: ['build', '-t', '${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/${_IMAGE_NAME}', '.'] env: diff --git a/index.html b/index.html index bb33833..37c4498 100644 --- a/index.html +++ b/index.html @@ -4,9 +4,11 @@