Skip to content

Commit

Permalink
fix: not booting after docker compose up
Browse files Browse the repository at this point in the history
Took 1 hour 56 minutes
  • Loading branch information
jordimorillo committed Jun 10, 2024
1 parent b5ffc11 commit f4315ff
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 10 deletions.
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ FROM node:22.2.0 AS node-stage

WORKDIR /var/www/html

COPY package.json package-lock.json ./
RUN npm ci --cache /tmp/empty-cache
RUN mkdir -p /var/www/html/build
RUN npm install -g typescript

COPY . .

FROM php:8.1-fpm as php-stage

Expand All @@ -24,13 +22,20 @@ COPY .env.docker /var/www/html/.env

EXPOSE 9000

COPY ./entrypoint.sh /var/www/html/entrypoint.sh
RUN chmod +x /var/www/html/entrypoint.sh
ENTRYPOINT ["/var/www/html/entrypoint.sh"]

CMD ["php-fpm"]


FROM nginx:latest as nginx-stage
COPY ./nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
COPY --from=php-stage /var/www/html /var/www/html
COPY --from=node-stage /var/www/html/build /var/www/html/build
RUN chmod -R 777 /var/www/html/build

EXPOSE 80
EXPOSE 8000

CMD ["nginx", "-g", "daemon off;"]
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ setup: ## Does the setup of basic project's features like composer install, migr
docker exec -it php php artisan cache:clear
docker exec -it php php artisan key:generate
docker exec -it php php artisan passport:install --force --no-interaction
docker exec -it node npm install
docker exec -it node npm run build

render-setup:
bash -c 'if [ -f /var/www/html/bootstrap/cache/config.php ]; then rm /var/www/html/bootstrap/cache/config.php; fi'
Expand All @@ -77,8 +75,6 @@ render-setup:
php artisan cache:clear
php artisan key:generate
php artisan passport:install --force --no-interaction
npm install
npm run build

cache-clear: ## Clear the cache
docker exec -it php php artisan config:clear
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ services:

node:
container_name: node
image: node:22.2.0-bullseye
image: node:22.2.0
restart: unless-stopped
tty: true
build:
context: .
target: node-stage
entrypoint:
- /var/www/html/entrypoint_node.sh
volumes:
- ./:/var/www/html
expose:
Expand Down
30 changes: 30 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# Elimina el archivo de configuración en caché si existe
if [ -f /var/www/html/bootstrap/cache/config.php ]; then
rm /var/www/html/bootstrap/cache/config.php
fi

# Ejecuta las instrucciones de Composer y Artisan
composer install
composer clear-cache
composer dump-autoload
php artisan cache:clear
php artisan config:clear
php artisan optimize
php artisan clear-compiled
php artisan key:generate
php artisan config:cache
chmod 777 -R storage

php artisan migrate:fresh --seed
php artisan l5-swagger:generate
cp .env.docker .env
php artisan config:clear
php artisan config:cache
php artisan cache:clear
php artisan key:generate
php artisan passport:install --force --no-interaction

# Ejecuta el comando recibido como argumento del entrypoint
exec "$@"
7 changes: 7 additions & 0 deletions entrypoint_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

npm install
npm run build

# Ejecuta el comando recibido como argumento del entrypoint
exec "$@"
2 changes: 0 additions & 2 deletions reboot.bat
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ docker exec -it php php artisan config:cache
docker exec -it php php artisan cache:clear
docker exec -it php php artisan key:generate
docker exec -it php php artisan passport:install --force --no-interaction
docker exec -it node npm install
docker exec -it node npm run build

0 comments on commit f4315ff

Please sign in to comment.