Skip to content

Commit 41ac37a

Browse files
committed
[Docker] Add env var to skip yarn install if necessary
1 parent 53138b1 commit 41ac37a

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
@@ -49,6 +49,7 @@ services:
4949
volumes:
5050
- ./front:/usr/src/front:rw,cached,z
5151
environment:
52+
- SKIP_YARN_INSTALL=${SKIP_YARN_INSTALL:-false}
5253
# On Linux, you may want to comment the following line for improved performance
5354
- WATCHPACK_POLLING="true"
5455
- NEXT_PUBLIC_ENTRYPOINT=
@@ -60,12 +61,13 @@ services:
6061
build:
6162
context: ./docker/front
6263
target: gally_example_dev
63-
additional_contexts:
64+
additional_contexts:
6465
front_src: ./front
6566
volumes:
6667
- ./front:/usr/src/front:rw,cached,z
6768
environment:
6869
- PUBLIC_URL=https://${SERVER_NAME:-gally.localhost}/example
70+
- SKIP_YARN_INSTALL=${SKIP_YARN_INSTALL:-false}
6971

7072
e2e:
7173
extends:
@@ -92,3 +94,4 @@ services:
9294
- traefik.http.routers.gally-mail-$COMPOSE_PROJECT_NAME-https.rule=Host(`mail.${SERVER_NAME:-gally.localhost}`)
9395
- traefik.http.routers.gally-mail-$COMPOSE_PROJECT_NAME-https.entrypoints=https
9496
- traefik.http.routers.gally-mail-$COMPOSE_PROJECT_NAME-https.tls=true
97+

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)