-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated deploypreview workflow and docker files accordingly
- Loading branch information
1 parent
60fe22e
commit 8b99e73
Showing
6 changed files
with
108 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
version: "3.8" | ||
services: | ||
web: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
env_file: .env | ||
expose: | ||
- "8000" | ||
depends_on: | ||
- db | ||
volumes: | ||
- ./staticfiles:/app/staticfiles | ||
|
||
nginx: | ||
build: | ||
context: ./nginx | ||
dockerfile: Dockerfile | ||
ports: | ||
- "80:80" | ||
depends_on: | ||
- web | ||
volumes: | ||
# Mount the staticfiles into Nginx container | ||
- ./staticfiles:/usr/share/nginx/html/static | ||
|
||
db: | ||
image: postgres:15 | ||
environment: | ||
POSTGRES_USER: your_user | ||
POSTGRES_PASSWORD: your_password | ||
POSTGRES_DB: your_db | ||
volumes: | ||
- db_data:/var/lib/postgresql/data | ||
|
||
volumes: | ||
db_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
#!/bin/sh | ||
|
||
# Exit immediately if a command exits with a non-zero status | ||
# Exit on error | ||
set -e | ||
|
||
# Run Django migrations | ||
echo "Running migrations..." | ||
python manage.py migrate --noinput | ||
|
||
# Collect static files (ensure the static files directory exists) | ||
echo "Collecting static files..." | ||
python manage.py collectstatic --noinput | ||
|
||
# Start Gunicorn server to serve the Django application | ||
echo "Starting Gunicorn server..." | ||
echo "Starting Gunicorn..." | ||
exec gunicorn core.wsgi:application --bind 0.0.0.0:8000 --timeout 600 --workers 3 --log-level info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM nginx:alpine | ||
|
||
# Remove default configuration | ||
RUN rm /etc/nginx/conf.d/default.conf | ||
|
||
# Copy your custom nginx configuration | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Expose port 80 for Nginx | ||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
user nginx; | ||
worker_processes auto; | ||
pid /var/run/nginx.pid; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
|
||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
|
||
# Set client body size limit to 10MB | ||
client_max_body_size 10M; | ||
|
||
upstream django_app { | ||
# Points to the Django/Gunicorn container service name defined in docker-compose | ||
server web:8000; | ||
} | ||
|
||
server { | ||
listen 80; | ||
server_name _; | ||
|
||
# Serving static files directly from Nginx | ||
# Assuming 'staticfiles' directory is where Django collectstatic places files | ||
location /static/ { | ||
alias /usr/share/nginx/html/static/; | ||
expires 1y; | ||
access_log off; | ||
add_header Cache-Control "public"; | ||
} | ||
|
||
location / { | ||
proxy_pass http://django_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; | ||
} | ||
} | ||
} |