remove the docker development environment
It's just easier to have the stuff in a venv
This commit is contained in:
parent
49a27b9427
commit
3cbbebb61b
93
Makefile
93
Makefile
|
@ -1,46 +1,79 @@
|
||||||
SHELL=/usr/bin/env bash
|
SHELL=/usr/bin/env bash
|
||||||
|
|
||||||
.PHONY: docker
|
.DEFAULT_GOAL := run
|
||||||
|
|
||||||
docker:
|
.PHONY: run
|
||||||
export DJANGO_SETTINGS_MODULE=network_inventory.settings.docker; \
|
run: setup
|
||||||
docker-compose -f docker-compose-development.yml up
|
export DJANGO_SETTINGS_MODULE=network_inventory.settings.local; \
|
||||||
|
$(find . -name __pycache__ -o -name "*.pyc" -delete) \
|
||||||
|
python manage.py runserver; \
|
||||||
|
|
||||||
init:
|
.PHONY: setup
|
||||||
export DJANGO_SETTINGS_MODULE=network_inventory.settings.docker; \
|
setup: ./venv
|
||||||
docker-compose -f docker-compose-development.yml run web python manage.py loaddata network_inventory.yaml
|
( \
|
||||||
|
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:
|
./venv:
|
||||||
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:
|
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
( \
|
( \
|
||||||
source venv/bin/activate; \
|
source venv/bin/activate; \
|
||||||
pip3 install -r requirements/local.txt; \
|
pip3 install -r requirements/local.txt; \
|
||||||
)
|
)
|
||||||
|
|
||||||
testlocal:
|
.PHONY: clean
|
||||||
( \
|
|
||||||
source venv/bin/activate; \
|
|
||||||
pytest -nauto --ds=network_inventory.settings.local --nomigrations --cov=. --cov-report=html; \
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
docker-compose -f docker-compose-development.yml down -v
|
docker-compose -f docker-compose-development.yml down -v
|
||||||
sudo find . \( -name __pycache__ -o -name "*.pyc" \) -delete
|
find . \( -name __pycache__ -o -name "*.pyc" \) -delete
|
||||||
sudo rm -rf htmlcov/
|
rm -rf htmlcov/
|
||||||
sudo rm -f */migrations/0*.py
|
rm -f */migrations/0*.py
|
||||||
sudo rm .second_run
|
rm .second_run
|
||||||
|
|
||||||
cleanall:
|
.PHONY: cleanall
|
||||||
|
cleanall: clean
|
||||||
docker-compose -f docker-compose-development.yml down -v --rmi local
|
docker-compose -f docker-compose-development.yml down -v --rmi local
|
||||||
rm -rf venv/
|
rm -rf venv/
|
||||||
sudo find . \( -name __pycache__ -o -name "*.pyc" \) -delete
|
|
||||||
sudo rm -rf htmlcov/
|
.PHONY: init
|
||||||
sudo rm -f */migrations/*.py
|
init:
|
||||||
sudo rm .second_run
|
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
|
||||||
|
|
|
@ -7,27 +7,9 @@ services:
|
||||||
db:
|
db:
|
||||||
image: postgres
|
image: postgres
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_DB
|
- POSTGRES_DB=network_inventory
|
||||||
- POSTGRES_PASSWORD
|
- POSTGRES_PASSWORD=password
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/var/lib/postgresql/data/
|
- 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:
|
ports:
|
||||||
- 8080:80
|
- "5432:5432"
|
||||||
depends_on:
|
|
||||||
- web
|
|
||||||
volumes:
|
|
||||||
- ./static:/home/app/web/static
|
|
||||||
|
|
|
@ -5,16 +5,23 @@ ALLOWED_HOSTS = [
|
||||||
'127.0.0.1',
|
'127.0.0.1',
|
||||||
]
|
]
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
CSRF_TRUSTED_ORIGINS = [
|
||||||
SECRET_KEY = 'development_key'
|
'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
|
DEBUG = True
|
||||||
CRISPY_FAIL_SILENTLY = not DEBUG
|
CRISPY_FAIL_SILENTLY = not DEBUG
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
'NAME': ':memory:',
|
'NAME': 'postgres',
|
||||||
|
'USER': 'postgres',
|
||||||
|
'HOST': 'localhost',
|
||||||
|
'PORT': 5432,
|
||||||
|
'PASSWORD': 'password',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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',
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue