From 714c4dd7e08f94374cf2333486517333e3689686 Mon Sep 17 00:00:00 2001 From: Himanshu Kumar Date: Thu, 4 Jul 2024 02:12:51 +0530 Subject: [PATCH] add docker-compose file --- .dockerignore | 0 docker-compose.yml | 34 ++++++++++++++++++++++++++++++++++ dockerfile | 20 ++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .dockerignore create mode 100644 docker-compose.yml create mode 100644 dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8eb3acc --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..d8a582d --- /dev/null +++ b/dockerfile @@ -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"]