[RUBY] Install yarn in docker image

background

When deploying a Rails application (v5.2.4) created using Docker to a production environment, when I tried to precompile the assets, I got the following error and could not execute it.

$docker-compose run web bundle exec rake assets:precompile RAILS_ENV=production
Starting excite-map_db_1 ... done
Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/instal

How to solve

Add the following to the Dockerfile

RUN curl https://deb.nodesource.com/setup_12.x | bash
RUN curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update && apt-get install -y nodejs yarn postgresql-client

reference

https://github.com/yarnpkg/yarn/issues/7329

Recommended Posts

Install yarn in docker image
Install openjdk8 on Docker image (Debian)
Install laravel/Dusk in docker environment (laravel6)
Build Spring Boot + Docker image in Gradle
Docker in LXD
[Docker] Start container, start bash in container, delete image
Just install Laravel8 on docker in PHP8 environment
Install Docker on Manjaro
How to install Docker
Delete unused docker image
Install Composer with Docker
Dramatically speed up slow bundle install in docker environment
Command memo to install xeyes in ubuntu docker environment
Install Docker on Raspberry Pi
Install Docker on Windows 10 PRO
Install CentOS Stream8 in VirtualBox
Install by specifying the version of Django in the Docker environment
docker review image creation-container start
Install the plugin in Eclipse
Install docker and docker-compose on ubuntu in the shortest process
Extract files from Docker Image
npm error in docker tutorial
Install docker on AWS EC2
[Docker] dokcer-compose run, Please run `yarn install –check-files` to update. Error
Install docker, docker-compose for debin10
Install tomcat plugin in eclipse
JavaFX-Load Image in the background
Install lsb_release from the command line when lsb_release fails in docker environment
Install Docker on AWS Ubunt 20.04 LTS
Run lambda with custom docker image
Install java with Ubuntu 16.04 based Docker
Let's summarize Docker in an atmosphere
Run LibreOffice Basic macros in Docker
[Ruby on Rails] yarn install --check-files
Create a lightweight STNS Docker image
yarn install fails "getaddrinfo EAI_AGAIN registry.yarnpkg.com"
Install CentOS Stream 8 in Hyper-V environment
Migrate Docker image to another server
Install a CA certificate in ColdFusion
How to install Bootstrap in Ruby
Deploy Flask's Docker image on Heroku
Hit the Docker API in Rust
Include image resources in jar file
2. Create Docker image and register Registry
Gats by new with yarn (Docker)
Restart apache with docker php-apache image
Error summary in bundle install. memorandum
Challenge to install WSL2 and docker
[Splunk] Build Splunk Enterprise (use docker image)
Check MySQL logs in Docker environment
How to install Swiper in Rails
Email sending error "dh key too small" in Redmine's official Docker Image
Install Zabbix 5.0 with Docker → Set up Slack notification in case of failure
[AWS CLI] Switch roles to get a Docker image in another account