feat: docker setup

This commit is contained in:
karishmas6
2024-10-29 23:42:58 +05:30
parent e88fabe864
commit 26d22a1602
3 changed files with 18 additions and 97 deletions

View File

@@ -1,23 +0,0 @@
# Use node image
FROM node:18-alpine
# Set working directory in the container to /app
WORKDIR /app
# Copy only the package.json and package-lock.json first for caching
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install --production
# Copy the entire project (core and backend code)
COPY . .
# Set the working directory to the backend folder
WORKDIR /app/server
# Expose the port the backend listens on
EXPOSE 8080
# Start the backend server
CMD ["npm", "run", "start:server"]

View File

@@ -1,29 +0,0 @@
# Use node image for the build stage
FROM node:18-alpine AS build
# Set working directory in the container to /app
WORKDIR /app
# Copy only the package.json and package-lock.json first for caching
COPY package.json package-lock.json ./
# Install dependencies (legacy peer deps is needed for react highlight, we get rid of it soon)
RUN npm install --legacy-peer-deps
# Copy the entire project (including frontend code)
COPY . .
# Build the frontend
RUN npm run build
# Use NGINX for serving the built frontend in production
FROM nginx:stable-alpine
# Copy the build output from the previous stage
COPY --from=build /app/build /usr/share/nginx/html
# Expose the frontend port
EXPOSE 3000
# Start NGINX server
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -1,67 +1,40 @@
version: '3.8'
services:
# Frontend
frontend:
app:
build:
context: .
dockerfile: ./Dockerfile.frontend
dockerfile: Dockerfile
env_file: .env
ports:
- "3000:3000" # Map host port 3000 to container port 3000
- "5173:80"
- "8080:8080"
depends_on:
- backend
networks:
- app-network
# Backend
backend:
build:
context: .
dockerfile: ./Dockerfile.backend
ports:
- "8080:8080" # Map host port 8080 to container port 8080
environment:
POSTGRES_HOST: postgres
POSTGRES_DB: mydb
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
MINIO_ENDPOINT: minio
MINIO_PORT: 9000
depends_on:
- postgres
- db
- minio
networks:
- app-network
# Postgres Database
postgres:
image: postgres:15
db:
image: postgres:13
environment:
POSTGRES_DB: mydb
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- app-network
# MinIO for Storage
minio:
image: minio/minio
environment:
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY}
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY}
command: server /data
ports:
- "9000:9000"
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin123
volumes:
- minio_data:/data
networks:
- app-network
volumes:
postgres_data:
minio_data:
networks:
app-network:
driver: bridge