A referendum presentation website.
It is built using Python on top of Django web framework and PostgreSQL database.
This assumes you have Python 3 installed. To run in default
configuration, you also need PostgreSQL server up and running on 5432
port. You
also need a database and user ready. Defaults are:
- Username:
nsnd
- Database:
nsnd
- Password:
nsnd
This can be changed by providing the DATABASE_DSN
environment variable.
-
Clone the repository and cd into it
git clone [email protected]:xaralis/nechcistadionnadluh.cz.git cd nechcistadionnadluh.cz
-
Initialize virtual environment and activate it
make init-env source .env/bin/activate
-
Install dependencies
make install-dev
-
Run the application
make run
This app has docker-compose support prepared out-of-the-box. This will also run PostgreSQL database in case you don't want to install it locally.
docker-compose up
First, make sure you have test dependencies installed. Run:
make install-test
From now on, you can run the test suite using:
make test
All config is made using environment variables.
Variable name | Description | Required | Default value |
---|---|---|---|
DEBUG |
Turns on debug mode if equal to '1'. Shall not be used in production. | No | None |
SECRET_KEY |
Key used for encryption. Provide a long random string value. | Yes if DEBUG is False |
None |
DATABASE_DSN |
Database connection string | No | postgresql://localhost:5432/nsnd |
This application is designed to be deployed as Docker container. Therefore, you can use your preferred orchestration tool like Kubernetes or Docker swarm.
Or, you can simply launch it using Docker compose for small-scale installations and/or testing purposes.
Docker images are continuosly pushed to the Docker Hub
xaralis/nechcistadionnadluh.cz. App is
exposed via NginX proxy at port 80
.
-
Create your docker-compose.yml file somewhere:
version: '3.4' services: db: image: postgres:9.6.10-alpine volumes: - dbdata:/var/lib/postgresql restart: always ports: - "55433:5432" environment: POSTGRES_USER: nsnd POSTGRES_PASS: nsnd POSTGRES_DB: nsnd website: build: context: . volumes: - ./nsnd:/nsnd/nsnd - media:/media - thumbnails:/thumbnails ports: - "8080:80" restart: always environment: DEBUG: 0 SECRET_KEY: "not-really-secret-key" DATABASE_DSN: postgresql://nsnd:nsnd@db:5432/nsnd ALLOWED_HOSTS: '*' MEDIA_ROOT: /media THUMBNAIL_CACHE_DIR: /thumbnails volumes: dbdata: media: thumbnails:
-
Run both the database and the application by a simple
up
command:docker-compose up -d
-
Run migrations (in case there are some DB schema changes):
docker-compose exec --user nsnd website sh -c "django-admin migrate"
Note: You can easily update the app by the image tag in the compose file. Make sure to re-run migrations when updating.
You can easily run it using docker exec
. Just make sure you're running it under nsnd
user. Otherwise,
things will break.
docker-compose exec --user nsnd website django-admin migrate