Skip to content

Commit a96d662

Browse files
Fix Cloud Run deployment: correct Angular project name and improve Docker setup
- Fix Dockerfile to build 'web' project instead of non-existent 'blog-ssg' - Add comprehensive .dockerignore for optimized build context - Improve GitHub Action workflow with better error reporting and simplified setup - Remove redundant build steps from CI (handled by Dockerfile) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 855de83 commit a96d662

File tree

3 files changed

+96
-31
lines changed

3 files changed

+96
-31
lines changed

.dockerignore

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Dependencies
2+
node_modules
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Build outputs
8+
dist
9+
.angular
10+
.nx
11+
tmp
12+
out-tsc
13+
14+
# IDE
15+
.vscode
16+
.idea
17+
*.swp
18+
*.swo
19+
20+
# OS
21+
.DS_Store
22+
Thumbs.db
23+
24+
# Tests
25+
coverage
26+
*.tgz
27+
*.tar.gz
28+
29+
# Environment files
30+
.env
31+
.env.local
32+
.env.development.local
33+
.env.test.local
34+
.env.production.local
35+
36+
# Logs
37+
logs
38+
*.log
39+
40+
# Git
41+
.git
42+
.gitignore
43+
README.md
44+
45+
# CI/CD
46+
.github
47+
48+
# Docker
49+
Dockerfile*
50+
.dockerignore
51+
52+
# Documentation
53+
docs
54+
*.md
55+
56+
# Linting and formatting
57+
.eslintrc*
58+
.prettierrc*
59+
.editorconfig
60+
61+
# Testing
62+
e2e
63+
*.spec.ts
64+
*.e2e-spec.ts
65+
karma.conf.js
66+
protractor.conf.js
67+
68+
# Supabase local development
69+
supabase/.temp
70+
supabase/functions/node_modules
71+
supabase/logs
72+
supabase/.branches
73+
74+
# Cache directories
75+
.cache
76+
.parcel-cache

.github/workflows/google-cloudrun-docker.yml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,26 @@ jobs:
3030
deploy:
3131
runs-on: ubuntu-latest
3232
needs: test
33+
timeout-minutes: 30
3334
steps:
3435
- uses: actions/checkout@v4
3536

36-
- uses: actions/setup-node@v4
37-
with:
38-
node-version: '20'
39-
cache: npm
40-
41-
- run: npm ci
42-
43-
- run: npm run build -- --configuration production
44-
4537
- uses: google-github-actions/auth@v2
4638
with:
4739
credentials_json: '${{ secrets.GCP_SA_KEY }}'
4840

49-
- name: Install Google Cloud SDK
50-
run: |
51-
echo "Installing Google Cloud SDK"
52-
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
53-
sudo apt-get install -y apt-transport-https ca-certificates
54-
sudo apt-get update && sudo apt-get install -y google-cloud-sdk
55-
gcloud version
41+
- name: Set up Cloud SDK
42+
uses: google-github-actions/setup-gcloud@v1
43+
44+
- name: Configure Docker for GCR
45+
run: gcloud auth configure-docker
5646

57-
- name: Deploy to Cloud Run using Buildpacks
47+
- name: Build and Deploy to Cloud Run
5848
uses: google-github-actions/deploy-cloudrun@v2
5949
with:
6050
service: angular-blog
6151
region: europe-west4
6252
source: .
53+
flags: '--verbosity=debug --timeout=1200'
54+
env_vars: |
55+
NODE_ENV=production

Dockerfile

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
1-
# Dockerfile for Angular SSR (blog-ssg) on Cloud Run
1+
# Dockerfile for Angular SSR (web project) on Cloud Run
22
# Multi-stage: build Angular bundles, then run the SSR server.
33
# Cloud Run expects the app to listen on PORT env var (default 8080).
44

55
# ---------- Build stage ----------
66
FROM node:20-bullseye AS builder
77
WORKDIR /workspace
88

9-
# Install deps with pnpm (recommended for speed). Fallback to npm if needed.
10-
COPY package.json* pnpm-lock.yaml* package-lock.json* .npmrc* ./
11-
RUN corepack enable && corepack prepare pnpm@latest --activate || true
12-
RUN if [ -f pnpm-lock.yaml ]; then pnpm install --frozen-lockfile; elif [ -f package-lock.json ]; then npm ci; else pnpm install; fi
9+
# Install deps with npm (project uses npm based on package-lock.json)
10+
COPY package.json package-lock.json ./
11+
RUN npm ci
1312

1413
COPY . .
1514

16-
# Build browser, server (SSR). Prerender can be done in CI before building the image.
17-
RUN npx ng build blog-ssg --configuration=production
18-
RUN npx ng run blog-ssg:server:production
19-
# Optional:
20-
# RUN npx ng run blog-ssg:prerender --routes=apps/blog-ssg/routes.txt
15+
# Build the web project with SSR support
16+
RUN npx ng build web --configuration=production
2117

2218
# ---------- Runtime stage ----------
2319
FROM node:20-bullseye-slim AS runtime
2420
ENV NODE_ENV=production
2521
WORKDIR /srv
2622

27-
# Copy built artifacts
28-
COPY --from=builder /workspace/dist/apps/blog-ssg /srv/dist/apps/blog-ssg
23+
# Copy built artifacts from the correct path
24+
COPY --from=builder /workspace/dist/web /srv/dist/web
2925

3026
# Cloud Run provides PORT env. Angular SSR server must bind to this port.
3127
ENV PORT=8080
3228
EXPOSE 8080
3329

34-
# Adjust path to the server entry if your project differs.
35-
CMD ["node", "dist/apps/blog-ssg/server/server.mjs"]
30+
# Run the SSR server
31+
CMD ["node", "dist/web/server/server.mjs"]

0 commit comments

Comments
 (0)