Skip to content

Commit a22df44

Browse files
author
Hauke Ingwersen
committed
merge run-dev and run-prod, fixed wait-for-it
1 parent e8ad7fc commit a22df44

File tree

8 files changed

+39
-46
lines changed

8 files changed

+39
-46
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ COPY ./root/ /root/
103103
RUN find /root -name "run-*.sh" -exec chmod -v +x {} \;
104104
RUN chmod +x /root/entrypoint.sh
105105

106+
# copy startup modules folder and make scripts executalbe
107+
108+
COPY ./modules/ /root/modules/
109+
RUN find /root/modules/ -name "*.sh" -exec chmod -v +x {} \;
110+
111+
106112
# run the application
107113
ENTRYPOINT ["/root/entrypoint.sh"]
108-
CMD /root/run-prod.sh
114+
CMD ["runsvdir", "/etc/service"]
109115
EXPOSE 8080

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ version: '3.7'
4545
services:
4646
app:
4747
build: .
48-
command: /root/run-dev.sh
4948
restart: unless-stopped
5049
environment:
5150
- PHP_OPCACHE_VALIDATE_TIMESTAMPS=1
5251
- PHP_MEMORY_LIMIT=1G
52+
- STARTUP_COMMAND1=/root/modules/dev.sh
53+
- STARTUP_COMMAND2=php artisan migrate --force
54+
- STARTUP_COMMAND3=php artisan setup
5355
volumes:
5456
- ./:/opt/app:cached
5557
ports:
@@ -80,13 +82,14 @@ version: '3.7'
8082
services:
8183
app:
8284
image: sourceboat/docker-laravel
83-
command: /root/run-prod.sh
8485
restart: unless-stopped
8586
environment:
8687
- PHP_OPCACHE_VALIDATE_TIMESTAMPS=1
8788
- PHP_MEMORY_LIMIT=1G
88-
- STARTUP_COMMAND1=php artisan migrate --force
89-
- STARTUP_COMMAND2=php artisan horizon:restart
89+
- STARTUP_COMMAND1=/root/modules/storage.sh
90+
- STARTUP_COMMAND2=/root/modules/cache.sh
91+
- STARTUP_COMMAND3=php artisan migrate --force
92+
- STARTUP_COMMAND4=php artisan horizon:restart
9093
volumes:
9194
- ./:/opt/app:cached
9295
ports:

modules/cache.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
cd /opt/app
4+
5+
# build caches
6+
echo "Build caches..."
7+
php artisan config:cache
8+
php artisan route:cache
9+
php artisan view:cache

modules/dev.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
cd /opt/app
3+
4+
echo "Build development..."
5+
composer install --prefer-dist --no-progress --no-interaction
6+
yarn

modules/storage.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
cd /opt/app
3+
4+
echo "Create storage symlink..."
5+
su www-data -s /bin/sh -c "php artisan storage:link -q"

root/entrypoint.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ touch /opt/app/storage/logs/worker.log
1010
chown www-data:www-data -R /opt/app/storage
1111
chown www-data:www-data -R /opt/app/bootstrap/cache
1212

13-
cd /opt/app
14-
15-
# create storage symlink
16-
echo "create storage symlink..."
17-
su www-data -s /bin/sh -c "php artisan storage:link -q"
18-
1913
# startup commands
14+
echo "Running startup commands..."
2015
php /usr/local/bin/startup-commands.php | bash
2116

17+
if [[ -n "$DB_HOST" || -n "$DB_PORT" ]]; then
18+
wait-for-it.sh --host=$DB_HOST --port=$DB_PORT
19+
fi
20+
2221
exec "$@"

root/run-dev.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

root/run-prod.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)