SUPERCAT.DEV

Benvenut* sul mio blog

DOCKER

Hedgedoc

20-01-2024

Installare Hedgedoc su una macchina virtuale

Installazione di requisiti minimi su Ubuntu 22.04

Mi creo la macchina virtuale e installo il software richiesto (git, docker, docker compose)

sudo apt update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run hello-world

Configurazione

Creo il file sulla mia VM in una cartella a scelta.
File compose.yml

version: '3'
services:
  database:
    image: postgres:13.4-alpine
    environment:
      - POSTGRES_USER=hedgedoc
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=hedgedoc
    volumes:
      - ./database:/var/lib/postgresql/data  # metto il ./ così ho le cartelle in quella da me desiderata
    restart: always
  app:
    # Make sure to use the latest release from https://hedgedoc.org/latest-release
    image: quay.io/hedgedoc/hedgedoc  # tolgo il numero di versione così ho l'ultima
    environment:
      - CMD_DB_URL=postgres://hedgedoc:password@database:5432/hedgedoc
      - CMD_DOMAIN=localhost
      - CMD_URL_ADDPORT=true
    volumes:
      - ./uploads:/hedgedoc/public/uploads  # metto il ./
    ports:
      - "3000:3000"
    restart: always
    depends_on:
      - database

Creazione utente

Da Terminale

docker container ls
docker exec -it ...nomecontainer... bash
bin/manage_users --add email@email.it
exit
docker compose up -d

Lancio

Vado su ipvm:3000

Backup

docker compose exec database pg_dump hedgedoc -U hedgedoc > backup.sql

Ripristino

docker compose up -d database
cat backup.sql | docker exec -i $(docker compose ps -q database) psql -U hedgedoc