You can choose to use Docker to get the development environment up and running. If you wanna go for Docker, install Docker and docker-compose.
When you have docker and docker-compose installed and working. Start the project by:
docker-compose up
Docker will build everything for you and you can access the page from http://localhost:8000/ when the build process is done.
To be able to login at http://localhost:8000/admin , enter the docker env and then create a superuser.
docker exec -it koddjango bash
python manage.py createsuperuser # Create a superuser
Only if you really know what you are doing, unless, use Docker.
pip install -r requirements.txt # Install dependencies
mkdir logs # Create a folder for logs
cd kodkollektivet/ # Go into the project
python manage.py makemigrations # Make a migration scheme
python manage.py migrate # Create a DB with the scheme
python manage.py createsuperuser # Create a superuser
python manage.py makemessages -l en -l sv
python manage.py compilemessages -l sv -l en
python manage.py runserver # Start development server
Django provides a managment backend by default. Visit is on 127.0.0.1:8000/admin
Styling is done with compass + neat. (stand-alone) To write your sass changes to main.css do:
# First install ruby if needed
gem install compass neat-compass # Then we install compass + neat plugin
cd kodkollektivet/static/css/compass # Go to folder with compass config file
compass watch # Tell compass to watch for changes and write them to main.css
This part will give instructions on how to setup kodkollektivet.se on a new host. Some of the stuff needs correct DNS settings to work, those are stuff like Lets Encrypt (SSL/TLS/HTTPS).
To setup the server we are using Ansible, to deploy the project and updates we are using Fabric.
Start a new Debian (yes it must be Debian) server somewhere. I mostly use digitalocean. Log in to the server via SSH and make sure that you can login with password as root. This is needed for Ansible to work. When you are sure that you can login to the root account with a password. Logout.
Navigate to the secrets folder within the project directory. Take a look at the files
and what they contains. Generate a new SSH key. Move the public key to ansible users
filder. This key will be used for deploy. If it asks you to overwrite the existing
file, choose y
. Dont enter a passphrase.
cd kodkollektivet.se/ansible/secrets ssh-keygen -t ed25519 -f kodkollektivetse-deploy-user -C kodkollektivetse-deploy-user cp kodkollektivetse-deploy-user.pub ../roles/users/files/authorized_keys
We are doing this steps so that we later on can put new code on the server via the “kodkollektivetse-deploy-user” user and do that without a password.
In secrets/inventory
you shall now update some secrets.
ansible_ssh_host | The IP address to reflect your host. |
ansible_ssh_pass | The root password |
ansible_port | 22 is the default, but could be changed on your host |
In secrets/production.json
change:
Your email | |
deploy -> password | To a good random password |
postgres -> pass | To a good random password |
To configure the server run:
cd kodkollektivet.se/ansible
docker build -t kodans:0.1 -f Dockerfile-ansible .
docker run -it -v $PWD:/app --rm -w /app kodans:0.1 ansible-playbook -e @secrets/production.json kodkollektivetse.yml
This will put the project to the server and start the services.
cd kodkollektivet.se/ansible
docker build -t kodfab:0.1 -f Dockerfile-fabric .
docker run -it -v $PWD:/app --rm -w /app kodfab:0.1 fab bootstrap
Ask John for secret files.
The secret files contains usernames passwords and that kind of stuff.
cd ansible/
docker build -t kodfab:0.1 -f Dockerfile-fabric .
docker run -it -v $PWD:/app --rm -w /app kodfab:0.1 fab deploy
Afer this commands have run with succcess the application will restart itself with the new updates. You dont need to do anything else.
Added here as a note! Maybe we should have a page for publications?