Add basic docker support
This commit is contained in:
parent
54e1b1f93a
commit
8a0a755889
|
@ -0,0 +1,5 @@
|
||||||
|
*.psql
|
||||||
|
*.sqlite3
|
||||||
|
notes.md
|
||||||
|
.venv
|
||||||
|
.pre-commit-config.yaml
|
|
@ -1,3 +1,4 @@
|
||||||
*.psql
|
*.psql
|
||||||
*.sqlite3
|
*.sqlite3
|
||||||
|
.venv
|
||||||
notes.md
|
notes.md
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
FROM python:3.9-bullseye as builder
|
||||||
|
|
||||||
|
RUN mkdir -p /takahe
|
||||||
|
RUN python -m venv /takahe/.venv
|
||||||
|
RUN apt-get update && apt-get -y install libpq-dev python3-dev
|
||||||
|
|
||||||
|
WORKDIR /takahe
|
||||||
|
|
||||||
|
COPY requirements.txt requirements.txt
|
||||||
|
|
||||||
|
RUN . /takahe/.venv/bin/activate \
|
||||||
|
&& pip install --upgrade pip \
|
||||||
|
&& pip install --upgrade -r requirements.txt
|
||||||
|
|
||||||
|
|
||||||
|
FROM python:3.9-slim-bullseye
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y libpq5
|
||||||
|
|
||||||
|
COPY --from=builder /takahe /takahe
|
||||||
|
COPY . /takahe
|
||||||
|
|
||||||
|
WORKDIR /takahe
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
CMD ["/takahe/scripts/start.sh"]
|
|
@ -0,0 +1,42 @@
|
||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:15-alpine
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD', 'pg_isready', '-U', 'postgres']
|
||||||
|
volumes:
|
||||||
|
- dbdata:/var/lib/postgresql/data
|
||||||
|
networks:
|
||||||
|
- internal_network
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- "POSTGRES_DB=tahake"
|
||||||
|
- "POSTGRES_USER=postgres"
|
||||||
|
- "POSTGRES_PASSWORD=insecure_password"
|
||||||
|
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
image: tahake:latest
|
||||||
|
environment:
|
||||||
|
- "DJANGO_SETTINGS_MODULE=takahe.settings"
|
||||||
|
- "SECRET_KEY=insecure_secret"
|
||||||
|
- "POSTGRES_HOST=db"
|
||||||
|
- "POSTGRES_DB=tahake"
|
||||||
|
- "POSTGRES_USER=postgres"
|
||||||
|
- "POSTGRES_PASSWORD=insecure_password"
|
||||||
|
networks:
|
||||||
|
- external_network
|
||||||
|
- internal_network
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
internal_network:
|
||||||
|
external_network:
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
dbdata:
|
|
@ -6,3 +6,6 @@ django-crispy-forms~=1.14
|
||||||
cryptography~=38.0
|
cryptography~=38.0
|
||||||
httpx~=0.23
|
httpx~=0.23
|
||||||
pyOpenSSL~=22.1.0
|
pyOpenSSL~=22.1.0
|
||||||
|
uvicorn~=0.19
|
||||||
|
gunicorn~=20.1.0
|
||||||
|
psycopg2==2.9.5
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /takahe/.venv/bin/activate
|
||||||
|
|
||||||
|
python manage.py migrate
|
||||||
|
|
||||||
|
exec gunicorn takahe.asgi:application -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000
|
|
@ -1,10 +1,11 @@
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = "insecure_secret"
|
SECRET_KEY = os.environ.get("SECRET_KEY", "insecure_secret")
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
@ -64,8 +65,10 @@ WSGI_APPLICATION = "takahe.wsgi.application"
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
||||||
"NAME": "takahe",
|
"HOST": os.environ.get("POSTGRES_HOST", "localhost"),
|
||||||
"USER": "postgres",
|
"NAME": os.environ.get("POSTGRES_DB", "takahe"),
|
||||||
|
"USER": os.environ.get("POSTGRES_USER", "postgres"),
|
||||||
|
"PASSWORD": os.environ.get("POSTGRES_PASSWORD"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue