More generic deployment: rename "inventory" to "django"

pull/26/head
JensDiemer 2020-11-22 12:51:14 +01:00
rodzic b8f14b19af
commit 07f0eeff44
9 zmienionych plików z 28 dodań i 24 usunięć

2
deployment/.env 100644
Wyświetl plik

@ -0,0 +1,2 @@
PROJECT_NAME=pyinventory
PYTHON_PACKAGE_NAME=inventory

Wyświetl plik

@ -1,5 +1,6 @@
.* .*
!.dockerignore !.dockerignore
!.env
!.gitignore !.gitignore
poetry.lock poetry.lock

Wyświetl plik

@ -4,7 +4,7 @@ all: help
help: help:
@echo -e '_________________________________________________________________' @echo -e '_________________________________________________________________'
@echo -e 'PyInventory - *deployment* Makefile\n' @echo -e '*Deployment* Makefile\n'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9 -_]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9 -_]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
check-poetry: check-poetry:
@ -68,12 +68,12 @@ init_postgres: ## Create postgres database
############################################################################## ##############################################################################
createsuperuser: ## Create super user createsuperuser: ## Create super user
./compose.sh exec inventory ./manage.sh createsuperuser ./compose.sh exec django ./manage.sh createsuperuser
############################################################################## ##############################################################################
shell_inventory: ## Go into bash shell in inventory container shell_django: ## Go into bash shell in django container
./compose.sh exec inventory /bin/bash ./compose.sh exec django /bin/bash
shell_postgres: ## Go into bash shell in postgres container shell_postgres: ## Go into bash shell in postgres container
./compose.sh exec postgres /bin/bash ./compose.sh exec postgres /bin/bash
@ -94,8 +94,8 @@ logs: ## Display docker logs from all containers
logs_postgres: ## Display docker logs from postgres container logs_postgres: ## Display docker logs from postgres container
./compose.sh logs --tail=500 --follow postgres ./compose.sh logs --tail=500 --follow postgres
logs_inventory: ## Display docker logs from inventory container logs_django: ## Display docker logs from django container
./compose.sh logs --tail=500 --follow inventory ./compose.sh logs --tail=500 --follow django
logs_caddy: ## Display docker logs from caddy container logs_caddy: ## Display docker logs from caddy container
./compose.sh logs --tail=500 --follow caddy ./compose.sh logs --tail=500 --follow caddy
@ -103,18 +103,18 @@ logs_caddy: ## Display docker logs from caddy container
############################################################################## ##############################################################################
dbbackup: ## Backup database dbbackup: ## Backup database
./compose.sh exec inventory ./manage.sh dbbackup ./compose.sh exec django ./manage.sh dbbackup
dbrestore: ## Restore a database backup dbrestore: ## Restore a database backup
./compose.sh exec inventory ./manage.sh dbrestore ./compose.sh exec django ./manage.sh dbrestore
############################################################################## ##############################################################################
restart: down up ## Restart all containers restart: down up ## Restart all containers
upgrade_inventory: ## Upgrade "inventory" container and restart it upgrade_django: ## Upgrade "django" container and restart it
$(MAKE) build $(MAKE) build
./compose.sh stop inventory ./compose.sh stop django
$(MAKE) up $(MAKE) up
restart_caddy: ## Restart caddy container restart_caddy: ## Restart caddy container
@ -127,9 +127,9 @@ reload_caddy: ## Reload Caddy server
./compose.sh exec caddy caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile ./compose.sh exec caddy caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile
$(MAKE) logs_caddy $(MAKE) logs_caddy
reload_inventory: ## Reload server in "inventory" container reload_django: ## Reload server in "django" container
./compose.sh exec inventory ./docker/kill_python.sh ./compose.sh exec django ./docker/kill_python.sh
./compose.sh logs --tail=500 --follow inventory ./compose.sh logs --tail=500 --follow django
############################################################################## ##############################################################################

Wyświetl plik

@ -102,7 +102,7 @@ install some base packages, e.g.:
# Theses Makefile targets exists: # Theses Makefile targets exists:
~/PyInventory/deployment$ make ~/PyInventory/deployment$ make
_________________________________________________________________ _________________________________________________________________
PyInventory - *deployment* Makefile *Deployment* Makefile
install-poetry install or update poetry install-poetry install or update poetry
install install requirements to setup project install install requirements to setup project
@ -113,21 +113,21 @@ prune Cleanup docker
build Update docker container build build Update docker container build
init_postgres Create postgres database init_postgres Create postgres database
createsuperuser Create super user createsuperuser Create super user
shell_inventory Go into bash shell in inventory container shell_django Go into bash shell in django container
shell_postgres Go into bash shell in postgres container shell_postgres Go into bash shell in postgres container
shell_caddy Go into bash shell in caddy container shell_caddy Go into bash shell in caddy container
caddy_environ Prints the caddy environment caddy_environ Prints the caddy environment
logs Display docker logs from all containers logs Display docker logs from all containers
logs_postgres Display docker logs from postgres container logs_postgres Display docker logs from postgres container
logs_inventory Display docker logs from inventory container logs_django Display docker logs from django container
logs_caddy Display docker logs from caddy container logs_caddy Display docker logs from caddy container
dbbackup Backup database dbbackup Backup database
dbrestore Restore a database backup dbrestore Restore a database backup
restart Restart all containers restart Restart all containers
upgrade_inventory Upgrade "inventory" container and restart it upgrade_django Upgrade "django" container and restart it
restart_caddy Restart caddy container restart_caddy Restart caddy container
reload_caddy Reload Caddy server reload_caddy Reload Caddy server
reload_inventory Reload server in "inventory" container reload_django Reload server in "django" container
}}} }}}
Install, e.g.: Install, e.g.:

Wyświetl plik

@ -23,6 +23,6 @@ Disallow: /"
file_server /static/* { file_server /static/* {
root /srv/ root /srv/
} }
reverse_proxy inventory:8000 reverse_proxy django:8000
} }
} }

Wyświetl plik

@ -1,4 +1,3 @@
DB_NAME=pyinventory
DB_USER=postgres DB_USER=postgres
DB_PASS=postgres DB_PASS=postgres
DB_HOST=postgres DB_HOST=postgres

Wyświetl plik

@ -26,7 +26,7 @@ if [ -d "/dist/" ] ; then
else else
( (
set -x set -x
pip3 install -U "pyinventory>=0.5.0" pip3 install -U "${PYTHON_PACKAGE_NAME}"
) )
fi fi
( (

Wyświetl plik

@ -6,7 +6,7 @@ services:
- HOSTNAME=localhost - HOSTNAME=localhost
- LETSENCRYPT_EMAIL=internal - LETSENCRYPT_EMAIL=internal
inventory: django:
environment: environment:
- DJANGO_SETTINGS_MODULE=docker_settings - DJANGO_SETTINGS_MODULE=docker_settings
- HOSTNAME=localhost - HOSTNAME=localhost

Wyświetl plik

@ -16,18 +16,19 @@ services:
- HOSTNAME=${HOSTNAME:-localhost} - HOSTNAME=${HOSTNAME:-localhost}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL:-internal} - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL:-internal}
inventory: django:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
restart: unless-stopped restart: unless-stopped
hostname: inventory hostname: django
ports: ports:
- "8000" - "8000"
env_file: ./common.env env_file: ./common.env
environment: environment:
- DJANGO_SETTINGS_MODULE=docker_settings - DJANGO_SETTINGS_MODULE=docker_settings
- HOSTNAME=${HOSTNAME:-localhost} - HOSTNAME=${HOSTNAME:-localhost}
- DB_NAME=${PROJECT_NAME}
links: links:
- postgres:postgres - postgres:postgres
depends_on: depends_on:
@ -50,6 +51,7 @@ services:
- "5432" - "5432"
env_file: ./common.env env_file: ./common.env
environment: environment:
- DB_NAME=${PROJECT_NAME}
- POSTGRES_HOST_AUTH_METHOD=trust - POSTGRES_HOST_AUTH_METHOD=trust
volumes: volumes:
- ./postgres/init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh:ro - ./postgres/init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh:ro