Cache npm dzielony między kontenerami dockera

Summary: Ref T2306

Test Plan: Odpalić budowanie apki bez i z cachem. Apka z cachem powinna zbudować się dużo szybciej.

Reviewers: #reviewers, kuba-orlik

Reviewed By: #reviewers, kuba-orlik

Subscribers: jenkins-user

Maniphest Tasks: T2306

Differential Revision: https://hub.sealcode.org/D1085
master
Kavelach 3 years ago
parent dd8e14ab0c
commit 35ab332535

@ -11,6 +11,7 @@ services:
dockerfile: test.Dockerfile dockerfile: test.Dockerfile
volumes: volumes:
- ./:/opt/sealious/ - ./:/opt/sealious/
- ~/.npm_cacache:/opt/sealious/.npm_cacache
user: ${UID:-1000}:${GID:-1000} user: ${UID:-1000}:${GID:-1000}
mailcatcher: mailcatcher:
image: schickling/mailcatcher:latest image: schickling/mailcatcher:latest

@ -11,6 +11,13 @@ export SEALIOUS_PORT=$PORT
SEALIOUS_BASE_URL=$(cat .base_url) SEALIOUS_BASE_URL=$(cat .base_url)
export SEALIOUS_BASE_URL export SEALIOUS_BASE_URL
# Create the npm cache directory if it isn't present yet. If it is not present, it will be created
# when the docker image is being built with root:root as the owner.
mkdir -p ~/.npm_cacache
# Create .npm directory in the container, since it is not yet present and we need it for next step.
docker-compose run --user="$UID" --rm --service-ports test mkdir -p /opt/sealious/.npm
# Link the host-bound npm cache directory into the container's npm cache directory.
docker-compose run --user="$UID" --rm --service-ports test ln -s /opt/sealious/.npm_cacache /opt/sealious/.npm/_cacache
docker-compose up -d db docker-compose up -d db
./npm.sh ci ./npm.sh ci
./npm.sh run build:back; ./npm.sh run build:back;

@ -19,4 +19,4 @@ docker-compose run --user="$UID"\
echo "Deployed to https://${PORT}.dep.sealco.de" echo "Deployed to https://${PORT}.dep.sealco.de"
echo "Application logs should be available at https://jenkins.sealcode.org/job/Deploy%20to%20dep.sealco.de/ws/$PORT/log.html" echo "Application logs should be available at https://jenkins.sealcode.org/job/Deploy%20to%20dep.sealco.de/ws v2/$PORT/log.html"

Loading…
Cancel
Save