Skip to content

Commit

Permalink
Improve yarn and pipenv experience during development (#803)
Browse files Browse the repository at this point in the history
Both yarn and pipenv have had to re-create their caches from scratch whenever `docker-compose` is run, which made `bash docker-update.sh` particularly slow.  Now they use persistent caches backed by Docker volumes, which should make things faster.

We also now mount a `/.yarnrc` at the root of the Docker image to tell yarn to install packages in `/node_modules`, so we don't have to manually pass `--modules-folder` whenever we run yarn ourselves.
  • Loading branch information
toolness authored Aug 9, 2019
1 parent 74922f7 commit 80b1898
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .docker-yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--modules-folder /node_modules
--cache-folder /var/yarn-cache
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ volumes:
unused-node-modules:
python-venv:
pgdata:
yarn-cache:
pipenv-cache:
11 changes: 10 additions & 1 deletion docker-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@ services:
# root of the container) to store all our things.
- unused-node-modules:/tenants2/node_modules/
- node-modules:/node_modules/
- .docker-yarnrc:/.yarnrc
- yarn-cache:/var/yarn-cache/
- pipenv-cache:/var/pipenv-cache/
environment:
# This is used by pipenv, but not really documented anywhere:
# https://github.com/pypa/pipenv/blob/master/pipenv/environments.py#L208
- VIRTUAL_ENV=/venv

- PYTHONUNBUFFERED=yup
- PIPENV_CACHE_DIR=/var/pipenv-cache

# This disables an annoying "Pipenv found itself running within a virtual environment"
# warning.
- PIPENV_VERBOSITY=-1

- DDM_VENV_DIR=/venv
- DDM_USER_OWNED_DIRS=/venv:/node_modules
- DDM_USER_OWNED_DIRS=/venv:/node_modules:/var/yarn-cache:/var/pipenv-cache
- DDM_HOST_USER=justfix
- DDM_IS_RUNNING_IN_DOCKER=yup
- CHOKIDAR_USEPOLLING=1
Expand Down
2 changes: 1 addition & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pipenv install --dev --keep-outdated
pip install -r requirements.production.txt

echo "----- Updating Node Dependencies -----"
yarn install --modules-folder /node_modules --frozen-lockfile
yarn install --frozen-lockfile

echo "----- Rebuilding GraphQL queries -----"
yarn querybuilder
Expand Down

0 comments on commit 80b1898

Please sign in to comment.