@@ 31,10 31,8 @@ server.
Then, you need to clone the damn deploy repository:
-```
-git clone https://git.sr.ht/~qeef/damn-deploy
-cd damn-deploy
-```
+ git clone https://git.sr.ht/~qeef/damn-deploy
+ cd damn-deploy
The most common usecase is *autostart server and clients*. The following
sections consider *server* setup, setup for *clients* (client and manager),
@@ 66,16 64,12 @@ Server setup
3. Create `acme.json` file and set `600` permissions:
- ```
- touch acme.json
- chmod 600 acme.json
- ```
+ touch acme.json
+ chmod 600 acme.json
4. You may run the damn server now.
- ```
- docker-compose -f server.yml up
- ```
+ docker-compose -f server.yml up
Setup for clients
-----------------
@@ 102,9 96,7 @@ In addition to *Server setup*, you may want to run a client and a manager, too.
2. You may run the damn server with clients now.
- ```
- docker-compose -f server.yml -f clients.yml up
- ```
+ docker-compose -f server.yml -f clients.yml up
Setup for chat
--------------
@@ 117,15 109,11 @@ In addition to *Server setup*, you may want to run a chat server.
2. Run the chat server with the server:
- ```
- docker-compose -f server.yml -f chat.yml up
- ```
+ docker-compose -f server.yml -f chat.yml up
or also with clients:
- ```
- docker-compose -f server.yml -f clients.yml -f chat.yml up
- ```
+ docker-compose -f server.yml -f clients.yml -f chat.yml up
Autostart with `systemd`
------------------------
@@ 134,31 122,27 @@ I assume that the damn deploy repository is cloned to `/root/damn-deploy/`.
1. Create systemd unit for `docker-compose`:
- ```
- cat << EOF >> /etc/systemd/system/damn.service
- [Unit]
- Description=Damn server app
- After=network.target docker.service
+ cat << EOF >> /etc/systemd/system/damn.service
+ [Unit]
+ Description=Damn server app
+ After=network.target docker.service
- [Service]
- Type=simple
- WorkingDirectory=/root/damn-deploy
- ExecStart=/usr/bin/docker-compose -f /root/damn-deploy/server.yml -f /root/damn-deploy/clients.yml up
- ExecStop=/usr/bin/docker-compose -f /root/damn-deploy/server.yml -f /root/damn-deploy/clients.yml down
+ [Service]
+ Type=simple
+ WorkingDirectory=/root/damn-deploy
+ ExecStart=/usr/bin/docker-compose -f /root/damn-deploy/server.yml -f /root/damn-deploy/clients.yml up
+ ExecStop=/usr/bin/docker-compose -f /root/damn-deploy/server.yml -f /root/damn-deploy/clients.yml down
- [Install]
- WantedBy=multi-user.target
- EOF
- ```
+ [Install]
+ WantedBy=multi-user.target
+ EOF
Remove ` -f /root/damn-deploy/clients.yml` when running server only.
2. Enable and run damn service:
- ```
- systemctl start damn.service
- systemctl enable damn.service
- ```
+ systemctl start damn.service
+ systemctl enable damn.service
How to update
@@ 166,43 150,31 @@ How to update
1. If use `systemd` autostart, stop the damn service first:
- ```
- systemctl stop damn.service
- ```
+ systemctl stop damn.service
2. Stash the configuration:
- ```
- git stash
- ```
+ git stash
3. Pull new version of the damn deploy repository:
- ```
- git pull
- ```
+ git pull
4. Pop stashed changes (renew the configuration):
- ```
- git stash pop
- ```
+ git stash pop
5. Maybe rebuild some docker images, but it depends on update changes:
- ```
- docker-compose -f server.yml build --no-cache api
- docker-compose -f server.yml build --no-cache upkeep
- docker-compose -f clients.yml build --no-cache client
- docker-compose -f clients.yml build --no-cache manager
- docker-compose -f chat.yml build --no-cache chat
- ```
+ docker-compose -f server.yml build --no-cache api
+ docker-compose -f server.yml build --no-cache upkeep
+ docker-compose -f clients.yml build --no-cache client
+ docker-compose -f clients.yml build --no-cache manager
+ docker-compose -f chat.yml build --no-cache chat
6. Start the damn service again:
- ```
- systemctl start damn.service
- ```
+ systemctl start damn.service
Update database structure
-------------------------
@@ 222,39 194,29 @@ Upgrade to `v0.6.0`
Stop the damn service and update the repository:
-```
-systemctl stop damn.service
-git stash
-git pull
-git stash pop
-```
+ systemctl stop damn.service
+ git stash
+ git pull
+ git stash pop
Run the database:
-```
-docker-compose up -d db
-```
+ docker-compose up -d db
Run the database upgrade script (you will be asked for the password stored in
`.env` file):
-```
-export DB_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' damndb)
-psql -h $DB_HOST -d damndb -U damnuser < damndb/71_areas_squares_stats.sql
-```
+ export DB_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' damndb)
+ psql -h $DB_HOST -d damndb -U damnuser < damndb/71_areas_squares_stats.sql
Stop the database container:
-```
-docker-compose down
-```
+ docker-compose down
Finally, there is no need to build the database container again. The database
is created only once anyway, so run the damn service again:
-```
-systemctl start damn.service
-```
+ systemctl start damn.service
Upgrade to `v0.7.0`
-------------------
@@ 262,16 224,12 @@ Upgrade to `v0.7.0`
When the upgrade is finished, update the `current_commits` in the database.
Connect to the database (the password is in `.env` file):
-```
-export DB_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' damndb)
-psql -h $DB_HOST -d damndb -U damnuser
-```
+ export DB_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' damndb)
+ psql -h $DB_HOST -d damndb -U damnuser
Run update query:
-```
-update current_commits set type='splitted' where message='The square was splitted';
-```
+ update current_commits set type='splitted' where message='The square was splitted';
Damn upkeep
@@ 285,32 243,28 @@ hours.
1. Create systemd unit and timer for damn upkeep:
- ```
- cat << EOF >> /etc/systemd/system/damn_upkeep.service
- [Unit]
- Description=Run damn upkeep
+ cat << EOF >> /etc/systemd/system/damn_upkeep.service
+ [Unit]
+ Description=Run damn upkeep
- [Service]
- WorkingDirectory=/root/damn-deploy
- ExecStart=/usr/bin/docker-compose -f /root/damn-deploy/server.yml run --rm upkeep
- EOF
- cat << EOF >> /etc/systemd/system/damn_upkeep.timer
- [Unit]
- Description=Run damn upkeep every 15 minutes
+ [Service]
+ WorkingDirectory=/root/damn-deploy
+ ExecStart=/usr/bin/docker-compose -f /root/damn-deploy/server.yml run --rm upkeep
+ EOF
+ cat << EOF >> /etc/systemd/system/damn_upkeep.timer
+ [Unit]
+ Description=Run damn upkeep every 15 minutes
- [Timer]
- OnCalendar=*:0/15
+ [Timer]
+ OnCalendar=*:0/15
- [Install]
- WantedBy=timers.target
- EOF
- ```
+ [Install]
+ WantedBy=timers.target
+ EOF
2. Enable and run damn upkeep service and timer:
- ```
- systemctl enable damn_upkeep.timer
- systemctl enable damn_upkeep.service
+ systemctl enable damn_upkeep.timer
+ systemctl enable damn_upkeep.service
- systemctl start damn_upkeep.timer
- ```
+ systemctl start damn_upkeep.timer