remove the docker development environment

It's just easier to have the stuff in a venv
This commit is contained in:
Andreas Zweili 2022-02-07 22:27:59 +01:00
parent 49a27b9427
commit 3cbbebb61b
4 changed files with 78 additions and 83 deletions

View File

@ -1,46 +1,79 @@
SHELL=/usr/bin/env bash
.PHONY: docker
.DEFAULT_GOAL := run
docker:
export DJANGO_SETTINGS_MODULE=network_inventory.settings.docker; \
docker-compose -f docker-compose-development.yml up
.PHONY: run
run: setup
export DJANGO_SETTINGS_MODULE=network_inventory.settings.local; \
$(find . -name __pycache__ -o -name "*.pyc" -delete) \
python manage.py runserver; \
init:
export DJANGO_SETTINGS_MODULE=network_inventory.settings.docker; \
docker-compose -f docker-compose-development.yml run web python manage.py loaddata network_inventory.yaml
.PHONY: setup
setup: ./venv
( \
source venv/bin/activate; \
export DJANGO_SETTINGS_MODULE=network_inventory.settings.local; \
docker-compose -f docker-compose-development.yml up -d; \
if [ -f .second_run ]; then \
sleep 2; \
python manage.py collectstatic --noinput; \
python manage.py makemigrations; \
python manage.py migrate; \
else \
python manage.py collectstatic --noinput; \
python manage.py makemigrations backups; \
python manage.py makemigrations computers; \
python manage.py makemigrations core; \
python manage.py makemigrations customers; \
python manage.py makemigrations devices; \
python manage.py makemigrations licenses; \
python manage.py makemigrations nets; \
python manage.py makemigrations softwares; \
python manage.py makemigrations users; \
python manage.py makemigrations; \
python manage.py migrate; \
python manage.py loaddata backups; \
python manage.py loaddata computers; \
python manage.py loaddata core; \
python manage.py loaddata devices; \
python manage.py loaddata nets; \
python manage.py loaddata softwares; \
python manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin@example.com', 'password')"; \
touch .second_run; \
fi; \
)
test:
docker-compose -f docker-compose-development.yml run web pytest -nauto --nomigrations --cov=. --cov-report=html
debug:
docker-compose -f docker-compose-development.yml run web pytest --pdb --nomigrations --cov=. --cov-report=html
local:
./venv:
python3 -m venv venv
( \
source venv/bin/activate; \
pip3 install -r requirements/local.txt; \
)
testlocal:
( \
source venv/bin/activate; \
pytest -nauto --ds=network_inventory.settings.local --nomigrations --cov=. --cov-report=html; \
)
.PHONY: clean
clean:
docker-compose -f docker-compose-development.yml down -v
sudo find . \( -name __pycache__ -o -name "*.pyc" \) -delete
sudo rm -rf htmlcov/
sudo rm -f */migrations/0*.py
sudo rm .second_run
find . \( -name __pycache__ -o -name "*.pyc" \) -delete
rm -rf htmlcov/
rm -f */migrations/0*.py
rm .second_run
cleanall:
.PHONY: cleanall
cleanall: clean
docker-compose -f docker-compose-development.yml down -v --rmi local
rm -rf venv/
sudo find . \( -name __pycache__ -o -name "*.pyc" \) -delete
sudo rm -rf htmlcov/
sudo rm -f */migrations/*.py
sudo rm .second_run
.PHONY: init
init:
export DJANGO_SETTINGS_MODULE=network_inventory.settings.local; \
python manage.py loaddata network_inventory.yaml
.PHONY: test
test:
export DJANGO_SETTINGS_MODULE=network_inventory.settings.local; \
pytest -nauto --nomigrations --cov=. --cov-report=html
.PHONY: debug
debug:
export DJANGO_SETTINGS_MODULE=network_inventory.settings.local; \
pytest --pdb --nomigrations --cov=. --cov-report=html

View File

@ -7,27 +7,9 @@ services:
db:
image: postgres
environment:
- POSTGRES_DB
- POSTGRES_PASSWORD
- POSTGRES_DB=network_inventory
- POSTGRES_PASSWORD=password
volumes:
- db_data:/var/lib/postgresql/data/
web:
build: .
volumes:
- .:/code
environment:
- DJANGO_SETTINGS_MODULE
- DJANGO_DEBUG
- DJANGO_SECRET_KEY
depends_on:
- db
nginx:
build: ./nginx
ports:
- 8080:80
depends_on:
- web
volumes:
- ./static:/home/app/web/static
- "5432:5432"

View File

@ -5,16 +5,23 @@ ALLOWED_HOSTS = [
'127.0.0.1',
]
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'development_key'
CSRF_TRUSTED_ORIGINS = [
'http://localhost:8000',
]
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "foo"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
CRISPY_FAIL_SILENTLY = not DEBUG
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'USER': 'postgres',
'HOST': 'localhost',
'PORT': 5432,
'PASSWORD': 'password',
}
}

View File

@ -1,27 +0,0 @@
from .base import *
ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
]
CSRF_TRUSTED_ORIGINS = [
'http://localhost:8000',
]
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "foo"
DEBUG = True
CRISPY_FAIL_SILENTLY = not DEBUG
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'USER': 'postgres',
'HOST': 'localhost',
'PORT': 5432,
'PASSWORD': 'password',
}
}