feat: Dockerisation du Docuseal

This commit is contained in:
N3WT DE COMPET
2025-05-30 14:21:42 +02:00
parent 23ab7d04ef
commit 6de0d3be1a
3 changed files with 35 additions and 91 deletions

3
Caddyfile Normal file
View File

@ -0,0 +1,3 @@
https://localhost:4443, https://127.0.0.1:4443 {
reverse_proxy docuseal:3000
}

View File

@ -16,40 +16,40 @@ services:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: school
TZ: Europe/Paris
# docuseal_db:
# image: postgres:latest
# environment:
# POSTGRES_USER: postgres
# POSTGRES_PASSWORD: postgres
# DOCUSEAL_DB_HOST: docuseal_db
# POSTGRES_DB: docuseal
# ports:
# - 5433:5432 # port différent si besoin d'accès direct depuis l'hôte
docuseal_db:
image: postgres:latest
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
DOCUSEAL_DB_HOST: docuseal_db
POSTGRES_DB: docuseal
ports:
- 5433:5432 # port différent si besoin d'accès direct depuis l'hôte
# docuseal:
# image: docuseal/docuseal:latest
# container_name: docuseal_app
# depends_on:
# - docuseal_db
# ports:
# - "3001:3000"
# environment:
# DATABASE_URL: postgresql://postgres:postgres@docuseal_db:5432/docuseal
# volumes:
# - ./docuseal:/data/docuseal
docuseal:
image: docuseal/docuseal:latest
container_name: docuseal_app
depends_on:
- docuseal_db
ports:
- "3001:3000"
environment:
DATABASE_URL: postgresql://postgres:postgres@docuseal_db:5432/docuseal
volumes:
- ./docuseal:/data/docuseal
# caddy:
# image: caddy:2
# container_name: caddy
# restart: unless-stopped
# ports:
# - "4000:4443"
# volumes:
# - ./Caddyfile:/etc/caddy/Caddyfile
# - caddy_data:/data
# - caddy_config:/config
# depends_on:
# - docuseal
caddy:
image: caddy:2
container_name: caddy
restart: unless-stopped
ports:
- "4000:4443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
depends_on:
- docuseal
backend:
build:
@ -72,24 +72,6 @@ services:
#- docuseal
command: python start.py
# init_docuseal_users:
# build:
# context: .
# dockerfile: Dockerfile
# depends_on:
# - docuseal
# environment:
# DOCUSEAL_DB_HOST: docuseal_db
# POSTGRES_USER: postgres
# POSTGRES_PASSWORD: postgres
# USER_FIRST_NAME: n3wt
# USER_LAST_NAME: school
# USER_COMPANY: n3wt.innov
# USER_EMAIL: n3wt.school@gmail.com
# USER_PASSWORD: n3wt1234
# volumes:
# - ./initDocusealUsers.sh:/docker-entrypoint-initdb.d/initDocusealUsers.sh
# frontend:
# build:
# context: ./Front-End

View File

@ -1,41 +0,0 @@
#!/bin/bash
set -e
# Attendre que le service docuseal soit prêt
until curl -s http://docuseal:3000 > /dev/null; do
echo "Waiting for docuseal to be ready..."
sleep 5
done
encrypt_password() {
local password=$1
ruby -e "require 'bcrypt'; puts BCrypt::Password.create('$password')"
}
# Mot de passe encrypté
ENCRYPTED_PASSWORD=$(encrypt_password "$USER_PASSWORD")
# Insérer les données dans les tables accounts et users si elles n'existent pas déjà
PGPASSWORD=$POSTGRES_PASSWORD psql -v ON_ERROR_STOP=1 --host=database --port=5432 --username="$POSTGRES_USER" --dbname=docuseal <<-EOSQL
-- Vérifier l'existence du compte
DO \$\$
BEGIN
IF NOT EXISTS (SELECT 1 FROM accounts WHERE name = '$USER_COMPANY') THEN
-- Insérer dans la table accounts
INSERT INTO accounts (name, timezone, locale, created_at, updated_at, uuid) VALUES
('$USER_COMPANY', 'UTC', 'en', NOW(), NOW(), gen_random_uuid());
END IF;
END
\$\$;
-- Vérifier l'existence de l'utilisateur
DO \$\$
BEGIN
IF NOT EXISTS (SELECT 1 FROM users WHERE email = '$USER_EMAIL') THEN
-- Insérer dans la table users
INSERT INTO users (first_name, last_name, email, encrypted_password, account_id, role, sign_in_count, failed_attempts, created_at, updated_at, uuid, otp_required_for_login) VALUES
('$USER_FIRST_NAME', '$USER_LAST_NAME', '$USER_EMAIL', '$ENCRYPTED_PASSWORD', (SELECT id FROM accounts WHERE name = '$USER_COMPANY'), 'admin', 1, 0, NOW(), NOW(), gen_random_uuid(), false);
END IF;
END
\$\$;
EOSQL