Docker deployment

Use the official BorgWarehouse docker image

  • Get the latest BorgWarehouse docker image from the docker hub.
docker pull borgwarehouse/borgwarehouse:latest
services:
  borgwarehouse:
    container_name: borgwarehouse
    # If you want to build the image yourself, uncomment the following lines and comment the image line
    #build:
    #   context: .
    #   dockerfile: Dockerfile
    #   args:
    #       - UID=${UID}
    #       - GID=${GID}
    image: borgwarehouse/borgwarehouse
    user: "${UID:?UID variable missing}:${GID:?GID variable missing}"
    ports:
      - "${WEB_SERVER_PORT:?WEB_SERVER_PORT variable missing}:3000"
      - "${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing}:22"
    env_file:
      - .env
    volumes:
      - ${CONFIG_PATH:?CONFIG_PATH variable missing}:/home/borgwarehouse/app/config
      - ${SSH_PATH:?SSH_PATH variable missing}:/home/borgwarehouse/.ssh
      - ${SSH_HOST:?SSH_HOST variable missing}:/etc/ssh
      - ${BORG_REPOSITORY_PATH:?BORG_REPOSITORY_PATH variable missing}:/home/borgwarehouse/repos
      - ${TMP_PATH:?TMP_PATH variable missing}:/home/borgwarehouse/tmp
      - ${LOGS_PATH:?LOGS_PATH variable missing}:/home/borgwarehouse/logs
  # Apprise is used to send notifications, it's optional. http://apprise:8000 is the URL to use in BorgWarehouse.
  apprise:
    container_name: apprise
    image: caronc/apprise
    user: "www-data:www-data"

Pick the .env.sample (rename it to .env) and adapt to your needs :

## Required variables section ##

# Host port mappings
WEB_SERVER_PORT=3000
SSH_SERVER_PORT=2222

# Hostname and URL
FQDN=your.domain.com
NEXTAUTH_URL=https://your.domain.com

# Secrects
NEXTAUTH_SECRET=your-secret
CRONJOB_KEY=your-other-secret

# UID:GID must match the user and group ID of the host folders and must be > 1000
# If you want to use a different user than 1001:1001, you must rebuild the image yourself.
UID=1001
GID=1001

# Config and data folders (volume mounts)
# The host folders must be owned by the user with UID and GID specified above
CONFIG_PATH=./config
SSH_PATH=./ssh
SSH_HOST=./ssh_host
BORG_REPOSITORY_PATH=./repos
TMP_PATH=./tmp
LOGS_PATH=./logs

## Optional variables section ##

# LAN feature
FQDN_LAN=
SSH_SERVER_PORT_LAN=

# SMTP server settings
MAIL_SMTP_FROM=
MAIL_SMTP_HOST=
MAIL_SMTP_PORT=
MAIL_SMTP_LOGIN=
MAIL_SMTP_PWD=
MAIL_REJECT_SELFSIGNED_TLS=
  • Create the 6 volumes on the host and adapt the permissions.
    • mkdir config ssh ssh_host repos tmp logs
  • Launch the docker-compose file with docker-compose up -d.
  • Set your scheduled tasks

Build your own docker image

The BorgWarehouse container is intentionally designed not to execute any root processes for enhanced security. The Docker image available on Docker Hub is constructed with a user ID of 1001 and a group ID of 1001. Consequently, it is essential that both volumes and containers operate with a user ID and group ID of 1001 to avoid encountering permission issues.

If you prefer not to utilize the 1001:1001 user and group configuration, you must build your image. Following this if you need help :

In this exemple, I will use the local user borgwarehouse with UID:GID as 1200:1200 to run my BorgWarehouse container. All the following commands are run with this local user.

Firstly, clone the repository and go to the directory:

git clone https://github.com/Ravinou/borgwarehouse.git
cd borgwarehouse

Comment the image line in docker-compose.yml and uncomment the build lines like this :

services:
  borgwarehouse:
    container_name: borgwarehouse
    # If you want to build the image yourself, uncomment the following lines and comment the image line
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - UID=${UID}
        - GID=${GID}
    #image: borgwarehouse/borgwarehouse
    user: "${UID:?UID variable missing}:${GID:?GID variable missing}"
    ports:
      - "${WEB_SERVER_PORT:?WEB_SERVER_PORT variable missing}:3000"
      - "${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing}:22"
    env_file:
      - .env
    volumes:
      - ${CONFIG_PATH:?CONFIG_PATH variable missing}:/home/borgwarehouse/app/config
      - ${SSH_PATH:?SSH_PATH variable missing}:/home/borgwarehouse/.ssh
      - ${SSH_HOST:?SSH_HOST variable missing}:/etc/ssh
      - ${BORG_REPOSITORY_PATH:?BORG_REPOSITORY_PATH variable missing}:/home/borgwarehouse/repos
      - ${TMP_PATH:?TMP_PATH variable missing}:/home/borgwarehouse/tmp
      - ${LOGS_PATH:?LOGS_PATH variable missing}:/home/borgwarehouse/logs
  # Apprise is used to send notifications, it's optional. http://apprise:8000 is the URL to use in BorgWarehouse.
  apprise:
    container_name: apprise
    image: caronc/apprise
    user: "www-data:www-data"

Copy the .env.sample in .env file, adapt to your needs and change UID:GID (here in this example, I chose 1200:1200) :

## Required variables section ##

# Host port mappings
WEB_SERVER_PORT=3000
SSH_SERVER_PORT=2222

# Hostname and URL
FQDN=your.domain.com
NEXTAUTH_URL=https://your.domain.com

# Secrects
NEXTAUTH_SECRET=your-secret
CRONJOB_KEY=your-other-secret

# UID:GID must match the user and group ID of the host folders and must be > 1000
# If you want to use a different user than 1001:1001, you must rebuild the image yourself.
UID=1200
GID=1200

# Config and data folders (volume mounts)
# The host folders must be owned by the user with UID and GID specified above
CONFIG_PATH=/home/borgwarehouse/volumes/config
SSH_PATH=/home/borgwarehouse/volumes/ssh
SSH_HOST=/home/borgwarehouse/volumes/ssh_host
BORG_REPOSITORY_PATH=/home/borgwarehouse/volumes/repos
TMP_PATH=/home/borgwarehouse/volumes/tmp
LOGS_PATH=/home/borgwarehouse/volumes/logs

## Optional variables section ##

# LAN feature
FQDN_LAN=
SSH_SERVER_PORT_LAN=

# SMTP server settings
MAIL_SMTP_FROM=
MAIL_SMTP_HOST=
MAIL_SMTP_PORT=
MAIL_SMTP_LOGIN=
MAIL_SMTP_PWD=
MAIL_REJECT_SELFSIGNED_TLS=

Then, just launch :

docker compose up -d

Finally, set your scheduled tasks

Your image will be build, and will run with the good permissions.

Scheduled tasks

As a reminder, 2 important tasks require regular API calls to be triggered :

  • checking repository status, and sending alerts.
  • storage verification.

Since version 2.1.0, the cron service is no longer included with the container. This is a better way of giving you control over the scheduler. So you’re free to use the service that suits you, your service’s cron or whatever…

Example of cronjob :

* * * * * borgwarehouse curl --request POST --url 'http://localhost:3000/api/cronjob/checkStatus' --header 'Authorization: Bearer CRONJOB_KEY' ; curl --request POST --url 'http://localhost:3000/api/cronjob/getStorageUsed' --header 'Authorization: Bearer CRONJOB_KEY'