diff --git a/docker/dev/podman/Dockerfile b/docker/dev/podman/Dockerfile index 98a340c..49d2834 100644 --- a/docker/dev/podman/Dockerfile +++ b/docker/dev/podman/Dockerfile @@ -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"] \ No newline at end of file +CMD ["/usr/local/bin/container-start.sh"] \ No newline at end of file diff --git a/docker/dev/podman/container-start.sh b/docker/dev/podman/container-start.sh new file mode 100644 index 0000000..4cfc0f6 --- /dev/null +++ b/docker/dev/podman/container-start.sh @@ -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 \ No newline at end of file