Start adding deployment infra.
This commit is contained in:
parent
288759146c
commit
9576202fa1
11 changed files with 121 additions and 12 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,7 +1,9 @@
|
||||||
/build
|
/build
|
||||||
*/uploads
|
*/uploads
|
||||||
|
*/staticfiles
|
||||||
__pycache__
|
__pycache__
|
||||||
*.pyc
|
*.pyc
|
||||||
.venv
|
.venv
|
||||||
|
.env*
|
||||||
*.sqlite3
|
*.sqlite3
|
||||||
|
|
||||||
|
|
33
README.md
33
README.md
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Web backend for hosting a wedding website.
|
Web backend for hosting a wedding website.
|
||||||
|
|
||||||
## Run development server:
|
# Run Local server:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
|
@ -10,10 +10,37 @@ cd wedding_site
|
||||||
python manage.py runserver
|
python manage.py runserver
|
||||||
```
|
```
|
||||||
|
|
||||||
## Do Migrations
|
# Do Migrations
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd wedding_site
|
cd wedding_site
|
||||||
python manage.py makemigrations primary
|
python manage.py makemigrations primary
|
||||||
python manage.py migrate
|
python manage.py migrate
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Run Dev Server in container
|
||||||
|
|
||||||
|
```sh
|
||||||
|
podman-compose -f compose.yaml up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
Bring it down with:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
podman-compose down -v
|
||||||
|
```
|
||||||
|
|
||||||
|
# Run Prod Server
|
||||||
|
|
||||||
|
```sh
|
||||||
|
podman-compose -f compose.prod.yaml up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
Sync static files:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
podman-compose -f compose.prod.yaml exec web python manage.py collectstatic --no-input --clear
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
25
compose.prod.yaml
Normal file
25
compose.prod.yaml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build: ./wedding_site
|
||||||
|
command: gunicorn wedding_site.wsgi:application --bind 0.0.0.0:8000
|
||||||
|
volumes:
|
||||||
|
- ./wedding_site/:/usr/src/app/
|
||||||
|
- static_volume:/staticfiles
|
||||||
|
expose:
|
||||||
|
- 8000
|
||||||
|
env_file:
|
||||||
|
- ./.env.prod
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
build: ./nginx
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
volumes:
|
||||||
|
- static_volume:/staticfiles
|
||||||
|
depends_on:
|
||||||
|
- web
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
static_volume:
|
12
compose.yaml
Normal file
12
compose.yaml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build: ./wedding_site
|
||||||
|
command: python manage.py runserver 0.0.0.0:8000
|
||||||
|
volumes:
|
||||||
|
- ./wedding_site/:/usr/src/app/
|
||||||
|
ports:
|
||||||
|
- 8000:8000
|
||||||
|
env_file:
|
||||||
|
- ./.env.dev
|
1
infra/install_arch_deps.sh
Normal file
1
infra/install_arch_deps.sh
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pacman -Sy podman aardvark-dns
|
4
nginx/Dockerfile
Normal file
4
nginx/Dockerfile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
FROM docker.io/nginx
|
||||||
|
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d
|
20
nginx/nginx.conf
Normal file
20
nginx/nginx.conf
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
upstream wedding_site {
|
||||||
|
server web:8000;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://wedding_site;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias /staticfiles/;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1 @@
|
||||||
django
|
podman-compose
|
||||||
markdown
|
|
||||||
pillow
|
|
||||||
beautifulsoup4
|
|
16
wedding_site/Dockerfile
Normal file
16
wedding_site/Dockerfile
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# pull official base image
|
||||||
|
FROM python:3.11.4-slim-buster
|
||||||
|
|
||||||
|
# set environment variables
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE 1
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
|
||||||
|
# install dependencies
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
COPY ./requirements.txt .
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
RUN mkdir staticfiles
|
||||||
|
|
||||||
|
# copy project
|
||||||
|
COPY . .
|
5
wedding_site/requirements.txt
Normal file
5
wedding_site/requirements.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
django
|
||||||
|
markdown
|
||||||
|
pillow
|
||||||
|
beautifulsoup4
|
||||||
|
gunicorn
|
|
@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/5.0/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
@ -19,13 +20,11 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
SECRET_KEY = os.environ.get("SECRET_KEY")
|
||||||
SECRET_KEY = 'django-insecure-bj9fez3qztt5e2lrzpgh%%nat@w^kn!k@l92l=+#%wm)4)p^5m'
|
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
DEBUG = bool(os.environ.get("DEBUG", default=0))
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
ALLOWED_HOSTS = ["localhost"]
|
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ")
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
@ -117,6 +116,7 @@ USE_TZ = True
|
||||||
# https://docs.djangoproject.com/en/5.0/howto/static-files/
|
# https://docs.djangoproject.com/en/5.0/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = 'static/'
|
STATIC_URL = 'static/'
|
||||||
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
||||||
|
|
||||||
# Default primary key field type
|
# Default primary key field type
|
||||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
|
||||||
|
|
Loading…
Reference in a new issue