commit
1d4cfe7927
8
Dockerfile
Normal file
8
Dockerfile
Normal file
|
@ -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
|
24
Makefile
Normal file
24
Makefile
Normal file
|
@ -0,0 +1,24 @@
|
|||
all: copy_environment_settings build db_up sleep migrate bootstrap
|
||||
|
||||
copy_environment_settings:
|
||||
cp src/bornhack/dev_environment_settings.py src/bornhack/environment_settings.py
|
||||
|
||||
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
|
||||
|
||||
run: db_up web_up
|
28
README.md
28
README.md
|
@ -4,7 +4,19 @@ 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
|
||||
|
||||
This will create everything. You can now start the project running:
|
||||
|
||||
$ make run
|
||||
|
||||
### Manual way
|
||||
|
||||
#### Clone the repo
|
||||
Clone with --recursive to include submodules:
|
||||
|
||||
git clone --recursive https://github.com/bornhack/bornhack-website
|
||||
|
@ -13,14 +25,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
|
||||
|
@ -35,13 +47,13 @@ Install system dependencies (method depends on OS):
|
|||
- Debian: ?
|
||||
- FreeBSD: x11-fonts/webfonts
|
||||
|
||||
### Python packages
|
||||
#### Python packages
|
||||
Install pip packages:
|
||||
```
|
||||
(venv) $ pip install -r src/requirements.txt
|
||||
```
|
||||
|
||||
### Configuration file
|
||||
#### Configuration file
|
||||
Copy environment settings file and change settings as needed:
|
||||
```
|
||||
(venv) $ cp src/bornhack/environment_settings.py.dist src/bornhack/environment_settings.py
|
||||
|
@ -50,7 +62,7 @@ Copy environment settings file and change settings as needed:
|
|||
Edit the configuration file, replacing all the ``{{ placeholder }}`` patterns
|
||||
(intended for Ansible).
|
||||
|
||||
### Database
|
||||
#### Database
|
||||
Is this a new installation? Initialize the database:
|
||||
```
|
||||
(venv) $ src/manage.py migrate
|
||||
|
@ -61,7 +73,7 @@ Is this for local development? Bootstrap the database with dummy data and users:
|
|||
(venv) $ src/manage.py bootstrap-devsite
|
||||
```
|
||||
|
||||
### Deploy camps+program test data
|
||||
#### Deploy camps+program test data
|
||||
|
||||
Run this command to create a bunch of nice test data:
|
||||
|
||||
|
@ -70,7 +82,7 @@ Run this command to create a bunch of nice test data:
|
|||
```
|
||||
|
||||
|
||||
### Done
|
||||
#### Done
|
||||
Is this for local development? Start the Django devserver:
|
||||
```
|
||||
(venv) $ src/manage.py runserver
|
||||
|
|
19
docker-compose.yml
Normal file
19
docker-compose.yml
Normal file
|
@ -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
|
22
src/bornhack/dev_environment_settings.py
Normal file
22
src/bornhack/dev_environment_settings.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
# This file is intended for easing the creation of a local development setup
|
||||
SECRET_KEY = "something-very-random"
|
||||
ALLOWED_HOSTS = "*"
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'bornhack',
|
||||
'USER': 'bornhack',
|
||||
'PASSWORD': 'bornhack',
|
||||
'HOST': 'db',
|
||||
},
|
||||
}
|
||||
DEBUG=True
|
||||
WKHTMLTOPDF_CMD="wkhtmltopdf"
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "asgiref.inmemory.ChannelLayer",
|
||||
"ROUTING": "bornhack.routing.channel_routing",
|
||||
"CONFIG": {}
|
||||
},
|
||||
}
|
||||
CAMP_REDIRECT_PERCENT=40
|
|
@ -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 }}'
|
||||
|
|
Loading…
Reference in a new issue