docker compose file and dockerfile

This commit is contained in:
Parsa Nazer
2024-12-05 14:32:06 +03:30
parent 5c136874e1
commit fe91fb6b1c
3 changed files with 66 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
COPY . /app/
CMD ["sh", "-c", "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]
+39
View File
@@ -0,0 +1,39 @@
services:
frontend:
build:
context: ./frontend
ports:
- "80:3000"
depends_on:
- django
django:
build:
context: ./backend
ports:
- "8000:8000"
depends_on:
- db
volumes:
- ./backend:/app
- media_data:/app/media
command: ["sh", "-c", "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]
db:
image: postgres:16
environment:
POSTGRES_DB: shop_db
POSTGRES_USER: byeto
POSTGRES_PASSWORD: vuhbyq-cypMu0-sirbon
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5434:5432"
volumes:
postgres_data:
media_data:
+13
View File
@@ -0,0 +1,13 @@
FROM node:20-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:20-alpine as production-stage
WORKDIR /app
COPY --from=build-stage /app /app
EXPOSE 3000
ENV NODE_ENV=production
CMD ["npm", "run", "start"]