kopia lustrzana https://github.com/jedie/PyInventory
commit
a2067f6816
4
Makefile
4
Makefile
|
@ -105,8 +105,12 @@ run-docker-dev-server: ## Start docker containers with current dev source code
|
|||
rm -Rf deployment/dist/
|
||||
cp -ruv dist deployment/
|
||||
cd deployment && make down
|
||||
cd deployment && ./compose.dev.sh build --pull
|
||||
cd deployment && ./compose.dev.sh up
|
||||
|
||||
shell_docker-dev-server: ## Go into bash shell in PyInventory dev container
|
||||
cd deployment && ./compose.dev.sh exec inventory /bin/bash
|
||||
|
||||
##############################################################################
|
||||
|
||||
.PHONY: help install lint fix test publish
|
|
@ -1,6 +1,9 @@
|
|||
FROM python:3.9-slim-buster
|
||||
# https://hub.docker.com/_/python
|
||||
|
||||
ARG XDG_CACHE_HOME
|
||||
ENV XDG_CACHE_HOME=${XDG_CACHE_HOME}
|
||||
|
||||
# Install deps
|
||||
RUN apt-get update \
|
||||
&& apt-mark auto $(apt-mark showinstall) \
|
||||
|
@ -11,7 +14,7 @@ RUN apt-get update \
|
|||
&& python3 -m pip install -U pip \
|
||||
&& pip install -U psycopg2-binary
|
||||
|
||||
WORKDIR /inventory
|
||||
WORKDIR /django
|
||||
|
||||
RUN pip install "pyinventory>=0.5.0"
|
||||
|
||||
|
|
|
@ -23,9 +23,6 @@ Disallow: /"
|
|||
file_server /static/* {
|
||||
root /srv/
|
||||
}
|
||||
file_server /media/* {
|
||||
root /srv/
|
||||
}
|
||||
reverse_proxy inventory:8000
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,4 +7,4 @@ DB_PORT=5432
|
|||
PYTHONUNBUFFERED=1
|
||||
|
||||
# e.g.: pip cache:
|
||||
XDG_CACHE_HOME="/var/cache"
|
||||
XDG_CACHE_HOME=/var/cache
|
||||
|
|
|
@ -36,9 +36,8 @@ fi
|
|||
./manage.py migrate
|
||||
|
||||
uwsgi \
|
||||
--http inventory:8000 \
|
||||
--chdir /inventory/ \
|
||||
--wsgi-file /inventory/wsgi.py \
|
||||
--http "$(hostname):8000" \
|
||||
--wsgi-file /django/wsgi.py \
|
||||
--master \
|
||||
--processes 2 \
|
||||
--threads 2 \
|
|
@ -8,7 +8,7 @@ services:
|
|||
|
||||
inventory:
|
||||
environment:
|
||||
- DJANGO_SETTINGS_MODULE=inventory_settings
|
||||
- DJANGO_SETTINGS_MODULE=docker_settings
|
||||
- HOSTNAME=localhost
|
||||
links:
|
||||
- postgres:postgres
|
||||
|
|
|
@ -11,8 +11,7 @@ services:
|
|||
- ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
|
||||
- ./volumes/caddy/data/:/data/:rw
|
||||
- ./volumes/caddy/config/:/config/:rw
|
||||
- ./volumes/static/:/srv/static/:ro
|
||||
- ./volumes/media/:/srv/media/:ro
|
||||
- ./volumes/django/static/:/srv/static/:ro
|
||||
environment:
|
||||
- HOSTNAME=${HOSTNAME:-localhost}
|
||||
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL:-internal}
|
||||
|
@ -27,7 +26,7 @@ services:
|
|||
- "8000"
|
||||
env_file: ./common.env
|
||||
environment:
|
||||
- DJANGO_SETTINGS_MODULE=inventory_settings
|
||||
- DJANGO_SETTINGS_MODULE=docker_settings
|
||||
- HOSTNAME=${HOSTNAME:-localhost}
|
||||
links:
|
||||
- postgres:postgres
|
||||
|
@ -35,12 +34,12 @@ services:
|
|||
- postgres
|
||||
- caddy
|
||||
volumes:
|
||||
- ./inventory/:/inventory/
|
||||
- ./volumes/static/:/static/:rw
|
||||
- ./volumes/media/:/media/:rw
|
||||
- ./django/:/django/:ro
|
||||
- ./volumes/django/:/django_volumes/:rw
|
||||
- ./volumes/django/static/:/static/:rw
|
||||
# e.g.: pip cache must be the same value as $XDG_CACHE_HOME !
|
||||
- ./volumes/cache/:/var/cache/:rw
|
||||
entrypoint: /inventory/entrypoint.sh
|
||||
entrypoint: /django/entrypoint.sh
|
||||
|
||||
postgres:
|
||||
# https://hub.docker.com/_/postgres
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
for pid in $(pidof python3); do kill $pid; done
|
|
@ -126,7 +126,7 @@ norecursedirs = ".* .git __pycache__ coverage* dist volumes"
|
|||
# -p no:warnings
|
||||
addopts = """
|
||||
--import-mode=importlib
|
||||
--ignore-glob=deployment/inventory/*
|
||||
--ignore-glob=deployment/django/*
|
||||
--reuse-db
|
||||
--nomigrations
|
||||
--cov=.
|
||||
|
|
|
@ -8,13 +8,31 @@ from pathlib import Path as __Path
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
# Build paths relative to the current working directory:
|
||||
BASE_PATH = __Path().cwd().resolve()
|
||||
print(f'BASE_PATH:{BASE_PATH}')
|
||||
|
||||
###############################################################################
|
||||
|
||||
# Build paths relative to the project root:
|
||||
PROJECT_PATH = __Path(__file__).parent.parent.parent
|
||||
print(f'PROJECT_PATH:{PROJECT_PATH}')
|
||||
|
||||
if __Path('/.dockerenv').is_file():
|
||||
# We are inside a docker container
|
||||
BASE_PATH = __Path('/django_volumes')
|
||||
assert BASE_PATH.is_dir()
|
||||
else:
|
||||
# Build paths relative to the current working directory:
|
||||
BASE_PATH = __Path().cwd().resolve()
|
||||
|
||||
print(f'BASE_PATH:{BASE_PATH}')
|
||||
|
||||
# Paths with Django dev. server:
|
||||
# BASE_PATH...: .../django-for-runners
|
||||
# PROJECT_PATH: .../django-for-runners/src
|
||||
#
|
||||
# Paths in Docker container:
|
||||
# BASE_PATH...: /for_runners_volumes
|
||||
# PROJECT_PATH: /usr/local/lib/python3.9/site-packages
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
|
|
Ładowanie…
Reference in New Issue