Skip to content

Commit

Permalink
Add nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
DEENUU1 committed Dec 23, 2023
1 parent f3a4a22 commit 1c40abd
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
FROM python:3.12

WORKDIR /app

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc

COPY requirements.txt .

RUN pip install -r requirements.txt

RUN addgroup --system app && adduser --system --group app

COPY . /app/

ENTRYPOINT ["/app/entrypoints.sh"]
15 changes: 7 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ services:
- redis
restart: always

cloudsqlproxy:
container_name: cloudsql-proxy
image: gcr.io/cloudsql-docker/gce-proxy:1.19.1
volumes:
- ./creds.json:/secrets/cloudsql/creds.json
nginx:
build:
context: .
dockerfile: ./nginx/Dockerfile
ports:
- 127.0.0.1:5432:5432
command: /cloud_sql_proxy -instances="django-cloudrun-project:us-east1:django-dev-db"=tcp:0.0.0.0:5432 -credential_file=/secrets/cloudsql/creds.json
restart: always
- 443:80
depends_on:
- web
6 changes: 6 additions & 0 deletions entrypoints.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

#python manage.py collectstatic --no-input --clear
python manage.py migrate

exec "$@"
2 changes: 2 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM nginx:latest
COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf
16 changes: 16 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
upstream web {
server web:8000;
}

server {

listen 80;

location / {
proxy_pass http://web;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}

}

0 comments on commit 1c40abd

Please sign in to comment.