Kodkollektivet / kodkollektivet.se

kodkollektivet.se
3 stars 7 forks source link

+TITLE: kodkollektivet.se

+AUTHOR: kodkollektivet

[[https://travis-ci.org/Kodkollektivet/kodkollektivet.se][https://travis-ci.org/Kodkollektivet/kodkollektivet.se.svg?branch=master]]

** Start a new server

Start a new Debian (yes it must be Debian) server somewhere. I mostly use [[https://www.digitalocean.com/][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.

** Generate SSH key

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.

+BEGIN_SRC

 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

+END_SRC

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.

** Update secrets

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:

| email | Your email | | deploy -> password | To a good random password | | postgres -> pass | To a good random password |

** Configure the server

To configure the server run:

+BEGIN_SRC sh

 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

+END_SRC

** Bootstrap the kodkollektivet.se application

This will put the project to the server and start the services.

+BEGIN_SRC sh

 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

+END_SRC

Added here as a note! Maybe we should have a page for publications?