Skip to content

Deployment using Docker

AuxiliumCDNG edited this page Apr 1, 2022 · 3 revisions

In this part of the docs, you will learn how to build and deploy BeeLogger using Docker! No surprise that you want to have docker and docker-compose installed... :)

Getting the image

Option 1: Using our pre-built image (COMING SOON!)

To just start right away, just use our image hosted on docker hub. Continue at "Setting it up".

Option 2: Building the image yourself

If there is no image released yet, or you want to change something about BeeLogger that isn't configurable, you may build the image yourself.

  1. If you haven't done already, clone the BeeLogger repository.
  2. cd into the cloned folder
  3. Make your changes to the "example_config.py" file or leave it blank if you want to use environment variables (the file will automatically be copied to the container by Docker).
  4. use the following command to build the image: docker build --tag beelogger . (include the dot!)
  5. grab some coffee as this may take a long time! "hanging" pip wheel builds are likely not errors! Wait at least 5 minutes! Pip will keep you up to date if the build is still running. e.g.:
    Image showing: "Building wheel for numpy (pyproject.toml): still running..."
    This took around 10 minutes.
  6. Ignore pip warnings about running it as root...everything is fine.

If you see this, you are done!

Successfully built *****
Successfully tagged beelogger:latest

Setting it up

Create the .env file and fill in the data

telegram_bot_token=

insert_token=
display_token=

correction={"0": 1}
tare={"0": 0}
real_tare={"0": 0}

mysql_host=db
mysql_port=3306
mysql_user=root
mysql_pass=
mysql_db=beelogger

pages={}

mysql_backup_host=
mysql_backup_port=3306
mysql_backup_user=
mysql_backup_pass=
mysql_backup_db=

backup_host=
backup_port=
backup_user=
backup_pass=
backup_key=
backup_dir=

mail_host=
mail_port=
mail_user=
mail_pass=
mail_rec=

Option 1: Using docker-compose (Recommended)

The Docker-compose deployment may be set up very easily and is thus recommended.

  • Create a folder for the instance; e.g. "/home/beelogger/beelogger-docker"
  • cd into that folder
  • create the "docker-compose.yml" file
  • paste the following:

docker-compose.yml:

############################ DON'T CHANGE ANYTHING IN HERE - USE THE .env FILE! ############################

version: '3.1'

services:
  db:
    image: mariadb:10.3
    restart: always
    ports:
      - 3306
    volumes:
      - "./docker_volumes/mariadb:/var/lib/mysql"
    environment:
      MYSQL_ROOT_PASSWORD: "${mysql_pass}"

  beelogger:
    image: ghcr.io/programmier-ag/beelogger:latest
    # Uncomment if you'd like to build the image yourself.
    # build: .
    depends_on:
      - db
    restart: "no"
    ports:
      - 2688:8000
    volumes:
      - "./docker_volumes/contact:/app/contact"
      - "./docker_volumes/backup:/app/backup"
      - "./docker_volumes/logs:/app/logs"
      - "./docker_volumes/secrets:/app/secrets"
    env_file: .env

Option 2: Using docker and separate db (Not recommended)

Use the following command to start the container. Change the options to your liking...

Run command

docker run -d \
--restart "unless-stopped" \
-v "/var/beelogger/contact:/app/contact" \
-v "/var/beelogger/backup:/app/backup" \
-v "/var/beelogger/logs:/app/logs" \
-v "/var/beelogger/secrets:/app/secrets" \
-p "2688:8000" \
--env-file "./.env" \
beelogger

When that's done

Use docker-compose up -d to create and start the containers

BeeLogger should be available under port 2688.

Done 😃