Skip to content

Commit 621af50

Browse files
committed
[Docker] Add env var to skip yarn install if necessary
1 parent b47de06 commit 621af50

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

compose.override.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ services:
77
- "${HTTPS_PORT:-443}:443"
88
environment:
99
- HTTPS_PORT=${HTTPS_PORT:-443}
10-
10+
1111
certbot:
1212
environment:
1313
- SELF_SIGNED=true
14-
14+
1515
router:
1616
volumes:
1717
- ./api/public:/app/public
@@ -48,6 +48,7 @@ services:
4848
volumes:
4949
- ./front:/usr/src/front:rw,cached,z
5050
environment:
51+
- SKIP_YARN_INSTALL=${SKIP_YARN_INSTALL:-false}
5152
# On Linux, you may want to comment the following line for improved performance
5253
- WATCHPACK_POLLING="true"
5354
- NEXT_PUBLIC_ENTRYPOINT=
@@ -59,12 +60,13 @@ services:
5960
build:
6061
context: ./docker/front
6162
target: gally_example_dev
62-
additional_contexts:
63+
additional_contexts:
6364
front_src: ./front
6465
volumes:
6566
- ./front:/usr/src/front:rw,cached,z
6667
environment:
6768
- PUBLIC_URL=https://${SERVER_NAME:-gally.localhost}/example
69+
- SKIP_YARN_INSTALL=${SKIP_YARN_INSTALL:-false}
6870

6971
e2e:
7072
extends:
@@ -91,3 +93,4 @@ services:
9193
- traefik.http.routers.gally-mail-$COMPOSE_PROJECT_NAME-https.rule=Host(`mail.${SERVER_NAME:-gally.localhost}`)
9294
- traefik.http.routers.gally-mail-$COMPOSE_PROJECT_NAME-https.entrypoints=https
9395
- traefik.http.routers.gally-mail-$COMPOSE_PROJECT_NAME-https.tls=true
96+

docker/front/docker-entrypoint-pwa.sh

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,32 @@
22

33
fixuid || :
44

5-
rm -rf node_modules pwa/node_modules example-app/node_modules
5+
# Skip node_modules deletion and yarn install if SKIP_INSTALL is set to true
6+
# This is disabled by default as clean install are often necessary
7+
# Change this in env file at your own risk with the benefit of speeding up container startup
8+
if [ "$SKIP_YARN_INSTALL" != "true" ]; then
9+
echo "=== STARTING NODE_MODULES DELETION AND YARN INSTALL ==="
10+
echo "SKIP_YARN_INSTALL is not set to true"
611

7-
if [ -d gally-admin ]
8-
then
9-
rm -rf gally-admin/node_modules gally-admin/packages/components/node_modules gally-admin/packages/shared/node_modules
10-
fi
12+
rm -rf node_modules pwa/node_modules example-app/node_modules
13+
14+
if [ -d gally-admin ]
15+
then
16+
rm -rf gally-admin/node_modules gally-admin/packages/components/node_modules gally-admin/packages/shared/node_modules
17+
fi
1118

12-
yarn install --frozen-lockfile --network-timeout 120000
19+
yarn install --frozen-lockfile --network-timeout 120000
1320

14-
if [ -d gally-admin ]
15-
then
16-
cd gally-admin
17-
yarn build
18-
yarn cache clean
19-
cd ..
21+
if [ -d gally-admin ]
22+
then
23+
cd gally-admin
24+
yarn build
25+
yarn cache clean
26+
cd ..
27+
fi
28+
else
29+
echo "=== SKIPPING NODE_MODULES DELETION AND YARN INSTALL ==="
30+
echo "SKIP_INSTALL is set to true"
2031
fi
2132

2233
exec $@

0 commit comments

Comments
 (0)