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
Build Spring Boot + Docker image in Gradle
[Docker] Start container, start bash in container, delete image
How to install Docker
Dramatically speed up slow bundle install in docker environment
Install the plugin in Eclipse
Install docker and docker-compose on ubuntu in the shortest process
Install docker, docker-compose for debin10
Install tomcat plugin in eclipse
JavaFX-Load Image in the background
Install a CA certificate in ColdFusion
Include image resources in jar file
2. Create Docker image and register Registry
[Splunk] Build Splunk Enterprise (use docker image)
How to install Swiper in Rails
Install Zabbix 5.0 with Docker → Set up Slack notification in case of failure