standard-procedure-anvil 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +16 -82
- data/assets/cloudinit/redis.yml +4 -1
- data/checksums/standard-procedure-anvil-0.2.1.gem.sha512 +1 -0
- data/docs/app.md +51 -0
- data/docs/cloudinit.md +33 -0
- data/docs/configuration.md +7 -0
- data/docs/roadmap.md +12 -0
- data/docs/ruby-on-rails.md +69 -0
- data/docs/secrets.md +20 -0
- data/docs/why.md +17 -0
- data/lib/anvil/app/host_deployer.rb +2 -0
- data/lib/anvil/app/host_installer.rb +1 -0
- data/lib/anvil/version.rb +1 -1
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7330f81fa4611c93e7bd6424be609a05da36a04e0372c8401fdc58a3e1b09afb
|
4
|
+
data.tar.gz: 7f19466d160effbd3050ae33d1273487ccfd55e87f22575b75e578b6c3798b17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e0c452fab0076406770c3cff17458451cfe4ff58ae69e4fdc456b474f38cd1b7f9a5cf8cd3f619b0f6be8ac426e3ee7b618992b6f91de3a6400fa4d849363c4
|
7
|
+
data.tar.gz: b42162b6f694f90d4ab33b4734dbdfa465fd506998ddf687ec49b48142dd590021ad1af37d3518cc781415ff77585f7979449dc4f4a6754ca5fb9e152090163a
|
data/CHANGELOG.md
CHANGED
@@ -3,3 +3,17 @@
|
|
3
3
|
## [0.1.0] - 2023-06-19
|
4
4
|
|
5
5
|
- Initial release
|
6
|
+
|
7
|
+
## [0.2.0] - 2023-07-05
|
8
|
+
|
9
|
+
- It works for me
|
10
|
+
Successfully deployed a number of apps into production using this
|
11
|
+
|
12
|
+
## [0.2.1] - 2023-07-06
|
13
|
+
|
14
|
+
- Corrected dokku proxy SSL settings
|
15
|
+
- Tidy up of various bits of code and configuration
|
16
|
+
|
17
|
+
## [0.2.2] - 2023-08-14
|
18
|
+
|
19
|
+
- Updated the redis cloudinit file to use the latest version from Redis, instead of the older one that is included with Ubuntu.
|
data/README.md
CHANGED
@@ -2,110 +2,44 @@
|
|
2
2
|
|
3
3
|
Some simple scripts for installing [Dokku](https://dokku.com) applications on Ubuntu servers.
|
4
4
|
|
5
|
+
## Why does this exist?
|
6
|
+
|
7
|
+
I needed a tool to [simplify the management](/docs/why.md) of my many dokku-deployed Ruby on Rails apps.
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
11
|
+
Anvil requires Ruby 2.7 or newer, as it uses ConcurrentRuby to handle doing more than one thing at once.
|
12
|
+
|
7
13
|
```ruby
|
8
14
|
gem install standard-procedure-anvil
|
9
15
|
```
|
10
16
|
|
11
17
|
## Usage
|
12
18
|
|
13
|
-
###
|
19
|
+
### Build a server
|
14
20
|
|
15
21
|
Ultimately the plan is to use [Fog](https://github.com/fog/fog) to handle building servers.
|
16
22
|
|
17
23
|
But until then, you can prepare your servers using [CloudInit](https://cloudinit.readthedocs.io/en/latest/)
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
So firstly we ask Anvil which cloudinit configurations it has available:
|
22
|
-
|
23
|
-
```sh
|
24
|
-
anvil cloudinit list
|
25
|
-
```
|
26
|
-
|
27
|
-
This will give us a list of prewritten cloud init scripts - of which dokku is probably the one we're most interested in.
|
28
|
-
|
29
|
-
Next we tell anvil to generate our configuration:
|
30
|
-
|
31
|
-
```sh
|
32
|
-
anvil cloudinit generate dokku --user app --public-key ~/.ssh/my_key.pub > ~/Desktop/my_server.yml
|
33
|
-
```
|
34
|
-
|
35
|
-
Anvil generates a dokku configuration (and places it on our desktop) that will create an Ubuntu 22.04 box with docker and dokku preinstalled. Plus it will create a user called `app` that can log in through SSH using a public key `my_key.pub`. The server itself is locked down so only ports 80, 443 and 22 are open, only the users `app` and `dokku` are allowed to log in and they must use public/private key encryption - no passwords allowed.
|
36
|
-
|
37
|
-
To test this, it's worth taking a look at [Multipass](https://multipass.run) - a tool from Canonical that lets you create virtual machines (using cloud init files) on your local machine - meaning you can try out various configurations without spending money at a hosting company.
|
38
|
-
|
39
|
-
Once you've built a preconfigured virtual machine, we can move on to getting our dokku application installed.
|
40
|
-
|
41
|
-
### Installing an application onto the server
|
42
|
-
|
43
|
-
Move to your application's root folder and create the deploy.yml file (see below). Then use the `app install` command to set dokku up for your first deployment.
|
44
|
-
|
45
|
-
```sh
|
46
|
-
anvil app install
|
47
|
-
```
|
48
|
-
|
49
|
-
This will SSH into the server (or servers if you have multiple) from your config file and:
|
50
|
-
|
51
|
-
- Installs any dokku plugins that you have specified
|
52
|
-
- Tells dokku to create the app
|
53
|
-
- Uses your config file to set the environment variables for the app
|
54
|
-
- Sets some sensible defaults for Nginx and makes sure it proxies correctly to your app
|
55
|
-
- Optionally forwards the correct SSL/TLS headers if your app is behind a load-balancer
|
56
|
-
- Finally it runs the post-installation scripts from your config file, which you can use to configure your plugins
|
25
|
+
[Generating a cloudinit file](/docs/cloudinit.md) with `anvil cloudinit generate`
|
57
26
|
|
58
|
-
|
27
|
+
### Install and deploy
|
59
28
|
|
60
|
-
|
61
|
-
anvil app deploy
|
62
|
-
```
|
63
|
-
As this is the first deployment, anvil will create git remotes for each host, then do the initial git push. If you have multiple servers configured, these should run in parallel (coming soon). Once each deployment has completed, anvil will SSH in, scale your app and run the post-first-deployment scripts.
|
64
|
-
|
65
|
-
You can then use the same `anvil app deploy` command to deploy the app again - but as it knows this isn't the first deployment (as it does not need to create the git remotes), it will run your post-deployment scripts (not post-first-deployment) each time.
|
66
|
-
|
67
|
-
To change the number of processes (as defined by your Procfile), you can set the `scale` key(s) in your config file and then call:
|
68
|
-
|
69
|
-
```sh
|
70
|
-
anvil app scale
|
71
|
-
```
|
72
|
-
|
73
|
-
(COMING SOON)
|
74
|
-
Finally, if you need to change the values of any environment variables, update your config file and use:
|
75
|
-
|
76
|
-
```sh
|
77
|
-
anvil app configure
|
78
|
-
```
|
79
|
-
|
80
|
-
### Configuration Files
|
81
|
-
|
82
|
-
An Anvil configuration file specifies the configuration for multiple servers and multiple apps. Each server is configured, then each app is installed onto each server.
|
29
|
+
Use the `anvil app install` and `anvil app deploy` commands to [install and deploy](/docs/app.md) your app to your server.
|
83
30
|
|
84
|
-
|
31
|
+
### Manage and reconfigure
|
85
32
|
|
86
|
-
|
33
|
+
Use `anvil app scale` and `anvil app reconfigure` to manage and reconfigure your app. (Docs coming soon)
|
87
34
|
|
88
|
-
|
35
|
+
### Ruby on Rails
|
89
36
|
|
90
|
-
|
91
|
-
|
92
|
-
The secrets are just extra environment variables that are added to the ones defined in your config file - in the format:
|
93
|
-
|
94
|
-
```
|
95
|
-
SECRET1=VALUE1 SECRET2=VALUE2
|
96
|
-
```
|
97
|
-
|
98
|
-
You can either specify `--secrets my-secrets-file.env` to load these from a separate file. Or you can load them from stdin.
|
99
|
-
|
100
|
-
For example, I use [Bitwarden](https://bitwarden.com) as my password locker and use the Bitwarden CLI to access my secrets. The CLI is installed through homebrew, I then authenticate and can use a command like:
|
101
|
-
|
102
|
-
```sh
|
103
|
-
bw get notes secrets@myapp.com | anvil app install deploy.myapp.yml -S
|
104
|
-
```
|
105
|
-
I have the environment variables for myapp.com stored in Bitwarden as a secure note with the title "secrets@myapp.com". So `bw get notes secrets@myapp.com` loads them from my vault and pipes them to the `anvil app install` command. The anvil command is using the `-S` (or `--secrets-stdin`) option which means it will read the information piped in by bitwarden. So, once decrypted, the confidential data never touches a disk until it gets written into the dokku app configuration on the server.
|
37
|
+
I'm a Rails developer and I built anvil to help me with my Rails apps. Here are [some things I learnt along the way](/docs/ruby-on-rails.md).
|
106
38
|
|
107
39
|
## Contributing
|
108
40
|
|
41
|
+
Check out the [Roadmap](/docs/roadmap.md)
|
42
|
+
|
109
43
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/standard-procedure-anvil.
|
110
44
|
|
111
45
|
## License
|
data/assets/cloudinit/redis.yml
CHANGED
@@ -34,11 +34,14 @@ runcmd:
|
|
34
34
|
- sed -i -e '/^\(#\|\)AuthorizedKeysFile/s/^.*$/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config
|
35
35
|
- sed -i '$a AllowUsers %{USER}' /etc/ssh/sshd_config
|
36
36
|
# Set up Redis
|
37
|
+
- curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
|
38
|
+
- echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list
|
39
|
+
- apt-get update
|
37
40
|
- apt-get -y install redis-server
|
38
41
|
- sed -i 's/supervised no/supervised systemd/g' /etc/redis/redis.conf
|
39
42
|
- sed -i 's/bind 127.0.0.1 ::1/# bind 127.0.0.1 ::1/g' /etc/redis/redis.conf
|
40
43
|
- sed -i 's/protected-mode yes/protected-mode no/g' /etc/redis/redis.conf
|
41
|
-
- systemctl restart redis.service
|
44
|
+
- systemctl restart redis-server.service
|
42
45
|
- |
|
43
46
|
cat > /etc/logrotate.d/redis-server << EOF
|
44
47
|
/var/log/redis/redis-server*.log {
|
@@ -0,0 +1 @@
|
|
1
|
+
2b56322e96127aa43986eaa2de436eafd64c7d5260d61db1a13605d95bf0fc3b331f006c0b534d845c05e781659518f37d3f8aa17475e6e926675d5ea1985a50
|
data/docs/app.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# The `app` command
|
2
|
+
|
3
|
+
## Installing an application
|
4
|
+
|
5
|
+
Move to your application's root folder and create the deploy.yml file (see below). Then use the `app install` command to set dokku up for your first deployment.
|
6
|
+
|
7
|
+
```sh
|
8
|
+
anvil app install
|
9
|
+
```
|
10
|
+
|
11
|
+
This will SSH into the server (or servers if you have multiple) from your config file and:
|
12
|
+
|
13
|
+
- Installs any dokku plugins that you have specified
|
14
|
+
- Tells dokku to create the app
|
15
|
+
- Uses your config file to set the environment variables for the app
|
16
|
+
- Sets some sensible defaults for Nginx and makes sure it proxies correctly to your app
|
17
|
+
- Optionally forwards the correct SSL/TLS headers if your app is behind a load-balancer
|
18
|
+
- Finally it runs the post-installation scripts from your config file, which you can use to configure your plugins
|
19
|
+
|
20
|
+
## Deploying an application
|
21
|
+
|
22
|
+
Next up we deploy the app.
|
23
|
+
|
24
|
+
```sh
|
25
|
+
anvil app deploy
|
26
|
+
```
|
27
|
+
As this is the first deployment, anvil will create git remotes for each host, then do the initial git push. If you have multiple servers configured, these should run in parallel (coming soon). Once each deployment has completed, anvil will SSH in, scale your app and run the post-first-deployment scripts.
|
28
|
+
|
29
|
+
You can then use the same `anvil app deploy` command to deploy the app again - but as it knows this isn't the first deployment (as it does not need to create the git remotes), it will run your post-deployment scripts (not post-first-deployment) each time.
|
30
|
+
|
31
|
+
To change the number of processes (as defined by your Procfile), you can set the `scale` key(s) in your config file and then call:
|
32
|
+
|
33
|
+
```sh
|
34
|
+
anvil app scale
|
35
|
+
```
|
36
|
+
|
37
|
+
(COMING SOON)
|
38
|
+
Finally, if you need to change the values of any environment variables, update your config file and use:
|
39
|
+
|
40
|
+
```sh
|
41
|
+
anvil app configure
|
42
|
+
```
|
43
|
+
|
44
|
+
## Configuration files
|
45
|
+
|
46
|
+
The [anvil configuration file](/docs/configuration.md) is the heart of the system.
|
47
|
+
|
48
|
+
## Secrets
|
49
|
+
|
50
|
+
You don't want to store your secrets (passwords, encryption keys) in your anvil configuration. Instead anvil can [read your secrets](/docs/secrets.md) from a separate file or from the command line.
|
51
|
+
|
data/docs/cloudinit.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Building a server
|
2
|
+
|
3
|
+
## Cloudinit
|
4
|
+
|
5
|
+
A [CloudInit](https://cloudinit.readthedocs.io/en/latest/) file is a YML file that you load into a virtual machine while it is being created. As the server boots, uses the cloudinit configuration to install software and set itself up. With most cloud hosting providers, you will find an option for "user data", or something similar, on the "create a new server" page.
|
6
|
+
|
7
|
+
### Generate a configuration
|
8
|
+
|
9
|
+
So firstly we ask Anvil which cloudinit configurations it has available:
|
10
|
+
|
11
|
+
```sh
|
12
|
+
anvil cloudinit list
|
13
|
+
```
|
14
|
+
|
15
|
+
This will give us a list of prewritten cloud init scripts - of which dokku is probably the one we're most interested in.
|
16
|
+
|
17
|
+
Next we tell anvil to generate our configuration:
|
18
|
+
|
19
|
+
```sh
|
20
|
+
anvil cloudinit generate dokku --user app --public-key ~/.ssh/my_key.pub > ~/Desktop/my_server.yml
|
21
|
+
```
|
22
|
+
|
23
|
+
Anvil generates a dokku configuration (and places it on our desktop) that will create an Ubuntu 22.04 box with docker and dokku preinstalled. Plus it will create a user called `app` that can log in through SSH using a public key `my_key.pub`. The server itself is locked down so only ports 80, 443 and 22 are open, only the users `app` and `dokku` are allowed to log in and they must use public/private key encryption - no passwords allowed.
|
24
|
+
|
25
|
+
### Testing your configuration
|
26
|
+
|
27
|
+
To test this, it's worth taking a look at [Multipass](https://multipass.run) - a tool from Canonical that lets you create virtual machines (using cloud init files) on your local machine. This means you can try out various configurations without spending money at a hosting company.
|
28
|
+
|
29
|
+
One thing to note when using multipass - it requires SSH access for a user called "ubuntu". So take your generated cloudinit file, locate the SSH configuration section and the "AllowUsers" line - and add the "ubuntu" user to it. Something like: ` - sed -i '$a AllowUsers %{USER} ubuntu dokku' /etc/ssh/sshd_config`.
|
30
|
+
|
31
|
+
Multipass has its own private key generated for the ubuntu user, and uses this to manage the server. Of course, the multipass VM is only on your machine, plus its private key is hidden away, so it's not a security risk. But in general `anvil cloudinit generate` disallows all SSH access apart from your named user (using your own key), and the `dokku` user if applicable.
|
32
|
+
|
33
|
+
Once you've built a preconfigured virtual machine, we can move on to getting our dokku application installed. However, note that it can take several minutes for the initialisation process to complete - so don't start your deployment too early, or your server won't be ready and will reboot whilst your setting things up.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Anvil configuration files
|
2
|
+
|
3
|
+
An Anvil configuration file specifies the configuration for multiple servers and multiple apps. Each server is configured, then each app is installed onto each server.
|
4
|
+
|
5
|
+
For now take a look at the two samples in the spec folder - [single-server](/spec/fixtures/single-server.config.yml) and [multi-server](/spec/fixtures/multi-server.config.yml).
|
6
|
+
|
7
|
+
Also check out the [tips for Ruby on Rails](/docs/ruby-on-rails.md) which has an example configuration file.
|
data/docs/roadmap.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Roadmap
|
2
|
+
|
3
|
+
As I mentioned, this is pretty much designed for my own use.
|
4
|
+
|
5
|
+
There are a few bits I still need (which will be V1) and then I want to open it up. But if it gets too generic, you might as well just write a load of shell scripts to manage dokku yourself - it's important to keep it simple.
|
6
|
+
|
7
|
+
## To do
|
8
|
+
|
9
|
+
- [ ] `app reconfigure`
|
10
|
+
- [ ] Add `--first`/`--not-first` options to `app deploy` so you can override the first-deployment behaviour (in case you get a failure and need to re-run everything)
|
11
|
+
- [ ] Instead of relying on the ssh-agent, allow the use of your private key when connecting to servers
|
12
|
+
- [ ] Parallel execution across multiple hosts
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Dokku and Ruby on Rails
|
2
|
+
|
3
|
+
(incomplete - coming soon)
|
4
|
+
|
5
|
+
- If using the Mysql plugin, use the Mysql2 protocol
|
6
|
+
- store your RAILS_MASTER_KEY and SECRET_KEY_BASE outside of your configuration file (see [secrets](/docs/secrets.md))
|
7
|
+
- in your config/environments/production.rb or config/environments/staging.rb set `config.force_ssl = false` - dokku's nginx configuration will do the redirect for you if you're using the Let's Encrypt plugin, or you can set the redirect on your load-balancer. Setting `config.force_ssl = true` causes issues with the health checks
|
8
|
+
- Make sure your app knows its hostname; set it as an environment variable in your configuration file and then use that hostname in your environment file as follows: `config.action_mailer.default_url_options = {host: ENV["HOSTNAME"]}` and `Rails.application.routes.default_url_options[:host] = config.action_mailer.default_url_options[:host]`. This means that when you need to generate a full URL (as opposed to a relative path), Rails knows what to use.
|
9
|
+
- Use a CHECKS file that looks like this (again using that HOSTNAME environment variable), so dokku's zero-deployment checks can connect correctly. My `/health_check` route just returns a `200 OK` in most apps, but in some it actually checks the database connection, as well as some other services (although this causes problems with the initial deployment, which is why checks are switched off the first time through)
|
10
|
+
```
|
11
|
+
WAIT=10
|
12
|
+
ATTEMPTS=5
|
13
|
+
http://{{ var "HOSTNAME" }}/health_check
|
14
|
+
```
|
15
|
+
|
16
|
+
A typical Rails deploy.yml for a single-server, totally self-contained app, looks like this:
|
17
|
+
|
18
|
+
```yaml
|
19
|
+
version: 0.1
|
20
|
+
hosts:
|
21
|
+
- myapp.example.com:
|
22
|
+
user: app
|
23
|
+
app:
|
24
|
+
domain: myapp.example.com
|
25
|
+
port: 3000
|
26
|
+
environment:
|
27
|
+
- BUNDLE_WITHOUT=test:development
|
28
|
+
- CABLE_CHANNEL_PREFIX=myapp
|
29
|
+
- EMAIL_DOMAIN=mail.myapp.example.com
|
30
|
+
- EMAIL_HOST=smtp.myapp.example.com
|
31
|
+
- EMAIL_PORT=587
|
32
|
+
- EMAIL_USER=postmaster@mail.myapp.example.com
|
33
|
+
- HOSTNAME=myapp.example.com
|
34
|
+
- NODE_ENV=production
|
35
|
+
- RACK_ENV=production
|
36
|
+
- RAILS_ENV=production
|
37
|
+
- RAILS_LOG_TO_STDOUT=true
|
38
|
+
- RAILS_MAX_THREADS=10
|
39
|
+
- RAILS_SERVE_STATIC_FILES=true
|
40
|
+
resource_limit: 2048m
|
41
|
+
scale: web=2 worker=1
|
42
|
+
load_balancer: false
|
43
|
+
nginx:
|
44
|
+
client_max_body_size: 512m
|
45
|
+
proxy_read_timeout: 60s
|
46
|
+
plugins:
|
47
|
+
- cron-restart
|
48
|
+
- maintenance
|
49
|
+
- redis
|
50
|
+
- memcached
|
51
|
+
- mysql
|
52
|
+
- letsencrypt
|
53
|
+
scripts:
|
54
|
+
after_install:
|
55
|
+
- dokku cron-restart:set app schedule '0 3 * * *'
|
56
|
+
- dokku memcached:create memcached
|
57
|
+
- dokku memcached:link memcached app
|
58
|
+
- dokku redis:create redis_db
|
59
|
+
- dokku redis:link redis_db app
|
60
|
+
- dokku mysql:create mysql_db
|
61
|
+
- dokku config:set app MYSQL_DATABASE_SCHEME=mysql2
|
62
|
+
- dokku mysql:link mysql_db app
|
63
|
+
after_first_deploy:
|
64
|
+
- dokku letsencrypt:set app email me@myapp.example.com
|
65
|
+
- dokku letsencrypt:enable app
|
66
|
+
- dokku letsencrypt:cron-job --add
|
67
|
+
- dokku run app bin/rails db:seed
|
68
|
+
|
69
|
+
```
|
data/docs/secrets.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Secrets
|
2
|
+
|
3
|
+
Finally, you'll probably want to check your deploy.yml file into source control. But you _definitely_ don't want to be storing important secrets - database passwords, encryption keys and so on - where everyone can see them.
|
4
|
+
|
5
|
+
So the `anvil app` commands also allow you to specify secrets, either from another file, or via the command line.
|
6
|
+
|
7
|
+
The secrets are just extra environment variables that are added to the ones defined in your config file - in the format:
|
8
|
+
|
9
|
+
```
|
10
|
+
SECRET1=VALUE1 SECRET2=VALUE2
|
11
|
+
```
|
12
|
+
|
13
|
+
You can either specify `--secrets my-secrets-file.env` to load these from a separate file. Or you can load them from stdin.
|
14
|
+
|
15
|
+
For example, I use [Bitwarden](https://bitwarden.com) as my password locker and use the Bitwarden CLI to access my secrets. The CLI is installed through homebrew, I then authenticate and can use a command like:
|
16
|
+
|
17
|
+
```sh
|
18
|
+
bw get notes secrets@myapp.com | anvil app install deploy.myapp.yml -S
|
19
|
+
```
|
20
|
+
I have the environment variables for myapp.com stored in Bitwarden as a secure note with the title "secrets@myapp.com". So `bw get notes secrets@myapp.com` loads them from my vault and pipes them to the `anvil app install` command. The anvil command is using the `-S` (or `--secrets-stdin`) option which means it will read the information piped in by bitwarden. So, once decrypted, the confidential data never touches a disk until it gets written into the dokku app configuration on the server.
|
data/docs/why.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Why does this exist?
|
2
|
+
|
3
|
+
[Dokku](https://dokku.com) is great at installing and configuring containers on a single host.
|
4
|
+
|
5
|
+
But you do need to install dokku, generate your configuration and environment variables, install your plugins and app and then configure all those plugins.
|
6
|
+
|
7
|
+
Unfortunately, there's no [single configuration file](https://github.com/dokku/dokku/issues/1558) for dokku.
|
8
|
+
|
9
|
+
In addition, dokku is really designed for managing a single server. But I'm actually using it to manage multiple servers that are hidden behind a load-balancer.
|
10
|
+
|
11
|
+
So to manage this, I wanted a single configuration file that I could user for all my dokku information, that could then use that configuration across multiple servers.
|
12
|
+
|
13
|
+
Currently it's extremely tailored to my needs - it's built for Ubuntu 22.04, it creates a user called "app" (although you can change that), it names your dokku app "app".
|
14
|
+
|
15
|
+
I've also added in cloudinit configs for some of the other servers I have to use. Of course, these are not related to dokku, but anvil can generate them easily so it's useful to keep them all in one place.
|
16
|
+
|
17
|
+
There are several [limitations](/docs/roadmap.md) to how it works - it does what I need but does need expansion. That will come soon.
|
@@ -41,10 +41,12 @@ module Anvil
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def create_git_remote
|
44
|
+
logger.info "git remote add #{host} dokku@#{host}:/app"
|
44
45
|
logger.info `git remote add #{host} dokku@#{host}:/app`
|
45
46
|
end
|
46
47
|
|
47
48
|
def do_git_push
|
49
|
+
logger.info "git push #{host} #{branch}:main"
|
48
50
|
logger.info `git push #{host} #{branch}:main`
|
49
51
|
end
|
50
52
|
|
@@ -41,6 +41,7 @@ module Anvil
|
|
41
41
|
ssh.exec! "dokku docker-options:add app run \"--add-host=host.docker.internal:host-gateway\"", "set_dokku_options"
|
42
42
|
ssh.exec! "dokku domains:set app #{configuration_for_app["domain"]}", "set_dokku_options"
|
43
43
|
ssh.exec! "dokku proxy:ports-add app http:80:#{configuration_for_app["port"]}", "set_dokku_options"
|
44
|
+
ssh.exec! "dokku proxy:ports-add app https:443:#{configuration_for_app["port"]}", "set_dokku_options"
|
44
45
|
ssh.exec! "dokku nginx:set app client-max-body-size #{configuration_for_app["nginx"]["client_max_body_size"]}", "set_dokku_options"
|
45
46
|
ssh.exec! "dokku nginx:set app proxy-read-timeout #{configuration_for_app["nginx"]["proxy_read_timeout"]}", "set_dokku_options"
|
46
47
|
if configuration_for_app["load_balancer"]
|
data/lib/anvil/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: standard-procedure-anvil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rahoul Baruah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -121,6 +121,14 @@ files:
|
|
121
121
|
- checksums/standard-procedure-anvil-0.1.6.gem.sha512
|
122
122
|
- checksums/standard-procedure-anvil-0.1.7.gem.sha512
|
123
123
|
- checksums/standard-procedure-anvil-0.2.0.gem.sha512
|
124
|
+
- checksums/standard-procedure-anvil-0.2.1.gem.sha512
|
125
|
+
- docs/app.md
|
126
|
+
- docs/cloudinit.md
|
127
|
+
- docs/configuration.md
|
128
|
+
- docs/roadmap.md
|
129
|
+
- docs/ruby-on-rails.md
|
130
|
+
- docs/secrets.md
|
131
|
+
- docs/why.md
|
124
132
|
- exe/anvil
|
125
133
|
- lib/anvil.rb
|
126
134
|
- lib/anvil/app.rb
|