functional docker project

This commit is contained in:
2026-01-28 15:16:07 +01:00
parent 6d45c131c7
commit 7d2af43af4
7 changed files with 86 additions and 49 deletions
+2 -2
View File
@@ -5,10 +5,10 @@ RUN apk add --no-cache mariadb-client bash dcron
RUN mkdir -p /backups
RUN mkdir -p /etc/periodic/15min
COPY backup_db.sh /etc/periodic/15min/backup_db
COPY backup_db.sh /etc/periodic/daily/backup_db
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /etc/periodic/15min/backup_db
RUN chmod +x /etc/periodic/daily/backup_db
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
+7 -3
View File
@@ -7,9 +7,13 @@ BACKUP_DIR="/backups"
mkdir -p "$BACKUP_DIR"
DAY=$(date +%d)
DAY=$(date +%d)
FILE="$BACKUP_DIR/$DAY.sql"
mysqldump -h mariadb -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" > "$FILE"
mysqldump -h mariadb -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" > "$FILE" 2>/dev/null
echo "[$(date)] Backup $DB_NAME sauvegardé dans $FILE" >> "$BACKUP_DIR/backup.log"
if [ $? -eq 0 ]; then
echo "[$(date)] Backup $DB_NAME sauvegardé dans $FILE" >> "$BACKUP_DIR/backup.log"
else
echo "[$(date)] ERREUR lors du backup de $DB_NAME" >> "$BACKUP_DIR/backup.log"
fi
+19 -10
View File
@@ -2,14 +2,18 @@
set -e
FRONTEND_DIR=/app
PUBLIC_DIR=/public
APP_DIR=/var/www/app
PUBLIC_DIR="$APP_DIR/public"
GIT_URL="https://oauth2:${GIT_TOKEN}@${FRONTEND_GIT_REPO}"
GIT_URL="https://${GIT_TOKEN}@${FRONTEND_GIT_REPO}"
while [ ! -f "$APP_DIR/composer.json" ]; do
sleep 2
MAX_WAIT=300
WAITED=0
while [ ! -f "$APP_DIR/composer.json" ] || [ ! -d "$APP_DIR/vendor" ] || [ ! -d "$APP_DIR/public" ]; do
if [ $WAITED -ge $MAX_WAIT ]; then
exit 1
fi
sleep 3
WAITED=$((WAITED + 3))
done
@@ -17,18 +21,23 @@ if [ ! -d "$FRONTEND_DIR/.git" ]; then
git clone -b "${FRONTEND_GIT_BRANCH:-main}" "$GIT_URL" "$FRONTEND_DIR"
else
cd "$FRONTEND_DIR"
git pull "$GIT_URL" "${FRONTEND_GIT_BRANCH:-main}"
git fetch origin
git reset --hard origin/"${FRONTEND_GIT_BRANCH:-main}"
fi
cd "$FRONTEND_DIR"
if [ -f package.json ]; then
npm ci
npm ci --prefer-offline --no-audit
fi
npm run build
rm -rf "$PUBLIC_DIR/*"
if [ ! -d "dist" ]; then
exit 1
fi
find "$PUBLIC_DIR" -mindepth 1 ! -name '.gitkeep' ! -name 'index.php' ! -name '.htaccess' -delete
cp -r dist/* "$PUBLIC_DIR/"
exec "$@"
exit 0
+2 -2
View File
@@ -11,5 +11,5 @@ RUN chmod +x /usr/local/bin/entrypoint.sh
WORKDIR /var/www/app
ENTRYPOINT ["entrypoint.sh"]
CMD ["php-fpm"]
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["php-fpm"]
+16 -9
View File
@@ -2,29 +2,36 @@
set -e
APP_DIR=/var/www/app
GIT_URL="https://${GIT_TOKEN}@${BACKEND_GIT_REPO}"
GIT_URL="https://oauth2:${GIT_TOKEN}@${BACKEND_GIT_REPO}"
if [ ! -d "$APP_DIR/.git" ]; then
GIT_URL="https://${GIT_TOKEN}@${BACKEND_GIT_REPO}"
git clone -b "${BACKEND_GIT_BRANCH:-main}" "$GIT_URL" "$APP_DIR"
else
cd "$APP_DIR"
git pull "$GIT_URL" "${BACKEND_GIT_BRANCH:-main}"
git fetch origin
git reset --hard origin/"${BACKEND_GIT_BRANCH:-main}"
fi
cd "$APP_DIR"
if [ -f composer.json ]; then
composer install --no-interaction --prefer-dist --optimize-autoloader
composer update --no-interaction --prefer-dist --optimize-autoloader
fi
if [ -d storage ] && [ -d bootstrap/cache ]; then
chown -R www-data:www-data storage bootstrap/cache
if [ ! -f .env ] && [ -f .env.example ]; then
cp .env.example .env
fi
if [ -f .env ]; then
php artisan key:generate --no-interaction
if [ -f artisan ]; then
if ! grep -q "APP_KEY=base64:" .env 2>/dev/null; then
php artisan key:generate --ansi --force
fi
fi
php artisan migrate --force
exec "$@"
chown -R www-data:www-data storage bootstrap/cache public
chmod -R 775 storage bootstrap/cache
chmod -R 755 public
exec "$@"