From 44d2ce22abf6706d1f6b85128878fe1b701bc200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Sun, 5 Nov 2017 17:26:20 +0100 Subject: [PATCH] Got the site up running using docker-compose. Also added a Makefile for convenience. --- Dockerfile | 8 ++++++++ Makefile | 19 +++++++++++++++++++ README.md | 16 +++++++++++++--- docker-compose.yml | 19 +++++++++++++++++++ src/bornhack/environment_settings.py.dist | 8 ++++---- 5 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..7e2bcadb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3 +ENV PYTHONUNBUFFERED 1 +RUN mkdir /code +WORKDIR /code +ADD src/requirements.txt /code/ +RUN pip install -r requirements.txt +RUN apt-get update +RUN apt-get -y install wkhtmltopdf diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..e8f3eef1 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +all: build db_up sleep migrate bootstrap web_up + +build: + docker-compose build + +db_up: + docker-compose up -d db + +migrate: + docker-compose run web /usr/local/bin/python src/manage.py migrate + +bootstrap: + docker-compose run web /usr/local/bin/python src/manage.py bootstrap-devsite + +sleep: + echo "Sleeping to ensure that the db is up."; sleep 3 + +web_up: + docker-compose up web diff --git a/README.md b/README.md index 0e2401db..2c849a3c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,17 @@ Django project to power Bornhack. Features include news, villages, webshop, and ## Quickstart -### Clone the repo +### Using docker-compose + +If you have docker-compose you can use the included make file. Like so: + + $ make + +### Manual way + + + +#### Clone the repo Clone with --recursive to include submodules: git clone --recursive https://github.com/bornhack/bornhack-website @@ -13,14 +23,14 @@ If you already cloned the repository, you can add the submodules like this: git submodule update --init --recursive -### Virtualenv +#### Virtualenv Create a Python 3 virtual environment and activate it: ``` $ virtualenv venv -p python3 $ source venv/bin/activate ``` -### System libraries +#### System libraries Install system dependencies (method depends on OS): - postgresql headers (for psycopg2): - Debian: libpq-dev diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..0ec1bb21 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +version: '2' + +services: + db: + image: postgres + restart: always + environment: + POSTGRES_PASSWORD: bornhack + POSTGRES_USER: bornhack + POSTGRES_DB: bornhack + web: + build: . + command: python3 src/manage.py runserver 0.0.0.0:8000 + volumes: + - .:/code + ports: + - "8000:8000" + depends_on: + - db diff --git a/src/bornhack/environment_settings.py.dist b/src/bornhack/environment_settings.py.dist index 4fced002..b86f7895 100644 --- a/src/bornhack/environment_settings.py.dist +++ b/src/bornhack/environment_settings.py.dist @@ -29,6 +29,10 @@ CHANNEL_LAYERS = { }, } +# start redirecting to the next camp instead of the previous camp after +# this much of the time between the camps has passed +CAMP_REDIRECT_PERCENT=40 + ### changes below here are only needed for production # email settings @@ -47,10 +51,6 @@ TIME_ZONE='{{ django_timezone }}' MEDIA_ROOT='{{ django_media_root }}' PDF_ARCHIVE_PATH='{{ pdf_archive_path }}' -# start redirecting to the next camp instead of the previous camp after -# this much of the time between the camps has passed -CAMP_REDIRECT_PERCENT=40 - # PSP settings EPAY_MERCHANT_NUMBER='{{ epay_merchant_number }}' EPAY_MD5_SECRET='{{ epay_md5_secret }}'