Tweaks for old server. Ready for re-deployment
This commit is contained in:
@@ -3,4 +3,5 @@
|
|||||||
**/prod_data
|
**/prod_data
|
||||||
**/venv
|
**/venv
|
||||||
**/__pycache__
|
**/__pycache__
|
||||||
**/db.sqlite3
|
**/db.sqlite3
|
||||||
|
**/nginx.conf
|
||||||
@@ -22,7 +22,7 @@ RUN mkdir -p ${DATA_DIR}
|
|||||||
WORKDIR ${APP_DIR}
|
WORKDIR ${APP_DIR}
|
||||||
|
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
RUN apt-get install --yes --no-install-recommends nano curl
|
RUN apt-get install --yes --no-install-recommends wget
|
||||||
|
|
||||||
# Build pip requirements
|
# Build pip requirements
|
||||||
ADD ./requirements.txt .
|
ADD ./requirements.txt .
|
||||||
|
|||||||
11
one_trip_api/Server deployment.txt
Normal file
11
one_trip_api/Server deployment.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
1. sudo useradd --system --shell /bin/bash groceries
|
||||||
|
2. sudo usermod -aG www-data groceries
|
||||||
|
3. id -u groceries
|
||||||
|
4. id -g www-data
|
||||||
|
5. edit docker-compose.yaml to have correct UID / GID
|
||||||
|
6. docker compose build
|
||||||
|
7. sudo mkdir -p /var/www/groceries.alaevens.ca/data
|
||||||
|
8. sudo cp EXISTING_DB_FILE /var/www/groceries.alaevens.ca/db.sqlite3
|
||||||
|
9. sudo chown -R groceries /var/www/groceries.alaevens.ca/
|
||||||
|
10. sudo chgrp -R www-data /var/www/groceries.alaevens.ca/
|
||||||
|
11. docker compose up -d
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
services:
|
services:
|
||||||
groceries:
|
groceries:
|
||||||
|
container_name: groceries-api
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
args:
|
args:
|
||||||
- UID=999
|
- UID=992
|
||||||
- GID=33
|
- GID=33
|
||||||
ports:
|
ports:
|
||||||
- 8001:8080
|
- 8001:8080
|
||||||
|
stdin_open: true
|
||||||
|
tty: true
|
||||||
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- /var/www/groceries.alaevens.ca/data:/home/groceries/data:rw
|
- /var/www/groceries.alaevens.ca/data:/home/groceries/data:rw
|
||||||
- type: bind
|
- type: bind
|
||||||
@@ -14,7 +18,9 @@ services:
|
|||||||
target: /home/groceries/web/db.sqlite3
|
target: /home/groceries/web/db.sqlite3
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
|
container_name: groceries-ws-cache
|
||||||
image: "redis:alpine"
|
image: "redis:alpine"
|
||||||
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- 6379:6379
|
- 6379:6379
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
printf "Make migrations:\n"
|
||||||
python3 manage.py makemigrations
|
python3 manage.py makemigrations
|
||||||
|
printf "\n\nMigrate:\n"
|
||||||
python3 manage.py migrate
|
python3 manage.py migrate
|
||||||
|
printf "\n\nCollect static:\n"
|
||||||
python3 manage.py collectstatic --no-input
|
python3 manage.py collectstatic --no-input
|
||||||
|
printf "\n\nStart ASGI server:\n"
|
||||||
gunicorn one_trip_api.asgi:application -b 0.0.0.0:8080 --access-logfile - -k uvicorn.workers.UvicornWorker
|
gunicorn one_trip_api.asgi:application -b 0.0.0.0:8080 --access-logfile - -k uvicorn.workers.UvicornWorker
|
||||||
59
one_trip_api/nginx.conf
Normal file
59
one_trip_api/nginx.conf
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
server {
|
||||||
|
server_name groceries.alaevens.ca;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_pass http://container;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /downloads/ {
|
||||||
|
autoindex on;
|
||||||
|
alias /var/www/groceries.alaevens.ca/downloads/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias /var/www/groceries.alaevens.ca/data/static/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /media/ {
|
||||||
|
alias /var/www/groceries.alaevens.ca/data/media/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /app/ {
|
||||||
|
alias /var/www/groceries.alaevens.ca/web_app/;
|
||||||
|
index index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
listen [::]:443 ssl;
|
||||||
|
listen 443 ssl; # managed by Certbot
|
||||||
|
ssl_certificate /etc/letsencrypt/live/alaevens.ca/fullchain.pem; # managed by Certbot
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/alaevens.ca/privkey.pem; # managed by Certbot
|
||||||
|
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||||
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
if ($host = groceries.alaevens.ca) {
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
} # managed by Certbot
|
||||||
|
|
||||||
|
|
||||||
|
server_name groceries.alaevens.ca;
|
||||||
|
|
||||||
|
listen [::]:80;
|
||||||
|
listen 80;
|
||||||
|
return 404; # managed by Certbot
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
upstream container {
|
||||||
|
server 127.0.0.1:8001;
|
||||||
|
}
|
||||||
@@ -28,5 +28,3 @@ urlpatterns = [
|
|||||||
|
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
urlpatterns += staticfiles_urlpatterns()
|
urlpatterns += staticfiles_urlpatterns()
|
||||||
|
|
||||||
print("URLPATTERNS:", urlpatterns)
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
anyio==4.3.0
|
||||||
asgiref==3.7.2
|
asgiref==3.7.2
|
||||||
async-timeout==4.0.2
|
async-timeout==4.0.2
|
||||||
certifi==2022.9.24
|
certifi==2022.9.24
|
||||||
@@ -13,6 +14,7 @@ djangorestframework==3.14.0
|
|||||||
docopt==0.6.2
|
docopt==0.6.2
|
||||||
gunicorn==21.2.0
|
gunicorn==21.2.0
|
||||||
h11==0.14.0
|
h11==0.14.0
|
||||||
|
httptools==0.6.1
|
||||||
idna==3.6
|
idna==3.6
|
||||||
Markdown==3.4.1
|
Markdown==3.4.1
|
||||||
msgpack==1.0.4
|
msgpack==1.0.4
|
||||||
@@ -20,12 +22,18 @@ packaging==21.3
|
|||||||
Pillow==9.3.0
|
Pillow==9.3.0
|
||||||
pipreqs==0.4.11
|
pipreqs==0.4.11
|
||||||
pyparsing==3.0.9
|
pyparsing==3.0.9
|
||||||
|
python-dotenv==1.0.1
|
||||||
python-monkey-business==1.0.0
|
python-monkey-business==1.0.0
|
||||||
pytz==2022.6
|
pytz==2022.6
|
||||||
|
PyYAML==6.0.1
|
||||||
redis==4.3.5
|
redis==4.3.5
|
||||||
requests==2.28.1
|
requests==2.28.1
|
||||||
six==1.16.0
|
six==1.16.0
|
||||||
|
sniffio==1.3.1
|
||||||
sqlparse==0.4.3
|
sqlparse==0.4.3
|
||||||
urllib3==1.26.13
|
urllib3==1.26.13
|
||||||
uvicorn==0.27.1
|
uvicorn==0.27.1
|
||||||
yarg==0.1.9
|
uvloop==0.19.0
|
||||||
|
watchfiles==0.21.0
|
||||||
|
websockets==12.0
|
||||||
|
yarg==0.1.9
|
||||||
Reference in New Issue
Block a user