Fix dev container

This commit is contained in:
myrmidex 2025-08-01 00:03:50 +02:00
parent 24143d53ac
commit 2adb690d28
2 changed files with 32 additions and 7 deletions

View file

@ -40,13 +40,10 @@ RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html/storage \
&& chmod -R 755 /var/www/html/bootstrap/cache
# Create start script
RUN echo '#!/bin/bash\n\
php artisan serve --host=0.0.0.0 --port=8000 &\n\
npm run dev -- --host 0.0.0.0\n\
wait' > /usr/local/bin/start-dev.sh \
&& chmod +x /usr/local/bin/start-dev.sh
# Copy and set up container start script
COPY docker/dev/podman/container-start.sh /usr/local/bin/container-start.sh
RUN chmod +x /usr/local/bin/container-start.sh
EXPOSE 8000 5173
CMD ["/usr/local/bin/start-dev.sh"]
CMD ["/usr/local/bin/container-start.sh"]

View file

@ -0,0 +1,28 @@
#!/bin/bash
# Create .env file if it doesn't exist
if [ ! -f /var/www/html/.env ]; then
cp /var/www/html/.env.example /var/www/html/.env 2>/dev/null || touch /var/www/html/.env
fi
# Fix database name to match compose file
sed -i 's/DB_DATABASE=incr$/DB_DATABASE=incr_dev/' /var/www/html/.env
# Generate app key if not set or empty
if ! grep -q "APP_KEY=base64:" /var/www/html/.env; then
# Generate a new key and set it directly
NEW_KEY=$(php -r "echo 'base64:' . base64_encode(random_bytes(32));")
sed -i "s/APP_KEY=/APP_KEY=$NEW_KEY/" /var/www/html/.env
fi
# Run migrations
php artisan migrate --force
# Start Laravel development server in background
php artisan serve --host=0.0.0.0 --port=8000 &
# Start Vite development server
npm run dev -- --host 0.0.0.0
# Wait for background processes
wait