Skip to content

Commit

Permalink
Fix local docker setup to add support for yarn v3 (#905)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sra405 authored Jan 25, 2024
1 parent 43201e3 commit 16f15b3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist/
.git/
node_modules/
.yarn/
.yarnrc.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
node_modules
/.pnp
.pnp.js
.yarn

# testing
/coverage
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 16f15b3

Please sign in to comment.