myos/README.md

207 lines
4.6 KiB
Markdown
Raw Permalink Normal View History

2021-05-16 22:26:45 +02:00
# myos - Make Your Own Stack
2021-02-08 14:52:49 +01:00
2022-12-05 20:29:00 +01:00
Docker paas based on docker compose and make files.
2022-06-30 23:37:10 +02:00
Make Your Own Stack provides common make targets to build and run docker projects.
2021-02-08 14:52:49 +01:00
## Disclaimer
2022-12-05 20:29:00 +01:00
This is beta software, use it at your own risks.
2021-02-08 14:52:49 +01:00
2022-07-06 23:27:41 +02:00
## Requirements
2022-07-26 21:57:34 +02:00
You need `docker`, `git` and `make`.
2022-07-06 23:27:41 +02:00
## Install
2022-12-05 20:29:00 +01:00
* Include MYOS file `make/include.mk` adding the following lines to your project file `Makefile`.
```
2022-12-05 20:29:00 +01:00
MYOS ?= ../myos
MYOS_REPOSITORY ?= $(patsubst %/$(APP),%/myos,$(APP_REPOSITORY))
APP ?= $(lastword $(subst /, ,$(APP_REPOSITORY)))
APP_REPOSITORY ?= $(shell git config --get remote.origin.url 2>/dev/null)
$(MYOS):
-@git clone $(MYOS_REPOSITORY) $(MYOS)
-include $(MYOS)/make/include.mk
```
* Call the `make help` command to show available targets.
```
$ make help
Usage:
make [target]
Targets:
help This help
[...]
```
2021-02-08 14:52:49 +01:00
## Usage
2022-06-30 23:37:10 +02:00
### Examples
* Configure myos for domain `domain.tld` and stack `default`
2022-06-30 23:37:10 +02:00
```shell
$ make bootstrap DOMAIN=domain.tld STACK=default
2022-06-30 23:37:10 +02:00
```
2022-11-29 17:22:35 +01:00
* Start myos stack `host`
2022-06-30 23:37:10 +02:00
```shell
2022-11-29 17:22:35 +01:00
$ make host
2022-06-30 23:37:10 +02:00
```
2022-11-29 17:22:35 +01:00
`make host` starts the stack `host` with docker host services :
2022-12-05 20:29:00 +01:00
- consul (service discovery) on host port 8500
- fabio (load balancer) on host ports 80 and 443
2022-06-30 23:37:10 +02:00
- registrator (docker/consul bridge)
* Stop myos
```shell
$ make shutdown
```
### Variables
2021-06-12 03:13:01 +02:00
2022-06-30 23:37:10 +02:00
* DEBUG
2021-06-12 03:13:01 +02:00
2022-11-02 13:42:27 +01:00
Show executed commands.
2021-06-12 03:13:01 +02:00
```shell
2022-06-30 23:37:10 +02:00
$ make up DEBUG=true
2021-06-12 03:13:01 +02:00
```
2022-06-30 23:37:10 +02:00
* DRYRUN
2022-11-02 13:42:27 +01:00
Do nothing, show commands instead of executing it.
2022-06-30 23:37:10 +02:00
```shell
$ make up DRYRUN=true
```
* VERBOSE
2022-11-02 13:42:27 +01:00
Show called functions.
2022-06-30 23:37:10 +02:00
```shell
$ make up VERBOSE=true
```
2022-12-05 20:29:00 +01:00
* Show variable USER
2022-06-30 23:37:10 +02:00
```shell
2022-12-05 20:29:00 +01:00
$ make print-USER
2022-06-30 23:37:10 +02:00
```
2022-11-02 13:42:27 +01:00
#### Setup
* SETUP_LETSENCRYPT
Generate ${DOMAIN} certificate files with letsencrypt.
By default, myos generates invalid ${DOMAIN} certificate files with openssl.
You can use letsencrypt instead, to generate valid wildcard certificate files.
To achieve this, you must add following DNS entries to domain ${DOMAIN} to prove you own it:
```
_acme-challenge.${DOMAIN} IN CNAME ${DOMAIN}.acme.${DOMAIN}.
acme.${DOMAIN}. IN NS certbot.${DOMAIN}.
certbot.${DOMAIN}. IN A ${DOCKER_HOST_INET4}
```
In this config, DOCKER_HOST_INET4 should be the external IP address of the server running certbot.
Port 53 of this IP address must be reachable from internet and point to this server.
If you want a simple DNS configuration to host all your services on the same server, you can setup following DNS config:
```
@ IN A ${DOCKER_HOST_INET4}
*.${DOMAIN}. IN CNAME ${DOMAIN}.
_acme-challenge.${DOMAIN} IN CNAME ${DOMAIN}.acme.${DOMAIN}.
acme.${DOMAIN}. IN NS ${DOMAIN}.
```
This will point domain ${DOMAIN} to the IP address ${DOCKER_HOST_INET4} of this server, and point all subdomains *.{DOMAIN} to the ip address pointed by ${DOMAIN}.
At this point, you should be able to generate a valid certificate for *.${DOMAIN} using certbot [dns standalone](https://github.com/siilike/certbot-dns-standalone) plugin.
2022-11-29 17:22:35 +01:00
This task is done automatically when creating the host stack if SETUP_LETSENCRYPT variable is not empty.
2022-11-02 13:42:27 +01:00
2022-11-29 17:22:35 +01:00
If you already launched myos host stack before, the ${DOMAIN} certificates has been automatically generated by openssl and you should remove them before trying to generate them with letsencrypt.
2022-11-02 13:42:27 +01:00
```
2022-11-29 17:22:35 +01:00
$ make host-down
$ docker volume rm $(hostname)
2022-11-02 13:42:27 +01:00
```
You can then test the letsencrypt certificate generation using DEBUG mode that force to use the letsencrypt staging server.
```
2022-11-29 17:22:35 +01:00
$ make host SETUP_LETSENCRYPT=true DEBUG=true
2022-11-02 13:42:27 +01:00
```
If letsencrypt certificate generation fails, you can retry the generation of a staging certificate.
```
2022-11-29 17:22:35 +01:00
$ make host-certbot-staging
2022-11-02 13:42:27 +01:00
```
Once the certificate generation is working, you can ask for a valid certificate.
```
2022-11-29 17:22:35 +01:00
$ make host-down
$ docker volume rm $(hostname)
$ make host SETUP_LETSENCRYPT=true
2022-11-02 13:42:27 +01:00
```
2022-12-05 20:29:00 +01:00
* SETUP_UFW
Control linux firewall rules with ufw.
```
$ echo SETUP_UFW=true >> .env
$ make setup-ufw
```
2022-06-30 23:37:10 +02:00
### Debug
* Show docker compose yaml config
```shell
$ make config
```
2022-07-06 23:27:41 +02:00
`make config` show docker compose yaml config for stack `STACK`
2022-11-29 17:22:35 +01:00
`make host-config` show docker compose yaml config for stack `host`
2022-07-06 23:27:41 +02:00
`make user-config` show docker compose yaml config for stack `User`
`make stack-elastic-config` show docker compose yaml config for stack `elastic`
2022-06-30 23:37:10 +02:00
* Show debug variables
```shell
$ make debug
```
* Generate self documentation
```shell
$ make doc
```
2021-06-12 03:13:01 +02:00
2022-06-30 23:37:10 +02:00
* Show env args
2021-06-12 03:13:01 +02:00
```shell
2022-06-30 23:37:10 +02:00
$ make print-env_args
2021-06-12 03:13:01 +02:00
```
2022-12-05 20:29:00 +01:00
* Show user mail
```shell
$ make print-MAIL
```
2021-02-08 14:52:49 +01:00