From 26d22a16024eb984d146cc82f15c36ae3e3407f8 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 29 Oct 2024 23:42:58 +0530 Subject: [PATCH] feat: docker setup --- Dockerfile.backend | 23 ----------------- Dockerfile.frontend | 29 --------------------- docker-compose.yml | 63 +++++++++++++-------------------------------- 3 files changed, 18 insertions(+), 97 deletions(-) delete mode 100644 Dockerfile.backend delete mode 100644 Dockerfile.frontend diff --git a/Dockerfile.backend b/Dockerfile.backend deleted file mode 100644 index ec5ca679..00000000 --- a/Dockerfile.backend +++ /dev/null @@ -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"] diff --git a/Dockerfile.frontend b/Dockerfile.frontend deleted file mode 100644 index 9fd668ad..00000000 --- a/Dockerfile.frontend +++ /dev/null @@ -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;"] diff --git a/docker-compose.yml b/docker-compose.yml index 1019d486..2f4b07b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 + minio_data: \ No newline at end of file