-
Notifications
You must be signed in to change notification settings - Fork 0
Add Docker configuration for local development #80
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,7 @@ | ||||||||
| FROM node:20-alpine | ||||||||
| WORKDIR /usr/src/app | ||||||||
| COPY package*.json ./ | ||||||||
| RUN npm ci --omit=dev | ||||||||
| COPY . . | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||
| EXPOSE 3000 | ||||||||
| CMD ["node","server.js"] | ||||||||
|
Comment on lines
+1
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's generally recommended to run containers as a non-root user for security reasons. While less critical for local development, adopting this practice early is beneficial.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. security (missing-user): By not specifying a USER, a program in the container may run as 'root'. This is a security hazard. If an attacker can control a process running as root, they may have control over the container. Ensure that the last USER in a Dockerfile is a USER other than 'root'.
Suggested change
Source: opengrep |
||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -156,6 +156,17 @@ PORT=3000 | |||||||||||||||||
| NODE_ENV=development | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Docker Usage | ||||||||||||||||||
|
|
||||||||||||||||||
| To run Wirebase locally with Docker: | ||||||||||||||||||
|
|
||||||||||||||||||
| 1. Create a `.env` file using the environment variables shown above. | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||||||||||||
| 2. Build and start the containers: | ||||||||||||||||||
| ```bash | ||||||||||||||||||
| docker-compose up --build | ||||||||||||||||||
| ``` | ||||||||||||||||||
| The app will be available at `http://localhost:3000`. | ||||||||||||||||||
|
|
||||||||||||||||||
| ## License | ||||||||||||||||||
|
Comment on lines
+168
to
170
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider adding instructions for stopping the Docker containers. Including a note about using
Suggested change
License |
||||||||||||||||||
|
|
||||||||||||||||||
| This project is available under the MIT License. See the [LICENSE](LICENSE) file for details. | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| version: '3.8' | ||
| services: | ||
| app: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Add a restart policy for the app service Consider adding a |
||
| build: . | ||
| ports: | ||
| - "3000:3000" | ||
| environment: | ||
| - PORT=3000 | ||
| - DATABASE_URL=postgres://postgres:postgres@db:5432/wirebase | ||
| - SUPABASE_URL=${SUPABASE_URL} | ||
| - SUPABASE_KEY=${SUPABASE_KEY} | ||
| - SUPABASE_SERVICE_KEY=${SUPABASE_SERVICE_KEY} | ||
| - SESSION_SECRET=${SESSION_SECRET} | ||
|
Comment on lines
+7
to
+13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The application's database connection logic in To use the local Postgres service ( |
||
| depends_on: | ||
| - db | ||
| db: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Add a healthcheck for the database service This will help prevent startup connection errors by ensuring the app only starts when the database is ready. |
||
| image: postgres:15-alpine | ||
| environment: | ||
| POSTGRES_USER: postgres | ||
| POSTGRES_PASSWORD: postgres | ||
| POSTGRES_DB: wirebase | ||
| volumes: | ||
| - db-data:/var/lib/postgresql/data | ||
| volumes: | ||
| db-data: | ||
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.
suggestion (performance): Add a .dockerignore to reduce build context
Exclude node_modules, .git, and logs in your .dockerignore to speed up builds and reduce image size.
Suggested implementation: