mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-05 05:05:17 +02:00
Fast. Easy. Fun. Deployment 🚀
This commit is contained in:
parent
78ab387055
commit
ef3f2aee10
3 changed files with 63 additions and 31 deletions
|
@ -1,5 +1,4 @@
|
|||
# Dockerfile
|
||||
|
||||
# Use the official Python slim image as the base image
|
||||
FROM python:3.10-slim
|
||||
|
||||
LABEL Developers="Sean Morley"
|
||||
|
@ -11,9 +10,9 @@ ENV PYTHONUNBUFFERED 1
|
|||
# Set the working directory
|
||||
WORKDIR /code
|
||||
|
||||
# Install system dependencies
|
||||
# Install system dependencies (Nginx included)
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y git postgresql-client gdal-bin libgdal-dev \
|
||||
&& apt-get install -y git postgresql-client gdal-bin libgdal-dev nginx \
|
||||
&& apt-get clean
|
||||
|
||||
# Install Python dependencies
|
||||
|
@ -24,10 +23,18 @@ RUN pip install -r requirements.txt
|
|||
# Copy the Django project code into the Docker image
|
||||
COPY ./server /code/
|
||||
|
||||
# Copy Nginx configuration
|
||||
COPY ./nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Collect static files
|
||||
RUN python3 manage.py collectstatic --noinput --verbosity 2
|
||||
|
||||
# Set the entrypoint script
|
||||
COPY ./entrypoint.sh /code/entrypoint.sh
|
||||
RUN chmod +x /code/entrypoint.sh
|
||||
ENTRYPOINT ["/code/entrypoint.sh"]
|
||||
|
||||
# Expose ports for NGINX and Gunicorn
|
||||
EXPOSE 80 8000
|
||||
|
||||
# Command to start Nginx and Gunicorn
|
||||
CMD ["bash", "-c", "service nginx start && /code/entrypoint.sh"]
|
||||
|
|
38
backend/nginx.conf
Normal file
38
backend/nginx.conf
Normal file
|
@ -0,0 +1,38 @@
|
|||
worker_processes 1;
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
upstream django {
|
||||
server server:8000; # Use the internal Docker networking
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80; # NGINX always listens on port 80 inside the container
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
proxy_pass http://server:8000; # Explicitly forward to Django service
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
location /static/ {
|
||||
alias /code/staticfiles/; # Serve static files directly
|
||||
}
|
||||
|
||||
location /media/ {
|
||||
alias /code/media/; # Serve media files directly
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue