Notes on Selfhosted Services

Notes on Selfhosted Services
Photo by Markus Spiske / Unsplash

I started selfhosing with one service (Gitlab) 5 years ago, but now i have more services on totally 1 dedicated server and few VPSs in cloud.

Server configuration storage

First i had each service per git repository but was hard to manage if you have each service in different folder so i moved the to one big repository. My directory structure looks as follows

application
- application name
-- service_vars
-- service_config
-- docker.compose.yml
...
global_vars
scripts

Each application has it's own subfolder whe are stored it's configuration files and environmental variables.

  • service_vars: this is folder where i storing default .env files with container's environment variables
  • service_config: this folder contains configuration files which are mapped as read only to the container
  • docker-compose.yml: docker compose file, i trying to keep them simple. Each application has own compose file. It contains only services they are necessary to run appliaction, volumes definitions and network definitions.
  • global_vars: server configuration as server domain, cloud domain, default location for persistent storage.
  • scripts: for now mainly it contains backup scripts

Proxy and domain name computing

Services are running behind traefik proxy on each docker server. Domains are defined by global variable for example: - "traefik.http.routers.minio.rule=Host(minio.$CLOUD_DOMAIN)"

Persistent data storage

Data are storead as bind mounts but thinking about switch to volumes. They are not easy to move on 2nd drive or browse as bind mounts but they are easier to backup.

I have some volumes mounted as NFS (gitlab backup). So after backup i have Onsite backup on 2nd server and offsite backup. There is full backup with 7 days rotation.

Backups

This is how backup for mattermost looks like:

docker run --rm --volume mattermost_data:/appdata/data \
--volume mattermost_config:/appdata/config \
--volume mattermost_logs:/appdata/logs \
--volume mattermost_plugins:/appdata/plugins \
--volume mattermost_client_plugins:/appdata/client_plugins \
--volume ${TEMP_DIR}:/backup_dir ubuntu tar cvf /backup_dir/${DATA_FILE} /appdata

DATA_FILE is tar.gz archive with name computed from date and application name.

Backups are store offsite mostly on backblaze B2 storage. Databases are backed up 2 times a day and data storage varies from 1 to 7 days depends on service.

Source codes

I mirroring source codes for all aplications I using in case of outage some service...

Docker imges that i using are official docker images or sometimes they are builded on CI/CD then stored on private registry.

So thats my selfhosing adventure. Do you selfhost services you are using? Do you prefer bind mounts or volumes?