try to implement the global containerization

This commit is contained in:
Giovanni committed 2026-10-03 18:42:21 +02:00
1 parent e2b471312c
commit ed38086d09
24 files changed
+966

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
APP_DIR=/var/www/app
IS_DEV=${DEV:-0}
run() {
if [ "$IS_DEV" = 1 ]; then
gosu www-data "$@"
else
"$@"
fi
}
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
setup_composer() {
echo "Installing dependencies..."
mkdir -p /var/www/.composer/cache
chown -R www-data:www-data /var/www/.composer
if [ -f composer.json ]; then
run composer install --no-interaction --prefer-dist
fi
}
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
setup_env() {
echo "Configuring environment..."
cp /tmp/app.env .env
/usr/local/bin/wait-typesense.sh
TYPESENSE_API_KEY=$(cat /typesense-data/api-key)
sed -i "s/^TYPESENSE_API_KEY=.*/TYPESENSE_API_KEY=$TYPESENSE_API_KEY/" .env
echo "DEV=$DEV" >> .env
if [ "$IS_DEV" = 1 ]; then
chown www-data:www-data .env
chmod 664 .env
else
chown www-data:www-data .env
chmod 640 .env
fi
}
+36
View File
@@ -0,0 +1,36 @@
#!/bin/sh
setup_git() {
echo "Setting up Git..."
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
echo "Cloning repo..."
git clone -b "$BRANCH" "$GIT_URL" "$APP_DIR"
else
echo "Updating repo..."
cd "$APP_DIR"
CURRENT_BRANCH=$(run git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" = "$BRANCH" ]; then
run git fetch origin
run git reset --hard origin/"$CURRENT_BRANCH"
else
if [ "$FORCE_CLONE" = "true" ]; then
rm -rf "$APP_DIR"
mkdir -p "$APP_DIR"
git clone -b "$BRANCH" "$GIT_URL" "$APP_DIR"
else
run git fetch origin
run git reset --hard origin/"$BRANCH"
fi
fi
fi
cd "$APP_DIR"
}
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
setup_laravel() {
echo "Setting up Laravel..."
run php artisan key:generate --force
run php artisan config:clear
run php artisan cache:clear
run php artisan migrate --force --seed
if [ "$IS_DEV" = 1 ]; then
chmod -R 775 storage bootstrap/cache
chmod -R 755 public
else
chown -R www-data:www-data storage bootstrap/cache
chmod -R 775 storage bootstrap/cache
fi
run php artisan storage:link
}
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
until nc -z mariadb 3306; do
sleep 2
done
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
while [ ! -f /typesense-data/api-key ]; do
sleep 1
done