This project contains the infrastructure-as-code for deploying and configuring a Hetzner VPS.
Applications:
- Caddy as a file server and reverse proxy
- sxkcd
- cgit
Populate .env
with the necessary environment variables:
$ cp .env.sample .env
$ ./configure
The configuration in ./alpine
builds an Alpine Linux base image in Hetzner
Cloud with Packer and Ansible.
$ cd alpine
$ packer build -var-file="auto.pkrvars.hcl" .
Populate the necessary variables and run terraform apply
:
$ cd terraform
$ terraform plan
$ terraform apply
This configuration creates two local files that will be used by Ansible:
tf_ansible_vars.yml
- Ansible vars file with Cloudflare domainstf_ansible_inventory
- Ansible inventory file with the VM's IP address
The state is saved to an S3 bucket on a local Minio instance by default.
Ansible bootstraps the new VM before installing and configuring our applications to run. It uses the two Terraform-generated files from the previous step.
$ cd ansible
$ ansible-playbook main.yml
Check the following files before running the playbook:
main.yml
- Replace any variables if necessarytasks/templates/docker-compose.yml.j2
- the Docker containers to starttasks/templates/Caddyfile.j2
- the routes to serve
Custom Docker images are built in apps/
:
ghcr.io/kencx/caddy
- Custom caddy image with pluginsghcr.io/kencx/cgit
- Custom cgit image (with and without Nginx)- Custom should be added into
/etc/cgit.d/custom
.
- Custom should be added into