-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
163 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
version: '3.9' | ||
|
||
volumes: | ||
postgres_volume: | ||
static_volume: | ||
media_volume: | ||
|
||
services: | ||
# Database Postgres | ||
db: | ||
image: postgres:latest | ||
container_name: postgres | ||
env_file: | ||
- ./retail_order_api/.env | ||
volumes: | ||
- postgres_volume:/var/lib/postgresql/data/ | ||
ports: | ||
- "5432:5432" | ||
|
||
# Django App | ||
web: | ||
build: ./retail_order_api | ||
container_name: retail_order_api | ||
ports: | ||
- "8000:8000" | ||
env_file: | ||
- ./retail_order_api/.env | ||
volumes: | ||
- static_volume:/usr/src/app/static | ||
- media_volume:/usr/src/app/media | ||
depends_on: | ||
- db | ||
command: sh /usr/src/app/entrypoint.sh | ||
|
||
# web-server | ||
nginx: | ||
build: ./nginx | ||
container_name: nginx | ||
restart: on-failure | ||
ports: | ||
- '1337:80' | ||
volumes: | ||
- static_volume:/static | ||
- media_volume:/media | ||
depends_on: | ||
- web | ||
|
||
# Redis | ||
redis: | ||
image: redis:latest | ||
container_name: redis | ||
ports: | ||
- "6300:6379" | ||
|
||
# Celery | ||
celery: | ||
build: ./retail_order_api | ||
command: celery -A retail_order_api worker -l info | ||
depends_on: | ||
- redis | ||
- db |
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,3 @@ | ||
FROM nginx:1.24-alpine | ||
RUN rm /etc/nginx/conf.d/default.conf | ||
COPY nginx.conf /etc/nginx/conf.d |
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,30 @@ | ||
upstream retail-order { | ||
server retail_order_api:8000; | ||
} | ||
|
||
server { | ||
|
||
listen 80; | ||
server_name localhost; | ||
|
||
client_max_body_size 100M; | ||
proxy_force_ranges on; | ||
add_header Accept-Ranges bytes; | ||
|
||
location / { | ||
proxy_ignore_client_abort on; | ||
proxy_pass http://retail-order; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
} | ||
|
||
|
||
location /static/ { | ||
alias /static/; | ||
} | ||
|
||
location /media/ { | ||
alias /media/; | ||
} | ||
} |
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,27 @@ | ||
### main_dockerignore template | ||
# Personal | ||
manual.md | ||
initial_task.md | ||
README.md | ||
static/ | ||
|
||
# Git | ||
.gitignore | ||
.git | ||
|
||
# Environments | ||
venv_wsl | ||
#.env | ||
.venv | ||
env/ | ||
venv/ | ||
venv_wsl/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# PyCharm | ||
.idea/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ |
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,13 @@ | ||
FROM python:3.12-alpine | ||
|
||
WORKDIR /usr/src/app | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERD 1 | ||
|
||
COPY requirements.txt /usr/src/app/requirements.txt | ||
|
||
RUN python3 -m pip install --upgrade pip | ||
RUN pip3 install -r requirements.txt | ||
|
||
COPY . /usr/src/app |
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
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 @@ | ||
#!/bin/bash | ||
|
||
python manage.py makemigrations --noinput | ||
python manage.py migrate --noinput | ||
echo "Apply database migrations" | ||
python manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.filter(username='root').exists() or User.objects.create_superuser('[email protected]', 'root')" | ||
echo "Create SUPERUSER" | ||
python manage.py collectstatic --no-input | ||
echo "Starting server" | ||
gunicorn retail_order_api.wsgi:application --bind 0.0.0.0:8000 |
Binary file not shown.
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