I’m using the last RedwoodJS version (6.6.0) and I’ve realized there’s a new experimental Docker feature in it… Let’s say I create a new project from scratch with:
yarn create redwood-app myproject
After entering its folder I’ve executed yarn rw exp setup-docker and then I tried running the development docker-compose file with:
docker-compose -f docker-compose.dev.yml up --build
Hey @ramuyk, I think you’ve just alerted me to a bug in yarn rw exp setup-docker as of v6.6.0 which just went out today (yesterday now). In that version, we upgraded new projects to yarn v4. That meant two things both related to the .yarn directory:
we don’t need .yarn/plugins anymore because they’re included in yarn v4
we don’t need .yarn/releases because yarn now recommends using corepack
I didn’t update yarn rw exp setup-docker to account for these changes, so it’s trying to copy files that don’t exist. I’ll work on that in the next patch.
For now you should be able to get things back to working by downgrading the version of yarn to v3.7.0, then running the experimental setup command again:
# If you're on yarn v4 right now and need to downgrade:
yarn set version v3 --yarn-path
yarn
yarn rw exp setup-docker
It’s still looking for those files. This is a project I’ve started from scratch again… Commenting these lines in the Dockerfile doesn’t solve the issue either. Is there anything else I should do? Besides the yarn and RedwoodJS version, my docker is the 24.0.7.
Hmmm I’m guessing you didn’t re-run the docker setup command? I included it in the codeblock because it’d be necessary to re-run afterwards to pull in yarn’s workspace-tools plugin:
But if you don’t want to do that, you can add workspace tools:
Cool, my mistake was that I thought that the global version of yarn would remain the same inside the newly created project… Changing the yarn version after creating the project worked, thanks!
I’m not sure if this is the right place or if I should open a new issue, but I have an already existing RedwoodJS project on version 6.3.1… I’ve failed to make the docker experimental feature work after an upgrade… Basically, I’ve upgraded my project:
yarn rw upgrade
After that, I have the following versions in my project:
yarn --version
3.6.3
yarn rw --version
6.6.0
Then I’ve added the docker setup:
yarn rw exp setup-docker
✔ Confirmation
✔ Adding the official yarn workspace-tools plugin...
✔ Adding @redwoodjs/api-server and @redwoodjs/web-server...
✔ Successfully wrote file `./.dockerignore`
✔ Adding postgres to .gitignore...
✔ Adding config to redwood.toml...
We've written four files:
- ./Dockerfile
- ./.dockerignore
- ./docker-compose.dev.yml
- ./docker-compose.prod.yml
To start the docker compose dev:
docker compose -f docker-compose.dev.yml up
Then, connect to the container and migrate your database:
docker compose -f ./docker-compose.dev.yml run --rm -it console /bin/bash
root@...:/home/node/app# yarn rw prisma migrate dev
Lastly, ensure you have Docker. If you don't, see https://docs.docker.com/desktop/
There's a lot in the Dockerfile and there's a reason for every line.
Be sure to check out the docs: https://redwoodjs.com/docs/docker
Now if I run the command for starting the container it stops the build on the 11th step:
docker compose -f docker-compose.dev.yml up
[+] Building 8.3s (18/36) docker:default
=> [redwood internal] load .dockerignore 0.0s
=> => transferring context: 182B 0.0s
=> [redwood internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 3.93kB 0.0s
=> [redwood internal] load metadata for docker.io/library/node:18-bookworm-slim 1.3s
=> [console internal] load .dockerignore 0.0s
=> => transferring context: 182B 0.0s
=> [console internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 3.93kB 0.0s
=> [redwood internal] load build context 0.1s
=> => transferring context: 3.27MB 0.0s
=> CACHED [redwood internal] settings cache mount permissions 0.0s
=> [redwood base 1/14] FROM docker.io/library/node:18-bookworm-slim@sha256:fe687021c06383a2bc5eafa6db29b627ed28a55f6bdfbcea108f 0.0s
=> [console internal] load build context 0.7s
=> => transferring context: 149.66MB 0.7s
=> CACHED [redwood base 2/14] RUN apt-get update && apt-get install -y openssl && rm -rf /var/lib/apt/lists/* 0.0s
=> CACHED [redwood base 3/14] WORKDIR /home/node/app 0.0s
=> CACHED [redwood base 4/14] COPY --chown=node:node .yarn/plugins .yarn/plugins 0.0s
=> CACHED [redwood base 5/14] COPY --chown=node:node .yarn/releases .yarn/releases 0.0s
=> CACHED [redwood base 6/14] COPY --chown=node:node .yarnrc.yml . 0.0s
=> CACHED [redwood base 7/14] COPY --chown=node:node package.json . 0.0s
=> CACHED [redwood base 8/14] COPY --chown=node:node api/package.json api/ 0.0s
=> CACHED [redwood base 9/14] COPY --chown=node:node web/package.json web/ 0.0s
=> [redwood base 10/14] COPY --chown=node:node yarn.lock . 0.1s
=> [redwood base 11/14] RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,uid=1000 --mount=type=cache,target=/home/ 6.8s
=> => # ➤ YN0060: │ web@workspace:web provides react-dom (p581c4) with version 18.2.0, which doesn't satisfy what @redwoodjs/router an
=> => # d some of its descendants request
=> => # ➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is
=> => # the six-letter p-prefixed code
=> => # ➤ YN0000: └ Completed in 0s 363ms
=> => # ➤ YN0000: ┌ Fetch step
If I try to create a project from scratch as in my original question it works fine, I’d like to avoid manually passing my code to a new project to solve this problem. Does anyone have any idea of what could be happening?
I’m not sure how the output of yarn explain peer-requirements could help me, it generates more than 1000 lines of output… However, even in a functional project that I’ve started from scratch, this command still returns an output with hundreds of lines.
Not exactly, it freezes on the 11th step while building the Dockerfile
=> [redwood base 11/14] RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,uid=1000 --mount=type=cache,target=/home/ 6.8s
=> => # ➤ YN0060: │ web@workspace:web provides react-dom (p581c4) with version 18.2.0, which doesn’t satisfy what @redwoodjs/router an
=> => # d some of its descendants request
=> => # ➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements for details, where is
=> => # the six-letter p-prefixed code
=> => # ➤ YN0000: └ Completed in 0s 363ms
=> => # ➤ YN0000: ┌ Fetch step
In this example, I had just opened it, but it stops there forever and the container is not running yet. It stays hours in it and never passes this step (this is in a project I’ve upgraded from version 6.3.1).
Ah, I’ve executed yarn cache clean and now it works… Even if I try to clone my repository from scratch and follow the procedure I’ve described in my last question it works…
I think it was more a issue with my yarn installation than the RedwoodJS.