feat: docker setup
This commit is contained in:
@@ -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"]
|
|
||||||
@@ -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;"]
|
|
||||||
@@ -1,67 +1,40 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Frontend
|
app:
|
||||||
frontend:
|
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./Dockerfile.frontend
|
dockerfile: Dockerfile
|
||||||
|
env_file: .env
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000" # Map host port 3000 to container port 3000
|
- "5173:80"
|
||||||
|
- "8080:8080"
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- db
|
||||||
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
|
|
||||||
- minio
|
- minio
|
||||||
networks:
|
|
||||||
- app-network
|
|
||||||
|
|
||||||
# Postgres Database
|
db:
|
||||||
postgres:
|
image: postgres:13
|
||||||
image: postgres:15
|
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: mydb
|
POSTGRES_DB: ${DB_NAME}
|
||||||
POSTGRES_USER: myuser
|
POSTGRES_USER: ${DB_USER}
|
||||||
POSTGRES_PASSWORD: mypassword
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
networks:
|
|
||||||
- app-network
|
|
||||||
|
|
||||||
# MinIO for Storage
|
|
||||||
minio:
|
minio:
|
||||||
image: minio/minio
|
image: minio/minio
|
||||||
|
environment:
|
||||||
|
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY}
|
||||||
|
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY}
|
||||||
command: server /data
|
command: server /data
|
||||||
ports:
|
ports:
|
||||||
- "9000:9000"
|
- "9000:9000"
|
||||||
environment:
|
|
||||||
MINIO_ROOT_USER: minioadmin
|
|
||||||
MINIO_ROOT_PASSWORD: minioadmin123
|
|
||||||
volumes:
|
volumes:
|
||||||
- minio_data:/data
|
- minio_data:/data
|
||||||
networks:
|
|
||||||
- app-network
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
minio_data:
|
minio_data:
|
||||||
|
|
||||||
networks:
|
|
||||||
app-network:
|
|
||||||
driver: bridge
|
|
||||||
Reference in New Issue
Block a user