Skip to main content
  1. Posts/

Notes on Selfhosted Services

·400 words·2 mins·
linux
May Meow
Author
May Meow
MayMeow is a developer and cybersecurity enthusiast with a passion for cryptography, DevSecOps, and open-source contributions. They enjoy creating tools that strengthen digital security, blending creativity and technology to innovate in fields like PHP and .NET. Always exploring new frontiers in tech, MayMeow is dedicated to safeguarding the digital landscape through their work.
Table of Contents
selfhosted - This article is part of a series.
Part 2: This Article

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?

Reply by Email
selfhosted - This article is part of a series.
Part 2: This Article

Related

How to Install Virtualbox on Elementary OS Odin
·131 words·1 min
linux virtualization tutorial
Sending Exit Code Over Curl
·272 words·2 mins
linux administration notification monitoring
Docker Volume on NFS?
·367 words·2 mins
docker linux WIP