docker compose run -- I want rm webbin/setup to run yarn install

Asked 1 years ago, Updated 1 years ago, 353 views

I want yarn to work in dockefile web container.And
docker compose run --rm webbin/setup to run yarn install.
This is the current error.

The Gemfile's dependencies are satified
Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install

== Command ["bin/yarn"] failed ==
  • Cannot find yanr in container
root@d5ddf41fc3c6:/rails-docker-mysql#yarn --version
bash: yarn: command not found
  • Docker-compose up can boot the server

Dockerfile

#Node.js&yarn
FROM node —16-buster-slim
COPY --from=node/opt/yarn-*/opt/yarn
COPY --from=node/usr/local/bin/node/usr/local/bin/
COPY --from=node/usr/local/lib/node_modules/usr/local/lib/node_modules/
RUN ln-fs/usr/local/lib/node_modules/npm/bin/npm-cli.js/usr/local/bin/npm\
  &ln-fs/usr/local/lib/node_modules/npm/bin/npm-cli.js/usr/local/bin/npx\
  &ln-fs/opt/yarn/bin/yarn/usr/local/bin/yarn\
  &ln-fs/opt/yarn/bin/yarnpkg/usr/local/bin/yarnpkg

# Rails
FROM ruby: 2.7.7
RUN apt-get update
RUN apt-get install-y\
    build-essential\
    default-mysql-client



WORKDIR/rails-docker-mysql
COPY Gemfile Gemfile.lock/rails-docker-mysql/
RUN bundle install

docker-compose.yml

version:"3"

volumes:
  data:

services:
  web:
    build:.
    command: bundle exec rails -p 3000-b '0.0.0.0'

    ports:
      - "3000:3000"
    volumes:
      - ".:/ rails-docker-mysql"
    environment:
      - "DATABASE_PASSWORD=password"
    tty —true
    stdin_open —true
    depend_on:
      - db

  db:
    image —mysql
    volumes:
      - "data:/var/lib/mysql"
    environment:
      MYSQL_ROOT_PASSWORD:password
    ports:
      - "3306:3306"

If the dockerfile or docker-compose.yml description is incorrect, please correct it

ruby-on-rails docker docker-compose

2023-01-25 15:57

1 Answers

Speculation is included as there is no environment to try directly.

Looking at the contents of the base Docker image, we have created a symbolic link to /usr/local/bin/yarn for /opt/yarn-v${YARN_VERSION}/bin/yarn, and it seems that the yarn command can be used normally without any user action.

docker-node/16/buster-slim/Dockerfile

&tar-xzf yarn-v$YARN_VERSION.tar.gz-C/opt/\
  &ln-s/opt/yarn-v$YARN_VERSION/bin/yarn/usr/local/bin/yarn\

However, the Dockerfile I'm asking is re-creating a symbolic link to a file called /opt/yarn/bin/yarn, which probably doesn't exist, so I feel that the file is invalid and eventually the yarn command fails.

RUN ln-fs/usr/local/lib/node_modules/npm/bin/npm-cli.js/usr/local/bin/npm\
  &ln-fs/usr/local/lib/node_modules/npm/bin/npm-cli.js/usr/local/bin/npx\
  &ln-fs/opt/yarn/bin/yarn/usr/local/bin/yarn\
  &ln-fs/opt/yarn/bin/yarnpkg/usr/local/bin/yarnpkg

/opt/yarn/bin/Try to see if you can start the container and run the yarn command with symbolic links excluded below.


2023-01-25 16:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.