no more problems

This commit is contained in:
2026-02-06 16:03:25 +01:00
parent 8b3616ab73
commit b676145d55
7 changed files with 171 additions and 39 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"
SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1,localhost:8000
SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1,localhost:8000,localhost:5173
TYPESENSE_CONNECTION=typesense
TYPESENSE_API_KEY=xyz
+7 -1
View File
@@ -5,6 +5,7 @@ ARG GROUP_ID=1000
RUN apt-get update && apt-get install -y \
git unzip libzip-dev libpng-dev libonig-dev gosu \
&& apt-get install -y netcat-openbsd \
&& docker-php-ext-install pdo_mysql zip pcntl
RUN if [ ${USER_ID:-0} -ne 0 ] && [ ${GROUP_ID:-0} -ne 0 ]; then \
@@ -16,7 +17,12 @@ RUN if [ ${USER_ID:-0} -ne 0 ] && [ ${GROUP_ID:-0} -ne 0 ]; then \
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
COPY scripts/init-dev.sh /usr/local/bin/init-dev.sh
COPY scripts/init-prod.sh /usr/local/bin/init-prod.sh
RUN chmod +x /usr/local/bin/entrypoint.sh \
/usr/local/bin/init-dev.sh \
/usr/local/bin/init-prod.sh
WORKDIR /var/www/app
+3 -34
View File
@@ -1,42 +1,11 @@
#!/bin/sh
set -e
APP_DIR=/var/www/app
GIT_URL="https://oauth2:${GIT_TOKEN}@${BACKEND_GIT_REPO}"
# Si le dossier app-code est vide ou n'existe pas, on le prépare
if [ ! -d "$APP_DIR/.git" ]; then
# Créer le dossier avec les bonnes permissions si nécessaire
mkdir -p "$APP_DIR"
# Cloner en tant que root d'abord
git clone -b "${BACKEND_GIT_BRANCH:-main}" "$GIT_URL" "$APP_DIR"
# Puis changer TOUS les propriétaires vers www-data
chown -R www-data:www-data "$APP_DIR"
if [ "$DEV" = 1 ]; then
/usr/local/bin/init-dev.sh
else
cd "$APP_DIR"
# S'assurer que www-data possède le dossier avant fetch
chown -R www-data:www-data "$APP_DIR"
gosu www-data git fetch origin
gosu www-data git reset --hard origin/"${BACKEND_GIT_BRANCH:-main}"
/usr/local/bin/init-prod.sh
fi
cd "$APP_DIR"
if [ -f composer.json ]; then
gosu www-data composer update --no-interaction --prefer-dist --optimize-autoloader
fi
cp /tmp/app.env .env
chown www-data:www-data .env
gosu www-data php artisan key:generate --force
gosu www-data php artisan config:clear
gosu www-data php artisan cache:clear
gosu www-data php artisan migrate --force
chmod -R 775 storage bootstrap/cache
chmod -R 755 public
exec "$@"
+71
View File
@@ -0,0 +1,71 @@
#!/bin/sh
set -e
APP_DIR=/var/www/app
GIT_URL="https://oauth2:${GIT_TOKEN}@${BACKEND_GIT_REPO}"
BRANCH="${BACKEND_GIT_BRANCH:-main}"
FORCE_CLONE="${FORCE_CLONE:-false}"
chown www-data:www-data /var/www
chown -R www-data:www-data "$APP_DIR"
gosu www-data:www-data git config --global --add safe.directory "$APP_DIR"
if [ ! -d "$APP_DIR/.git" ]; then
mkdir -p "$APP_DIR"
git clone -b "$BRANCH" "$GIT_URL" "$APP_DIR"
chown -R www-data:www-data "$APP_DIR"
else
cd "$APP_DIR"
chown -R www-data:www-data "$APP_DIR"
CURRENT_BRANCH=$(gosu www-data git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" = "$BRANCH" ]; then
gosu www-data git fetch origin
gosu www-data git reset --hard origin/"$CURRENT_BRANCH"
else
if [ "$FORCE_CLONE" = true ]; then
cd /var/www
rm -rf "$APP_DIR"
mkdir app
cd app
git clone -b "$BRANCH" "$GIT_URL" "$APP_DIR"
chown -R www-data:www-data "$APP_DIR"
else
gosu www-data git fetch origin
gosu www-data git reset --hard origin/"$CURRENT_BRANCH"
fi
fi
fi
cd "$APP_DIR"
mkdir -p /var/www/.composer/cache
chown -R www-data:www-data /var/www/.composer
if [ -f composer.json ]; then
gosu www-data composer update --no-interaction --prefer-dist --optimize-autoloader
fi
cp /tmp/app.env .env
chown www-data:www-data .env
chmod 664 .env
echo "Waiting for MariaDB..."
until nc -z mariadb 3306; do
sleep 2
echo "MariaDB not ready yet..."
done
echo "MariaDB is ready!"
gosu www-data php artisan key:generate --force
gosu www-data php artisan config:clear
gosu www-data php artisan cache:clear
gosu www-data php artisan migrate --force
chmod -R 775 storage bootstrap/cache
chmod -R 755 public
+73
View File
@@ -0,0 +1,73 @@
set -e
APP_DIR=/var/www/app
GIT_URL="https://oauth2:${GIT_TOKEN}@${BACKEND_GIT_REPO}"
BRANCH="${BACKEND_GIT_BRANCH:-main}"
FORCE_CLONE="${FORCE_CLONE:-false}"
git config --global --add safe.directory "$APP_DIR"
if [ ! -d "$APP_DIR/.git" ]; then
mkdir -p "$APP_DIR"
echo "azy"
git clone -b "$BRANCH" "$GIT_URL" "$APP_DIR"
echo "a"
else
cd "$APP_DIR"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" = "$BRANCH" ]; then
echo "b"
git fetch origin
git reset --hard origin/"$CURRENT_BRANCH"
else
if [ "$FORCE_CLONE" = "true" ]; then
cd ..
rm -rf "$APP_DIR"
mkdir -p "$APP_DIR"
git clone -b "$BRANCH" "$GIT_URL" "$APP_DIR"
else
git fetch origin
git reset --hard origin/"$BRANCH"
fi
fi
fi
cd "$APP_DIR"
mkdir -p /var/www/.composer/cache
chown -R www-data:www-data /var/www/.composer
if [ -f composer.json ]; then
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
fi
cp /tmp/app.env .env
chown www-data:www-data .env
chmod 640 .env
echo "Waiting for MariaDB..."
until nc -z mariadb 3306; do
sleep 2
echo "MariaDB not ready yet..."
done
echo "MariaDB is ready!"
php artisan key:generate --force
php artisan config:clear
php artisan cache:clear
php artisan migrate --force
chown root:root .env
chmod 440 .env
chown -R www-data:www-data "$APP_DIR/storage" "$APP_DIR/bootstrap/cache"
chmod -R 775 "$APP_DIR/storage" "$APP_DIR/bootstrap/cache"