Hmmm... After googling for a bit and trying different things, I was able to make it work by eliminating that part and installing yarn after nodejs like this:
RUN npm install -g yarn
At least, running docker-compose up worked. Not sure if I will run into other issues in the next step.