diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..169edd6 --- /dev/null +++ b/.env.example @@ -0,0 +1,29 @@ +#################################################################################################### +# Example configuration. Must be edited and copied to ".env" next to the compose.yaml +#################################################################################################### + + +# Path to to mount as the directory for static data. Must be served by a webserver on the /static path +DJANGO_STATIC_VOL=/path/to/static/root + +# Path to the media root. Must be served by a webserver on the media URL +DJANGO_MEDIA_VOL=/path/to/media/root + +# Port to serve the App +PORT=8000 + +# Secret Key. Must be edited before deployment +DJANGO_SECRET_KEY=534hj5jgh4365ghj35jgh245jgh24 + +# Allowed host be be accessed. Currently it is only possible to specify a single URL +DJANGO_ALLOWED_HOST=lab.example.com + +# Media URL for images and other content +DJANGO_MEDIA_URL=media.lab.example.com/ + +# DO NOT SET DEBUG MODE IN PRODUCTION +# DJANGO_FORCE_DEV_MODE=True + +# Set this password if you want to use a custom postgres password. The db should be condifed inside the docker network. +# Using the standard PW is therefore not a problem +# DJANGO_POSTGRESQL_PW=myfancynewpassword123donotsharemewithanyone \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6557b16..8c6eff1 100644 --- a/.gitignore +++ b/.gitignore @@ -125,3 +125,6 @@ dmypy.json myenv/* + +run/* +.env diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..d273b48 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,36 @@ +services: + shimatta-kenkyusho-web: + build: . + volumes: + - "${DJANGO_STATIC_VOL:-./run/static}:/var/static" + - "${DJANGO_MEDIA_VOL:-./run/media}:/var/media" + environment: + DJANGO_POSTGRESQL_PW: "${DJANGO_POSTGRESQL_PW:-p4ssw0rd}" + DJANGO_POSTGRESQL_USER: "postgres" + DJANGO_SECRET_KEY: "${DJANGO_SECRET_KEY}" + DJANGO_ALLOWED_HOST: "${DJANGO_ALLOWED_HOST}" + DJANGO_STATIC_ROOT: "/var/static" + DJANGO_MEDIA_URL: "${DJANGO_MEDIA_URL}" + DJANGO_MEDIA_ROOT: "/var/media" + DJANGO_POSTGRESQL_SOCKET: "shimatta-kenkyusho-db" + DJANGO_POSTGRESQL_PORT: "5432" + DJANGO_FORCE_DEV_MODE: ${DJANGO_FORCE_DEV_MODE:-False} + ports: + - "${PORT}:8000" + networks: + - backendnet + depends_on: + - "shimatta-kenkyusho-db" + + shimatta-kenkyusho-db: + image: postgres:16.5-alpine + environment: + POSTGRES_PASSWORD: "${DJANGO_POSTGRESQL_PW:-p4ssw0rd}" + POSTGRES_DB: "shimatta_kenkyusho" + volumes: + - "${PGDATA:-./run/pgdata}:/var/lib/postgresql/data" + networks: + - backendnet + +networks: + backendnet: diff --git a/start_docker_compose_interactive.sh b/start_docker_compose_interactive.sh new file mode 100755 index 0000000..eaf2076 --- /dev/null +++ b/start_docker_compose_interactive.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Startup the db container +docker-compose start shimatta-kenkyusho-db + +# Override entrypoint to get interactive shell +docker-compose run --entrypoint="/bin/sh" -p 8000:8000 shimatta-kenkyusho-web \ No newline at end of file