-
Notifications
You must be signed in to change notification settings - Fork 3
Add cloudrun dockerfile #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Docker support and Cloud Run compatibility for the backend, enhances local development workflows, and updates the frontend service worker with new asset revisions.
- Dockerizes the backend with a new Dockerfile and
.dockerignore - Updates TypeScript and npm scripts to build, run, and deploy on Cloud Run
- Enables CORS and environment-based port configuration in the backend
- Adds detailed README for local development, Docker, and Cloud Run deployment
- Refreshes asset hashes in the frontend service worker
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkgs/frontend/public/sw.js | Swapped loader variable names and updated static asset revisions |
| pkgs/backend/tsconfig.json | Set "outDir": "dist" and broadened "include" to src/**/* |
| pkgs/backend/src/index.ts | Added CORS middleware and made port configurable via PORT |
| pkgs/backend/package.json | Added build, start, docker:build, and docker:run scripts |
| pkgs/backend/README.md | New documentation for local, Docker, and Cloud Run workflows |
| pkgs/backend/Dockerfile | Dockerfile for building and running the backend |
| pkgs/backend/.dockerignore | Files to exclude from Docker build context |
Comments suppressed due to low confidence (1)
pkgs/backend/src/index.ts:21
- [nitpick] This log runs before the server actually listens; consider removing or moving it after
serve(...)to avoid confusion.
console.log("Server is running");
| app.use( | ||
| cors({ | ||
| origin: ["*"], |
Copilot
AI
May 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a wildcard origin (*) with credentials: true is disallowed by browsers; either specify explicit origins or disable credentials.
| app.use( | |
| cors({ | |
| origin: ["*"], | |
| const allowedOrigins = process.env.CORS_ALLOWED_ORIGINS | |
| ? process.env.CORS_ALLOWED_ORIGINS.split(",") | |
| : []; | |
| app.use( | |
| cors({ | |
| origin: allowedOrigins, |
| "dev": "tsx ./src/index.ts" | ||
| "dev": "tsx ./src/index.ts", | ||
| "build": "tsc", | ||
| "start": "node --experimental-modules --es-module-specifier-resolution=node ./dist/index.js", |
Copilot
AI
May 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Node.js 20 supports ES modules natively; you can simplify the start script to node ./dist/index.js and remove experimental flags.
| "start": "node --experimental-modules --es-module-specifier-resolution=node ./dist/index.js", | |
| "start": "node ./dist/index.js", |
| docker build -t backend-api . | ||
|
|
||
| # ローカルでコンテナを実行 | ||
| docker run -p 8080:8080 --env-file .env backend-api |
Copilot
AI
May 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README maps port 8080, but the app and Dockerfile use port 4021; update one to keep them consistent.
| docker run -p 8080:8080 --env-file .env backend-api | |
| docker run -p 4021:4021 --env-file .env backend-api |
| RUN pnpm install | ||
|
|
||
| # Install @types/node for TypeScript compilation | ||
| RUN pnpm add -D @types/node |
Copilot
AI
May 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Installing @types/node inside the Dockerfile alters lockfiles; it's better to declare dev dependencies in package.json for consistency.
This pull request introduces Docker support for the backend, updates the backend to be compatible with Google Cloud Run, and improves the development workflow. It also includes minor updates to the frontend service worker. Below is a breakdown of the most important changes:
Backend Dockerization and Cloud Run Compatibility
.dockerignorefile to exclude unnecessary files likenode_modules,.env, and.gitfrom the Docker build context (pkgs/backend/.dockerignore).Dockerfilefor building and running the backend using Node.js 20, including dependency installation and application build steps (pkgs/backend/Dockerfile).PORTenvironment variable for compatibility with Google Cloud Run (pkgs/backend/src/index.ts).Documentation Enhancements
README.mdfile with instructions for local development, Docker usage, and deployment to Google Cloud Run (pkgs/backend/README.md).Development Workflow Improvements
pkgs/backend/package.json).pkgs/backend/src/index.ts).tsconfig.jsonto specify the output directory asdistand include all files in thesrcfolder (pkgs/backend/tsconfig.json).Frontend Updates
pkgs/frontend/public/sw.js).