Repository navigation
Fix nodejs-react-postgres: managed Postgres, no username in compose #769
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ae756fd
Fix nodejs-react-postgres: managed Postgres, single-origin app
defangdevs e42e88d
nodejs-react-postgres: read POSTGRES_PASSWORD as config, not compose …
defangdevs 9a042c3
nodejs-react-postgres: SSL for managed Postgres, db reservations, ign…
defangdevs 12e34b6
nodejs-react-postgres: retry DB init until the database is reachable
defangdevs f76bab8
nodejs-react-postgres: drop published port on db, as in the rails sample
defangdevs 7beb07d
nodejs-react-postgres: use Debian base so the short service name "db"…
defangdevs c6fe27e
nodejs-react-postgres: back to the Alpine runtime image
defangdevs 1837b59
loadtest: skip non-HTTP service endpoints
defangdevs e705883
nodejs-react-postgres: pass the db host as a compose env var
defangdevs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| **/node_modules | ||
| **/build | ||
| **/.env | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| **/.env.* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Build the React client | ||
| FROM node:20-bookworm-slim AS client | ||
| WORKDIR /client | ||
| COPY client/package*.json ./ | ||
| RUN npm install | ||
| COPY client/ ./ | ||
| # Empty API URL: the client calls the server on its own origin | ||
| ENV REACT_APP_API_URL="" | ||
| RUN npm run build | ||
|
|
||
| # Run the API server, which also serves the built client | ||
| FROM node:20-alpine | ||
| WORKDIR /app | ||
| COPY server/package*.json ./ | ||
| RUN npm install --omit=dev | ||
| COPY server/ ./ | ||
| COPY --from=client /client/build ./public | ||
| EXPOSE 3010 | ||
| CMD ["node", "index.js"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,45 @@ | ||
| name: nodejs-react-postgres | ||
| services: | ||
| todo_list: | ||
| app: | ||
| restart: unless-stopped | ||
| build: | ||
| context: ./client | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| args: | ||
| - REACT_APP_API_URL=https://<YOUR_USERNAME>-server--3010.prod1.defang.dev | ||
| ports: | ||
| - mode: ingress | ||
| target: 3000 | ||
| published: 3000 | ||
| target: 3010 | ||
| published: 3010 | ||
| environment: | ||
| POSTGRES_HOST: db | ||
| POSTGRES_PASSWORD: | ||
| healthcheck: | ||
| test: ["CMD", "wget", "-qO-", "http://localhost:3010/todos"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
| deploy: | ||
| resources: | ||
| reservations: | ||
| memory: 1g | ||
| cpus: "0.5" | ||
| memory: 512M | ||
| depends_on: | ||
| - server | ||
| server: | ||
| - db | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| db: | ||
| image: postgres:15 | ||
|
defangdevs marked this conversation as resolved.
Resolved
|
||
| x-defang-postgres: true | ||
| restart: unless-stopped | ||
| build: | ||
| context: ./server | ||
| dockerfile: Dockerfile | ||
| ports: | ||
| - target: 3010 | ||
| mode: ingress | ||
| published: 3010 | ||
| environment: | ||
| - DATABASE_URL | ||
| - POSTGRES_PASSWORD | ||
| deploy: | ||
| resources: | ||
| reservations: | ||
| cpus: "0.5" | ||
| memory: 512M | ||
| ports: | ||
| - mode: host | ||
| target: 5432 | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "pg_isready -U postgres"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.