Merge branch 'master' into prod
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
FROM python:3.13-alpine
|
||||
|
||||
# install nginx and runtime deps, plus a build-deps group for uv sync
|
||||
RUN apk add --no-cache nginx libffi openssl
|
||||
RUN apk add --no-cache --virtual .build-deps build-base libffi-dev openssl-dev python3-dev
|
||||
|
||||
# grab uv CLI
|
||||
RUN mkdir -p /usr/local/bin \
|
||||
&& wget -qO /usr/local/bin/uv https://ghcr.io/astral-sh/uv:latest/uv \
|
||||
&& wget -qO /usr/local/bin/uvx https://ghcr.io/astral-sh/uv:latest/uvx \
|
||||
&& chmod +x /usr/local/bin/uv /usr/local/bin/uvx
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# install your Python deps
|
||||
COPY uv.lock pyproject.toml ./
|
||||
RUN uv sync --frozen --no-cache \
|
||||
# drop build tools once deps are in place
|
||||
&& apk del .build-deps
|
||||
|
||||
# copy in the rest of your Django project
|
||||
COPY . .
|
||||
|
||||
# collectstatic
|
||||
RUN uv run python manage.py collectstatic --noinput
|
||||
|
||||
# copy nginx config
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# start.sh should launch both nginx and uvicorn
|
||||
COPY start.sh /start.sh
|
||||
RUN chmod +x /start.sh
|
||||
|
||||
CMD ["/start.sh"]
|
||||
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
# user & worker settings
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
# basic settings
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
# upstream for Uvicorn
|
||||
upstream app {
|
||||
server 127.0.0.1:8000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# serve static files
|
||||
location /static/ {
|
||||
alias /app/static/;
|
||||
expires 30d;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
# proxy everything else to Uvicorn
|
||||
location / {
|
||||
proxy_pass http://app;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user