Merge pull request 'ajout d'un docker compose pour tester en local et ajout d'un argument de build dockerfile' (#7) from refactoring into main

Reviewed-on: #7
Reviewed-by: technostrea <contact@technostrea.fr>
This commit is contained in:
2025-11-21 11:17:25 +00:00
10 changed files with 1203 additions and 2 deletions

View File

@@ -7,3 +7,5 @@ coverage
Docker*
start.sh
package-lock.json
pb
compose.yaml

2
.gitignore vendored
View File

@@ -124,3 +124,5 @@ Thumbs.db
start.sh
logs/*
logs/*.log
pb/data/*

View File

@@ -4,10 +4,12 @@ FROM node:20-alpine AS node-builder
ARG APP_NAME=technostrea
ARG ENVIRONMENT=production
ARG NG_VERSION=18
ARG ENV_URL
ENV APP_NAME=$APP_NAME
ENV ENVIRONMENT=$ENVIRONMENT
ENV NG_VERSION=$NG_VERSION
ENV ENV_URL=$ENV_URL
WORKDIR /app
@@ -30,6 +32,9 @@ RUN npm install -g @angular/cli@$NG_VERSION
COPY . .
RUN chmod +x replace-prod-env.sh
RUN ./replace-prod-env.sh src/environments/environment.ts $ENV_URL
RUN npm install --legacy-peer-deps
RUN ng build --configuration=$ENVIRONMENT --output-path=dist/

21
compose.yaml Normal file
View File

@@ -0,0 +1,21 @@
networks:
pb-net:
name: pb
services:
pocketbase:
image: elestio/pocketbase:latest
container_name: pocketbase
user: root
environment:
ADMIN_EMAIL: "admin@example.com"
ADMIN_PASSWORD: "password1234"
networks:
- pb-net
volumes:
- ./pb/data:/pb/data
- ./pb/schemas:/schemas
- ./pb/init.sh:/init.sh
entrypoint: ["/bin/sh", "/init.sh"]
ports:
- "8090:8090"

0
pb/data/.gitkeep Normal file
View File

26
pb/init.sh Normal file
View File

@@ -0,0 +1,26 @@
#!/bin/sh
set -e
PB="/usr/local/bin/pocketbase"
ADMIN_EMAIL="${ADMIN_EMAIL:-admin@example.com}"
ADMIN_PASSWORD="${ADMIN_PASSWORD:-password1234}"
LOCK_FILE="/pb/data/superuser_created"
mkdir -p /pb/data
# Vérifier si le fichier de verrouillage existe
if [ -f "$LOCK_FILE" ]; then
echo "✅ Le superuser a déjà été créé précédemment."
else
echo "➡️ Vérification du superuser existant..."
if $PB list-users --dir /pb/data | grep -q "$ADMIN_EMAIL"; then
echo "✅ Le superuser $ADMIN_EMAIL existe déjà."
else
echo "➡️ Création du superuser..."
$PB superuser upsert "$ADMIN_EMAIL" "$ADMIN_PASSWORD"
fi
# Créer le fichier de verrouillage
touch "$LOCK_FILE"
fi
echo "➡️ Lancement de PocketBase..."
exec $PB serve --http=0.0.0.0:8090 --dir /pb/data

File diff suppressed because it is too large Load Diff

34
replace-prod-env.sh Normal file
View File

@@ -0,0 +1,34 @@
#!/bin/sh
# Vérifier que le fichier et la nouvelle URL sont fournis
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <fichier> <nouvelle_url>"
exit 1
fi
FICHIER=$1
NOUVELLE_URL=$2
# Vérifier que le fichier existe
if [ ! -f "$FICHIER" ]; then
echo "Erreur: Le fichier $FICHIER n'existe pas."
exit 1
fi
# Détecter le système d'exploitation pour adapter la commande sed
case "$(uname -s)" in
Darwin*)
# macOS
sed -i '' "s|baseUrl: '.*'|baseUrl: '$NOUVELLE_URL'|g" "$FICHIER"
;;
Linux*)
# Linux
sed -i "s|baseUrl: '.*'|baseUrl: '$NOUVELLE_URL'|g" "$FICHIER"
;;
*)
echo "Système d'exploitation non supporté"
exit 1
;;
esac
echo "L'URL a été remplacée avec succès dans $FICHIER."

View File

@@ -1,4 +1,4 @@
export const environment = {
production: false,
baseUrl: 'https://pb-dev.prod.K3s.technostrea.fr',
baseUrl: 'http://localhost:8090',
};

View File

@@ -1,4 +1,4 @@
export const environment = {
production: true,
baseUrl: 'https://pb-dev.prod.K3s.technostrea.fr',
baseUrl: 'http://localhost:8090',
};