Skip to content
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

add docker-compose file #88

Closed
wants to merge 1 commit into from
Closed
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
Empty file added .dockerignore
Empty file.
34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3.8'

services:
# This service runs a PostgreSQL database
db:
image: postgres:13
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: example
POSTGRES_DB: mydatabase
volumes:
- db-data: /var/lib/postgresql/data

# This service runs the Node.js backend application
backend:
build: .
environment:
NODE_ENV: development
PORT: 3000
POSTGRES_USER: postgres
POSTGRES_PASSWORD: example
POSTGRES_DB: mydatabase
POSTGRES_HOST: db
POSTGRES_PORT: 5432
ports:
- '3000:3000'
depends_on:
- db

# Define named volumes to persist data
volumes:
db-data:

#to run the docker-compose.yml write the command docker-compose up --build
20 changes: 20 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Node.js 18 image as the base image
FROM node:18

# Create and change to the app directory
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install the dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Expose port (change the port number if needed)
EXPOSE 3000

# Command to run your application
CMD ["npm", "run", "dev"]