From 16f15b3168e2ba1b72358f693c8fb28eb46a05fa Mon Sep 17 00:00:00 2001 From: Scott Adams <74183390+sra405@users.noreply.github.com> Date: Thu, 25 Jan 2024 17:14:41 +0000 Subject: [PATCH] Fix local docker setup to add support for yarn v3 (#905) Yarn v3 needs: - activating inside Dockerfile - volumes need mounting in docker-compose ### Notes - `yarnrc.yml` could be different between environments (i.e. local machine and container) so ignoring the file in the repo and generating one on build in docker --- .dockerignore | 1 + .gitignore | 1 + CHANGELOG.md | 4 ++++ Dockerfile | 8 ++++++++ docker-compose.yml | 7 ++++++- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index b97d1fe3e..61592c09b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,4 @@ dist/ .git/ node_modules/ .yarn/ +.yarnrc.yml diff --git a/.gitignore b/.gitignore index 9587af7c6..efe2593f4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ node_modules /.pnp .pnp.js +.yarn # testing /coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index a3b9bb9a6..ce36a6687 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +### Fixed + +- Local docker setup with yarn v3 (#905) + ## [0.21.2] - 2024-01-23 ### Changed diff --git a/Dockerfile b/Dockerfile index ccfa11308..4dd9d0e5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,14 @@ WORKDIR /app COPY package.json yarn.lock ./ COPY . /app + +RUN corepack enable \ + && corepack prepare yarn@stable --activate \ + && yarn set version 3.4.1 \ + && echo -e "nodeLinker: node-modules\n\n$(cat /app/.yarnrc.yml)" > /app/.yarnrc.yml \ + && cat /app/.yarnrc.yml \ + && printf "Switched to Yarn version: "; yarn --version + RUN yarn EXPOSE 3000 diff --git a/docker-compose.yml b/docker-compose.yml index 17fc75c95..648e05168 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,13 @@ services: context: . volumes: - .:/app - - /app/node_modules - /var/run/docker.sock:/var/run/docker.sock + - /app/.yarn + - $PWD/.yarn/plugins:/app/.yarn/plugins + - $PWD/.yarn/releases:/app/.yarn/releases + - $PWD/.yarn/patches:/app/.yarn/patches + - $PWD/.yarn/sdks:/app/.yarn/sdks + - $PWD/.yarn/versions:/app/.yarn/versions stdin_open: true react-ui: <<: *x-app