Coder Social home page Coder Social logo

xaralis / nechcistadionnadluh.cz Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 1.63 MB

Website for the referendum about football stadium in Pardubice

License: GNU Affero General Public License v3.0

Makefile 1.52% JavaScript 6.06% CSS 17.72% Shell 0.89% Python 29.50% HTML 40.71% Dockerfile 3.60%

nechcistadionnadluh.cz's Introduction

NechciStadionNaDluh.cz

A referendum presentation website.

It is built using Python on top of Django web framework and PostgreSQL database.

Development

Local installation

Prerequistes

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.

Installation

  1. Clone the repository and cd into it

     git clone [email protected]:xaralis/nechcistadionnadluh.cz.git
     cd nechcistadionnadluh.cz
    
  2. Initialize virtual environment and activate it

     make init-env
     source .env/bin/activate
    
  3. Install dependencies

     make install-dev
    
  4. Run the application

     make run
    

Local installation using Docker

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

Running tests

First, make sure you have test dependencies installed. Run:

make install-test

From now on, you can run the test suite using:

make test

Configuration

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

Production deployment

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.

  1. 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:
    
  2. Run both the database and the application by a simple up command:

     docker-compose up -d
    
  3. 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.

Running django commands in the container

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

nechcistadionnadluh.cz's People

Contributors

xaralis avatar bbbecka avatar dependabot[bot] avatar

Watchers

 avatar James Cloos avatar

Forkers

bbbecka

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.