Skip to content

Commit 9150172

Browse files
authored
Merge pull request #34 from sourceboat/feature/merge-dev-and-prod-scripts
merge dev and prod scripts
2 parents 72520f6 + 9e89638 commit 9150172

File tree

8 files changed

+34
-48
lines changed

8 files changed

+34
-48
lines changed

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ RUN yarn config set strict-ssl false && \
100100

101101
# copy root folder and make run scripts executable
102102
COPY ./root/ /root/
103-
RUN find /root -name "run-*.sh" -exec chmod -v +x {} \;
104-
RUN chmod +x /root/entrypoint.sh
103+
RUN find /root -name "*.sh" -exec chmod -v +x {} \;
105104

106105
# run the application
107106
ENTRYPOINT ["/root/entrypoint.sh"]
108-
CMD /root/run-prod.sh
107+
CMD ["runsvdir", "/etc/service"]
109108
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:

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/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

root/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

root/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/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)