start project
This commit is contained in:
13
resources/layout/Dockerfile.alpine
Normal file
13
resources/layout/Dockerfile.alpine
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM python:3.12-alpine
|
||||
|
||||
ENV PYTHONPYCACHEPREFIX=/dev/null
|
||||
|
||||
RUN apt update && apt add git gettext
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
COPY requirements.txt /code/requirements.txt
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
|
||||
|
||||
CMD ["sh", "./entrypoint.sh"]
|
||||
4
resources/layout/Dockerfile.nginx
Normal file
4
resources/layout/Dockerfile.nginx
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM nginx:alpine
|
||||
|
||||
COPY ./resources/layout/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
53
resources/layout/nginx.conf
Normal file
53
resources/layout/nginx.conf
Normal file
@@ -0,0 +1,53 @@
|
||||
worker_processes 1;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
client_max_body_size 1024M;
|
||||
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
proxy_pass http://web:8000;
|
||||
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 https;
|
||||
proxy_set_header Host $http_host;
|
||||
}
|
||||
|
||||
location /ws/ {
|
||||
proxy_pass http://web:8000; # Uvicorn serveri ishga tushadigan port
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $http_host;
|
||||
}
|
||||
|
||||
location /resources/static/ {
|
||||
alias /usr/share/nginx/html/resources/static/;
|
||||
}
|
||||
|
||||
location /resources/media/ {
|
||||
alias /usr/share/nginx/html/resources/media/;
|
||||
}
|
||||
}
|
||||
}
|
||||
5
resources/scripts/backup.sh
Normal file
5
resources/scripts/backup.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
file=/tmp/db-$(/usr/bin/date +\%Y-%m-%d-%H:%M:%S).sql
|
||||
container=postgres
|
||||
/usr/bin/docker container exec $container pg_dump -U postgres django > $file
|
||||
mc cp $file b2/buket-name
|
||||
rm $file
|
||||
7
resources/scripts/entrypoint-server.sh
Normal file
7
resources/scripts/entrypoint-server.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
python3 manage.py collectstatic --noinput
|
||||
python3 manage.py makemigrations --noinput
|
||||
python3 manage.py migrate --noinput
|
||||
|
||||
gunicorn config.wsgi:application -b 0.0.0.0:8000 --workers $(($(nproc) * 2 + 1))
|
||||
|
||||
exit $?
|
||||
7
resources/scripts/entrypoint.sh
Normal file
7
resources/scripts/entrypoint.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
python3 manage.py collectstatic --noinput
|
||||
python3 manage.py makemigrations --noinput
|
||||
python3 manage.py migrate --noinput
|
||||
|
||||
uvicorn config.asgi:application --host 0.0.0.0 --port 8000 --reload --reload-dir core --reload-dir config
|
||||
|
||||
exit $?
|
||||
Reference in New Issue
Block a user