diff --git a/castellum_core/.gitignore b/castellum_core/.gitignore index 874dcc6b3497f77ba7f6796f2761495d0e0c783c..2525964517fa16b34b56383a0f4f6b20bb1e01d2 100644 --- a/castellum_core/.gitignore +++ b/castellum_core/.gitignore @@ -5,7 +5,7 @@ castellum_core.egg-info/ dist/ htmlcov/ node_modules/ -collectstatic/ +collected_static/ *.pyc *.sqlite3 diff --git a/castellum_core/Makefile b/castellum_core/Makefile index 42a7ca3d4f144d8e33b739f71f76c984c4390330..270f83b7ee8f52d40eb6f9b2ae4d03fdfffd13af 100644 --- a/castellum_core/Makefile +++ b/castellum_core/Makefile @@ -17,6 +17,9 @@ makemigrations: createsuperuser: $(MANAGEPY) shell -c "from castellum_auth.models import User; User.objects.filter(username='admin') or User.objects.create_superuser('admin', 'admin@example.com', '123')" +collectstatic: + $(MANAGEPY) collectstatic + install: pip install tox ipdb pip install -e . diff --git a/castellum_core/castellum_core/castellum_core/settings/default.py b/castellum_core/castellum_core/castellum_core/settings/default.py index 78c6e8a175996d2a786a07c2188469670498e91f..efee351484f0075bb5ae61c76749e8644ffca7ac 100644 --- a/castellum_core/castellum_core/castellum_core/settings/default.py +++ b/castellum_core/castellum_core/castellum_core/settings/default.py @@ -108,7 +108,7 @@ STATICFILES_FINDERS = [ STATIC_URL = '/static/' -STATIC_ROOT = os.path.join(BASE_DIR, 'collectstatic') +STATIC_ROOT = os.path.join(BASE_DIR, 'collected_static') NPM_ROOT_PATH = os.path.dirname(BASE_DIR) diff --git a/castellum_core/castellum_core/collected_static/.gitkeep b/castellum_core/castellum_core/collected_static/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/castellum_core/uwsgi.ini b/castellum_core/uwsgi.ini index 732c1c885b378dedeb3e4d43fcf5b559c6ae9649..bea07cb66b8ad86b96f0399429693b56d67e70f9 100644 --- a/castellum_core/uwsgi.ini +++ b/castellum_core/uwsgi.ini @@ -1,7 +1,7 @@ [uwsgi] chdir=/code/castellum_core wsgi-file=castellum_core/wsgi.py -socket=0.0.0.0:9000 +socket=0.0.0.0:8000 plugin=python3 env=DJANGO_SETTINGS_MODULE=castellum_core.settings.stage uid=uwsgi diff --git a/docker-compose.yml b/docker-compose.yml index 5acb24b00fed2e96a1f368fa547e72e684fa6896..b80b65801a5d2d973dea5bebb11d223138089761 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,23 +19,19 @@ services: sh -c " python3 castellum_core/manage.py migrate && python3 castellum_core/manage.py shell -c \"from castellum_auth.models import User; User.objects.filter(username='admin') or User.objects.create_superuser('admin', 'admin@example.com', '123')\" && - python3 castellum_core/manage.py collectstatic --no-input && uwsgi uwsgi.ini" volumes: - - static-content:/code/castellum_core/collectstatic - ./stage/settings.py:/code/castellum_core/castellum_core/settings/stage.py depends_on: - db - ldap + nginx: - image: nginx - volumes: - - ./stage/nginx.conf:/etc/nginx/conf.d/default.conf - - static-content:/static + build: + context: . + dockerfile: ./services/nginx/Dockerfile ports: - - "8000:80" + - "80:80" depends_on: - web - -volumes: - static-content: + restart: unless-stopped diff --git a/services/nginx/Dockerfile b/services/nginx/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8f6e2290e298d7a493d20b1b9b5f7d5c5b394930 --- /dev/null +++ b/services/nginx/Dockerfile @@ -0,0 +1,6 @@ +FROM nginx:1.13-alpine + +COPY ./services/nginx/nginx.conf /etc/nginx/nginx.conf +COPY ./castellum_core/castellum_core/collected_static /static + +EXPOSE 80 diff --git a/services/nginx/nginx.conf b/services/nginx/nginx.conf new file mode 100644 index 0000000000000000000000000000000000000000..be2fce62a3fb07b5a23b5c3a459aa8522618e239 --- /dev/null +++ b/services/nginx/nginx.conf @@ -0,0 +1,25 @@ +events { + worker_connections 1024; +} + + +http { + upstream castellum_core { + server web:8000; + } + + server { + listen *:80; + + location / { + include /etc/nginx/uwsgi_params; + uwsgi_pass castellum_core; + } + + location /static { + include /etc/nginx/mime.types; + alias /static; + autoindex off; + } + } +} diff --git a/stage/nginx.conf b/stage/nginx.conf deleted file mode 100644 index 949d4e1dabb07e941bcb40e75996258848a7a91d..0000000000000000000000000000000000000000 --- a/stage/nginx.conf +++ /dev/null @@ -1,17 +0,0 @@ -server { - listen *:80; - - location / { - include /etc/nginx/uwsgi_params; - uwsgi_pass castellum_core; - } - - location /static { - alias /static; - autoindex off; - } -} - -upstream castellum_core { - server web:9000; -}