Skip to content
Open

Temp #56

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# backend/Dockerfile

# 1. Use a lightweight Node image
FROM node:18-alpine

# 2. Install build tools
RUN apk add --no-cache python3 make g++

# 3. Set workdir
WORKDIR /app

# 4. Copy dependency manifests & install
COPY package*.json ./
RUN npm install

# 5. Copy source code
COPY . .

# 6. Set environment variables
ENV NODE_ENV=development
ENV PORT=4000

# 7. Expose the port your API listens on
EXPOSE 4000

# 8. Start the app
CMD ["npm", "run", "dev"]
2 changes: 1 addition & 1 deletion backend/dbServer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { Pool } = require("pg");
// Create a connection to the database.
const dbServer = new Pool({
host: "localhost",
host: "postgres_db",
port: 5432,
database: "postgres",
user: "postgres",
Expand Down
17 changes: 16 additions & 1 deletion backend/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@

services:
backend:
build: .
ports:
- "4000:4000"
depends_on:
postgres_db:
condition: service_healthy
environment:
- NODE_ENV=development
- PORT=4000

postgres_db:
image: postgres:16-alpine
volumes:
Expand All @@ -10,6 +20,11 @@ services:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: "028469"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5

volumes:
postgres_db_data:
Expand Down
Loading