Fix dev container
This commit is contained in:
parent
24143d53ac
commit
2adb690d28
2 changed files with 32 additions and 7 deletions
|
|
@ -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/storage \
|
||||||
&& chmod -R 755 /var/www/html/bootstrap/cache
|
&& chmod -R 755 /var/www/html/bootstrap/cache
|
||||||
|
|
||||||
# Create start script
|
# Copy and set up container start script
|
||||||
RUN echo '#!/bin/bash\n\
|
COPY docker/dev/podman/container-start.sh /usr/local/bin/container-start.sh
|
||||||
php artisan serve --host=0.0.0.0 --port=8000 &\n\
|
RUN chmod +x /usr/local/bin/container-start.sh
|
||||||
npm run dev -- --host 0.0.0.0\n\
|
|
||||||
wait' > /usr/local/bin/start-dev.sh \
|
|
||||||
&& chmod +x /usr/local/bin/start-dev.sh
|
|
||||||
|
|
||||||
EXPOSE 8000 5173
|
EXPOSE 8000 5173
|
||||||
|
|
||||||
CMD ["/usr/local/bin/start-dev.sh"]
|
CMD ["/usr/local/bin/container-start.sh"]
|
||||||
28
docker/dev/podman/container-start.sh
Normal file
28
docker/dev/podman/container-start.sh
Normal 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
|
||||||
Loading…
Reference in a new issue