docker
This commit is contained in:
parent
4f22557204
commit
854a0c6177
27
Dockerfile
Normal file
27
Dockerfile
Normal file
@ -0,0 +1,27 @@
|
||||
# Use an official Python runtime as a base image
|
||||
FROM python:3.13.5-slim-bookworm
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
# Set work directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y build-essential libpq-dev && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Python dependencies
|
||||
COPY requirements.txt /app/
|
||||
RUN pip install --upgrade pip && pip install -r requirements.txt
|
||||
|
||||
# Copy project
|
||||
COPY . /app/
|
||||
|
||||
# Run migrations & collect static in production (optional)
|
||||
# CMD ["python", "manage.py", "migrate"] && ["python", "manage.py", "collectstatic", "--noinput"]
|
||||
|
||||
# Command to run the server
|
||||
# CMD ["gunicorn", "freekake_api.wsgi:application", "--bind", "0.0.0.0:8000"]
|
||||
26
docker-compose.yml
Normal file
26
docker-compose.yml
Normal file
@ -0,0 +1,26 @@
|
||||
services:
|
||||
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
# command: gunicorn freekake_api.wsgi:application --bind 0.0.0.0:8000
|
||||
command: sh -c "gunicorn freekake_api.wsgi:application --bind 0.0.0.0:8000"
|
||||
volumes:
|
||||
- .:/app
|
||||
- static_volume:/app/static
|
||||
expose:
|
||||
- "8000"
|
||||
|
||||
nginx:
|
||||
image: nginx:1.28-bookworm
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
- static_volume:/static
|
||||
depends_on:
|
||||
- web
|
||||
|
||||
volumes:
|
||||
static_volume:
|
||||
30
nginx.conf
Normal file
30
nginx.conf
Normal file
@ -0,0 +1,30 @@
|
||||
# nginx.conf
|
||||
client_max_body_size 8M;
|
||||
|
||||
upstream django_app {
|
||||
server freekake_api:8000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
client_max_body_size 50M;
|
||||
|
||||
location / {
|
||||
proxy_pass http://web:8000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
# OPTIONAL: serve static files if needed
|
||||
location /static/ {
|
||||
alias /static/;
|
||||
}
|
||||
|
||||
location /media/ {
|
||||
alias /media/;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user