feat: Ajout du service Codimd

This commit is contained in:
Simon 2020-06-01 09:34:42 +02:00
parent f8e4f42cc2
commit 5ee693b8f3
6 changed files with 175 additions and 0 deletions

25
codimd/.env Normal file
View File

@ -0,0 +1,25 @@
## DOCKER
COMPOSE_FILE=./docker-compose.postgres.yml:./docker-compose.yml:./docker-compose.traefik.yml
DOCKER_HOST=ssh://pi@obelix:2222
TRAEFIK_NETWORK_NAME=kifeart
## APP
CODIMD_IMAGE=linuxserver/codimd:1.6.0-ls35
CODIMD_CONTAINER_NAME=codimd
CODIMD_VOLUME_NAME=codimd
CODIMD_DOMAIN=codimd.cool.life
NODE_ENV=production
CMD_PROTOCOL_USESSL=true
# DATABASE
# Voir la description ../postgres/README.md
POSTGRES_IMAGE=postgres:12.2-alpine
POSTGRES_USER=user-example
POSTGRES_PASSWORD=password-example
POSTGRES_DB=postgres-database-name-example
POSTGRES_CONTAINER_NAME=codimd-postgres
POSTGRES_VOLUME_NAME=codimd-postgres

44
codimd/README.md Normal file
View File

@ -0,0 +1,44 @@
# CodiMD
> Realtime collaborative markdown notes on all platforms.
>
> CodiMD lets you collaborate in real-time with markdown. Built on HackMD source
> code, CodiMD lets you host and control your team's content with speed and
> ease.
>
> -- <cite>[Github][github]</cite>
Voici [le dépôt github][github] et l'image docker utilisé.
## Configuration
```sh
cp .env.example .env
```
Modifier la configuration pour son propre serveur et lancer le service :
```sh
docker-compose up -d
```
## Backup
Lancer le script de backup :
```
./backup.sh
```
## Restore
Lancer le script de restauration d'un backup :
```sh
./recovery.sh
# or
./recovery.sh 2020_03_09
```
[docker]: https://github.com/linuxserver/docker-codimd
[github]: https://github.com/codimd/server

View File

@ -0,0 +1,19 @@
version: "3.8"
volumes:
postgres:
name: ${POSTGRES_VOLUME_NAME}
services:
codimd-postgres:
container_name: ${POSTGRES_CONTAINER_NAME}
image: ${POSTGRES_IMAGE}
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- postgres:/var/lib/postgresql/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro

View File

@ -0,0 +1,13 @@
version: "3.8"
networks:
default:
name: ${TRAEFIK_NETWORK_NAME}
services:
codimd:
labels:
traefik.enable: 'true'
traefik.docker.network: ${TRAEFIK_NETWORK_NAME}
traefik.http.routers.codimd.rule: 'Host(`${CODIMD_DOMAIN}`)'
traefik.http.routers.codimd.entrypoints: 'web'

24
codimd/docker-compose.yml Normal file
View File

@ -0,0 +1,24 @@
version: "3.8"
volumes:
codimd:
name: ${CODIMD_VOLUME_NAME}
services:
codimd:
container_name: ${CODIMD_CONTAINER_NAME}
image: ${CODIMD_IMAGE}
restart: always
depends_on:
- codimd-postgres
volumes:
- codimd:/config
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
environment:
CMD_DB_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@codimd-postgres:5432/${POSTGRES_DB}
CMD_DOMAIN: ${CODIMD_DOMAIN}
NODE_ENV: ${NODE_ENV}
CMD_PROTOCOL_USESSL: ${CMD_PROTOCOL_USESSL}
# PGID: 995
# PUID: 995

50
codimd/run Normal file
View File

@ -0,0 +1,50 @@
#!/bin/bash
set -eu
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/../help.sh
. $DIR/../postgres/run --only-source
codimd_help() {
echo "./run backup : Lancement de la sauvegarde de Codimd"
echo "./run restore : Restoration de la sauvegarde de Codimd"
}
codimd_backup() {
script_env
BACKUP_DATE_DEFAULT=`date +%Y%m%d_%H%M%S`
BACKUP_DATE=${BACKUP_DATE:-$BACKUP_DATE_DEFAULT}
backup_folder_create
POSTGRES_BACKUP_FILE=backups/${BACKUP_DATE}_${CODIMD_DOMAIN}_postgres.sql
postgres_backup
docker run -it --rm -v $HOME/backups/${CODIMD_DOMAIN}:/backup --volumes-from codimd alpine:3.11.6 ash -c "cd config && tar cvf /backup/${BACKUP_DATE}_${CODIMD_DOMAIN}_config.tar ."
}
codimd_restore() {
script_start
script_env
postgres_restore
docker run -it --rm -v $HOME/backups/${CODIMD_DOMAIN}:/backup --volumes-from codimd alpine:3.11.6 ash -c "cd /config && tar xvf /backup/${BACKUP_DATE}_${CODIMD_DOMAIN}_config.tar --strip 1"
script_end
}
if [ $# -ge 1 ]; then
if [ "${1}" == "backup" ]; then
script_start
codimd_backup
script_end
elif [ "${1}" == "restore" ]; then
script_start
codimd_restore
script_end
elif [ "${1}" != "--only-source" ]; then
codimd_help
fi
else
codimd_help
fi