Dockerization of server-side @SINDAN suite
- Branch: shored-master is the previous generation maintained by @shored (soon to be deprecated and removed)
Please visit our website sindan-net.com for more details. (Japanese edition only)
These instructions will get you a copy of this project up and running on your environment for production purpose. If you want to use this for development or testing purposes, some configurations need to be fixed appropriately.
To build images on your local environment, Docker with BuildKit support is needed. GNU/Make is not necessary, but it can reduce the number of commands you type.
- docker-engine: 18.06.0 and higher
- docker-compose: 1.22.0 and higher
By default, SINDAN servers listen and wait for requests from external network at the following ports. Open these ports in your firewall beforehand as needed.
- Caddy : 80/tcp, 443/tcp
- ghcr.io/sindan/sindan-docker/fluentd: 8080/tcp, 8888/tcp
- ghcr.io/sindan/sindan-docker/visualization: 3000/tcp
- ghcr.io/sindan/sindan-docker/grafana: 3001/tcp
First of all, you have to shallow clone this repository recursively with:
$ git clone --recursive --depth 1 https://github.com/SINDAN/sindan-docker
If you ran simple cloning command without recursive option or downloaded as a zip archive via browser, make sure that all submodules are fully updated.
$ git submodule update --init --recursive
Git will ignore all of password files in .secrets
directory, so that the updates are local-only.
Set the password of MySQL database.
For mac users, use shasum -a 256
instead of sha256sum
below.
$ echo PASSWORD_OF_YOUR_ENV | sha256sum | cut -d ' ' -f 1 > .secrets/db_password.txt
Register user accounts of SINDAN Web.
User's password must be 8-72 characters long.
Sample accounts.yml
registers an account whose name is sindan
and password is changeme
.
$ cp .secrets/accounts.yml.example .secrets/accounts.yml
$ vim .secrets/accounts.yml
You can register multiple accounts in bulk.
accounts:
- username: hoge
email: [email protected]
password: changeme
- username: fuga
email: [email protected]
password: changeme
Finally, set the Grafana's username and password to gf_user.txt
and gf_password.txt
respectively.
$ cp .secrets/gf_user.txt.example .secrets/gf_user.txt
$ cp .secrets/gf_password.txt.example .secrets/gf_password.txt
$ vim -p .secrets/gf_user.txt .secrets/gf_password.txt
Also if you want to start up with https, set your service domain name. (You must register this domain name entry to the DNS properly.)
$ cp caddy/domain.env.example caddy/domain.env
$ vim caddy/domain.env
Build dockerfile and initialize database. This might take a while.
$ cp .secrets/rails_secret_key_base.txt.example .secrets/rails_secret_key_base.txt
$ make build init
Instead of building locally, you can download pre-built images from GitHub Packages.
Note that in this case, you must not edit rails_secret_key_base.txt
as you like.
Just follow the next:
$ cp .secrets/rails_secret_key_base.txt.example .secrets/rails_secret_key_base.txt
$ make pull init
Deploy containers built or pulled previous steps.
$ make run log
If you want to start up with https:
$ make runtls log
Open your favorite browser and go http://localhost:3000 to see SINDAN Web. (If you start up on https, look at https://localhost:13000.)
You can also access Grafana with http://localhost:3001. The screenshot will be added later.
$ make stop # Stop all containers
$ make clean # Remove all containers (data will not be lost)
$ make destroy # Remove all containers, volumes, images
Thanks to Git and Docker, it is very easy to maintain SINDAN servers even after the production deployment. If you want to perform the rolling update or zero downtime deployment, consider using Kubernetes - check charts for details.
You can backup MySQL database anytime you want, and of course you can restore that in a simple way. In the case of restoring, it is recommended to stop all containers in advance.
$ make backup # Dump the database to ./sindan_database_YYYY-MMDD-HHMMSS.sql.gz
$ make restore # Restore the database from ./restore.sql.gz
For example, if you are trying to deploy servers to new environment and you want to inherit the database created in previous environment, following may help you:
$ git clone --recursive --depth 1 https://github.com/SINDAN/sindan-docker
$ cd sindan-docker
$ # Put the backup and rename it to restore.sql.gz
$ make pull restore run log
Just type make update
and your local repository will be up to date with the latest version.
For safety reasons, do not forget to stop all containers before the update.
That is, the command you should run is like the following.
It sequencially executes backup database, stop containers, update repository and restart containers:
$ make backup clean update pull run
We use CalVer for versioning. For the versions available, see the tags on this repository.
- Tomohiro ISHIHARA - Initial work & Patch contribution - @shored
- Taichi MIYA - Overhaul & Refactoring - @mi2428
See also the list of contributors who participated in this project.
This project is licensed under the BSD 3-Clause "New" or "Revised" License - see the LICENSE file for details.