added container config
This commit is contained in:
parent
eec00e17fe
commit
1000464b4a
7 changed files with 242 additions and 0 deletions
11
cmd/build_prod_container.sh
Executable file
11
cmd/build_prod_container.sh
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
LARAVEL_CONTAINER_NAME="quay.io/marshyon/share-lt"
|
||||
CONTAINER_LABEL="0.0.2"
|
||||
CACHE="--no-cache"
|
||||
CACHE=""
|
||||
|
||||
docker build \
|
||||
$CACHE \
|
||||
-t ${LARAVEL_CONTAINER_NAME}:${CONTAINER_LABEL} \
|
||||
-f Dockerfile.phpfpm .
|
||||
36
cmd/docker-entrypoint.sh
Normal file
36
cmd/docker-entrypoint.sh
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
run_as_www() {
|
||||
# prefer su-exec (alpine), fallback to runuser if available, otherwise run directly
|
||||
if command -v su-exec >/dev/null 2>&1; then
|
||||
su-exec www "$@"
|
||||
elif command -v runuser >/dev/null 2>&1; then
|
||||
runuser -u www -- "$@"
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Build front-end assets if Vite manifest is missing
|
||||
if [ ! -f /var/www/public/build/manifest.json ]; then
|
||||
echo "Building front-end assets (vite)..."
|
||||
run_as_www npm ci
|
||||
run_as_www npm run build
|
||||
fi
|
||||
|
||||
# Wait for database directory to be mounted
|
||||
if [ ! -f /var/www/database/database.sqlite ]; then
|
||||
echo "Creating database..."
|
||||
# create the sqlite file as the www user so ownership matches app files
|
||||
run_as_www sh -c 'touch /var/www/database/database.sqlite'
|
||||
run_as_www php artisan migrate --force
|
||||
fi
|
||||
|
||||
# Fix storage permissions
|
||||
echo "Fixing storage permissions..."
|
||||
chown -R www:www /var/www/storage /var/www/bootstrap/cache
|
||||
chmod -R 775 /var/www/storage /var/www/bootstrap/cache
|
||||
|
||||
# Execute the main command
|
||||
exec "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue