docs.coopcloud.tech/docs/x-archive/deploy.md

146 lines
5.5 KiB
Markdown
Raw Normal View History

2021-02-18 10:28:09 +00:00
---
title: Deploy your first app
2021-02-18 10:28:09 +00:00
---
In order to deploy an app you need two things:
2021-02-23 21:51:55 +00:00
1. a server (e.g. [Hetzner VPS](https://www.hetzner.com/cloud)), with
- SSH access
- a public IP address
2021-02-23 21:51:55 +00:00
2. a DNS provider (e.g. [Gandi](https://www.gandi.net/en))
## Create your server
2021-06-12 18:55:42 +00:00
Co-op Cloud has itself near zero system requirements. You only need to worry about the system resource usage of your apps and the overhead of running containers with the docker runtime (often negligible. If you want to know more, see [this FAQ entry](/faq/#isnt-running-everything-in-containers-inefficient)). We will deploy a new Nextcloud instance in this guide, so you will only need 1GB of RAM according to [their documentation](https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html). You may also be interested in this [FAQ entry](/faq/#arent-containers-horrible-from-a-security-perspective) if you are curious about security in the context of containers.
2021-02-23 21:51:55 +00:00
## Wire up your DNS
Typically, you'll need two A records, one to point to the VPS itself and another to support sub-domains for the apps. You can then support an app hosted on your root domain (e.g. `example.com`) and other apps on sub-domains (e.g. `foo.example.com`, `bar.example.com`). Your entries in your DNS provider setup might look like the following.
@ 1800 IN A 116.203.211.204
*. 1800 IN A 116.203.211.204
2021-03-01 10:23:28 +00:00
Where `116.203.211.204` can be replaced with the IP address of your server.
2021-02-23 21:51:55 +00:00
## Install server prerequisites
You'll want to install [Docker](https://www.docker.com/) on your server. This can be done by following the [install documentation](https://docs.docker.com/engine/install/).
2021-03-02 06:34:59 +00:00
## Bootstrap `abra`
2021-02-23 21:51:55 +00:00
Once your DNS and docker daemon are up, you can install [`abra`](https://git.coopcloud.tech/coop-cloud/abra) locally on your developer machine and hook it up to your server.
2021-02-23 21:51:55 +00:00
Firstly, install `abra` locally.
```bash
curl https://install.abra.autonomic.zone | bash
2021-02-23 21:51:55 +00:00
```
The source for this script [is here](https://git.coopcloud.tech/coop-cloud/abra/src/branch/main/scripts/installer/installer).
2021-02-23 21:51:55 +00:00
2021-10-26 10:59:51 +00:00
the installer will verify the checksum. If you want to download abra yourself, you can grab it from the [releases page](https://git.coopcloud.tech/coop-cloud/abra/releases) along with the checksums.txt file. If you decide to do this, please run:
```bash
grep $(sha256sum abra_[version]_[platform]) checksums.txt > /dev/null && echo "checksum OK"
```
if "checksum OK" appears in your terminal - you're good to go! otherwise, you have downloaded a corrupted file.
2021-02-23 21:51:55 +00:00
You may need to add the `~/.local/bin/` directory with your `$PATH` in order to run the executable.
```bash
export PATH=$PATH:$HOME/.local/bin
abra -h # check it works
2021-02-23 21:51:55 +00:00
```
Now you can connect `abra` with your new server.
```bash
abra server add example.com
2021-02-23 21:51:55 +00:00
```
2021-03-01 11:43:40 +00:00
Where `example.com` is replaced with your server DNS name.
2021-02-23 21:51:55 +00:00
!!! note "About SSH"
`abra` uses Docker's built-in SSH support to make a secure connection to a
remote Docker daemon, to deploy and manage apps from your local development
machine.
2021-03-01 11:44:21 +00:00
If you need to specify a non-standard port, and/or different username, for SSH,
add them as extra arguments:
2021-02-23 21:51:55 +00:00
```bash
2021-11-13 19:46:52 +00:00
abra server add -p example.com username 2222
```
2021-02-23 21:51:55 +00:00
2021-11-13 19:46:52 +00:00
The `-p` or `--provision` flag means that abra will initialise the [new single-host swarm](https://docs.docker.com/engine/swarm/key-concepts/) on your server.
2021-02-23 21:51:55 +00:00
You will now have a new `~/.abra/` folder on your local file system which stores all the configuration of your Co-op Cloud instance. You can easily share this as a git repository with others.
## Deploy Traefik
In order to have your Co-op cloud installation automagically provision SSL certificates, we will first install [Traefik](https://doc.traefik.io/traefik/). This tool is the main entrypoint for all web requests (e.g. like NGINX) and supports automatic SSL certificate configuration and other quality-of-life features which make deploying libre apps more enjoyable.
```bash
abra app new traefik
2021-03-01 11:31:24 +00:00
```
You will want to take a look at your generated configuration and tweak the `LETS_ENCRYPT_EMAIL` value:
```bash
abra app config traefik
2021-03-01 11:31:24 +00:00
```
Every app you deploy will have one of these `.env` files, which contains variables which will be injected into app configurations when deployed. Variables starting with `#` are optional, others are required.
2021-03-01 11:31:24 +00:00
```
abra app deploy traefik
2021-03-01 11:31:24 +00:00
```
2021-02-23 22:03:41 +00:00
## Deploy Nextcloud
2021-02-23 21:51:55 +00:00
2021-03-01 11:31:24 +00:00
And now we can deploy apps.
Let's create a new Nextcloud app.
2021-02-23 21:51:55 +00:00
```bash
abra app new nextcloud
2021-03-01 11:31:24 +00:00
```
And we need to generate secrets for the app: database connection password, root password and admin password.
2021-03-01 11:31:24 +00:00
```bash
abra app secret generate --all nextcloud
```
2021-03-01 11:48:06 +00:00
!!! warning
Take care, these secrets are only shown once on the terminal so make sure
to take note of them! `abra` makes use of the [Docker secrets](/secrets/)
mechanism to ship these secrets securely to the server and store them as
encrypted data.
2021-03-01 11:31:24 +00:00
Then we can deploy the Nextcloud.
```bash
abra app deploy nextcloud
2021-03-01 11:31:24 +00:00
```
We can watch to see that things come up correctly.
2021-03-01 11:31:24 +00:00
```bash
abra app ps nextcloud # status check
abra app logs nextcloud # logs watch
2021-03-01 11:31:24 +00:00
```
!!! note
2021-03-02 06:31:52 +00:00
Since Nextcloud takes some time to come up live, you can run the `ps`
command under `watch` like so.
2021-03-01 11:31:24 +00:00
```bash
watch abra app ps nextcloud
2021-03-01 11:31:24 +00:00
```
And you can wait until you see that all containers have the "Running" state.
2021-03-02 06:31:52 +00:00
Your `traefik` instance will detect that a new app is coming up and generate SSL certificates for it.