kopia lustrzana https://github.com/jedie/PyInventory
More generic deployment: rename "inventory" to "django"
rodzic
b8f14b19af
commit
07f0eeff44
|
@ -0,0 +1,2 @@
|
|||
PROJECT_NAME=pyinventory
|
||||
PYTHON_PACKAGE_NAME=inventory
|
|
@ -1,5 +1,6 @@
|
|||
.*
|
||||
!.dockerignore
|
||||
!.env
|
||||
!.gitignore
|
||||
|
||||
poetry.lock
|
||||
|
|
|
@ -4,7 +4,7 @@ all: help
|
|||
|
||||
help:
|
||||
@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)
|
||||
|
||||
check-poetry:
|
||||
|
@ -68,12 +68,12 @@ init_postgres: ## Create postgres database
|
|||
##############################################################################
|
||||
|
||||
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
|
||||
./compose.sh exec inventory /bin/bash
|
||||
shell_django: ## Go into bash shell in django container
|
||||
./compose.sh exec django /bin/bash
|
||||
|
||||
shell_postgres: ## Go into bash shell in postgres container
|
||||
./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
|
||||
./compose.sh logs --tail=500 --follow postgres
|
||||
|
||||
logs_inventory: ## Display docker logs from inventory container
|
||||
./compose.sh logs --tail=500 --follow inventory
|
||||
logs_django: ## Display docker logs from django container
|
||||
./compose.sh logs --tail=500 --follow django
|
||||
|
||||
logs_caddy: ## Display docker logs from caddy container
|
||||
./compose.sh logs --tail=500 --follow caddy
|
||||
|
@ -103,18 +103,18 @@ logs_caddy: ## Display docker logs from caddy container
|
|||
##############################################################################
|
||||
|
||||
dbbackup: ## Backup database
|
||||
./compose.sh exec inventory ./manage.sh dbbackup
|
||||
./compose.sh exec django ./manage.sh dbbackup
|
||||
|
||||
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
|
||||
|
||||
upgrade_inventory: ## Upgrade "inventory" container and restart it
|
||||
upgrade_django: ## Upgrade "django" container and restart it
|
||||
$(MAKE) build
|
||||
./compose.sh stop inventory
|
||||
./compose.sh stop django
|
||||
$(MAKE) up
|
||||
|
||||
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
|
||||
$(MAKE) logs_caddy
|
||||
|
||||
reload_inventory: ## Reload server in "inventory" container
|
||||
./compose.sh exec inventory ./docker/kill_python.sh
|
||||
./compose.sh logs --tail=500 --follow inventory
|
||||
reload_django: ## Reload server in "django" container
|
||||
./compose.sh exec django ./docker/kill_python.sh
|
||||
./compose.sh logs --tail=500 --follow django
|
||||
|
||||
##############################################################################
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ install some base packages, e.g.:
|
|||
# Theses Makefile targets exists:
|
||||
~/PyInventory/deployment$ make
|
||||
_________________________________________________________________
|
||||
PyInventory - *deployment* Makefile
|
||||
*Deployment* Makefile
|
||||
|
||||
install-poetry install or update poetry
|
||||
install install requirements to setup project
|
||||
|
@ -113,21 +113,21 @@ prune Cleanup docker
|
|||
build Update docker container build
|
||||
init_postgres Create postgres database
|
||||
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_caddy Go into bash shell in caddy container
|
||||
caddy_environ Prints the caddy environment
|
||||
logs Display docker logs from all containers
|
||||
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
|
||||
dbbackup Backup database
|
||||
dbrestore Restore a database backup
|
||||
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
|
||||
reload_caddy Reload Caddy server
|
||||
reload_inventory Reload server in "inventory" container
|
||||
reload_django Reload server in "django" container
|
||||
}}}
|
||||
|
||||
Install, e.g.:
|
||||
|
|
|
@ -23,6 +23,6 @@ Disallow: /"
|
|||
file_server /static/* {
|
||||
root /srv/
|
||||
}
|
||||
reverse_proxy inventory:8000
|
||||
reverse_proxy django:8000
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
DB_NAME=pyinventory
|
||||
DB_USER=postgres
|
||||
DB_PASS=postgres
|
||||
DB_HOST=postgres
|
||||
|
|
|
@ -26,7 +26,7 @@ if [ -d "/dist/" ] ; then
|
|||
else
|
||||
(
|
||||
set -x
|
||||
pip3 install -U "pyinventory>=0.5.0"
|
||||
pip3 install -U "${PYTHON_PACKAGE_NAME}"
|
||||
)
|
||||
fi
|
||||
(
|
||||
|
|
|
@ -6,7 +6,7 @@ services:
|
|||
- HOSTNAME=localhost
|
||||
- LETSENCRYPT_EMAIL=internal
|
||||
|
||||
inventory:
|
||||
django:
|
||||
environment:
|
||||
- DJANGO_SETTINGS_MODULE=docker_settings
|
||||
- HOSTNAME=localhost
|
||||
|
|
|
@ -16,18 +16,19 @@ services:
|
|||
- HOSTNAME=${HOSTNAME:-localhost}
|
||||
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL:-internal}
|
||||
|
||||
inventory:
|
||||
django:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
hostname: inventory
|
||||
hostname: django
|
||||
ports:
|
||||
- "8000"
|
||||
env_file: ./common.env
|
||||
environment:
|
||||
- DJANGO_SETTINGS_MODULE=docker_settings
|
||||
- HOSTNAME=${HOSTNAME:-localhost}
|
||||
- DB_NAME=${PROJECT_NAME}
|
||||
links:
|
||||
- postgres:postgres
|
||||
depends_on:
|
||||
|
@ -50,6 +51,7 @@ services:
|
|||
- "5432"
|
||||
env_file: ./common.env
|
||||
environment:
|
||||
- DB_NAME=${PROJECT_NAME}
|
||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||
volumes:
|
||||
- ./postgres/init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh:ro
|
||||
|
|
Ładowanie…
Reference in New Issue