質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

1回答

5619閲覧

『docker-compose run app rails assets:precompile』で『Yarn executable was not detected in the system.』

ryouya

総合スコア14

unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2020/06/01 04:51

編集2020/06/01 22:19

お世話になっております。
下記の問題について知見がある方がいらっしゃいましたらご教示お願いします。

#起きている問題
AWS環境でnginxunicornmysqldockerコンテナで構築しdocker-compose run app rails assets:precompile実行時に、Yarn executable was not detected in the system.と表示される。

$ docker-compose run app rails assets:precompile Starting coffee_app_db_1 ... done Yarn executable was not detected in the system.

#試したこと
####yarnがインストールされていないとのことなので、Dockerfileに追記。

Dockerfile

1FROM ruby:2.5.1 2RUN apt-get update -qq && \ 3 apt-get install -y apt-utils \ 4 build-essential \ 5 libpq-dev \ 6 nodejs \ 7 default-mysql-client \ 8 yarn ※ここを追記 9

docker-compose build成功後、docker-compose run app rails assets:precompileで同様のエラーが発生してしまいます。

####コンテナに入ってyarnをインストール

root@da3aa33866d4:/# apt-get install yarn Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package yarn root@da3aa33866d4:/# yarn -v bash: yarn: command not found

コンテナに直接yarnをインストールしたところE: Unable to locate package yarnが出力されました。

#関連ファイル
・docker-compose.yml

version: '2' services: app: build: context: . dockerfile: ./docker/rails/Dockerfile command: bundle exec unicorn_rails -c /var/www/rails/coffee_app/config/unicorn.conf.rb -D -E production # command: bundle exec rails s -p 3000 -b '0.0.0.0' ports: - '3000:3000' volumes: - /var/tmp - .:/coffee_app depends_on: - db extends: file: ./docker/mysql/password.yml service: password db: build: context: . dockerfile: ./docker/mysql/Dockerfile ports: - '3300:3306' volumes: - db_data:/var/lib/mysql extends: file: ./docker/mysql/password.yml service: password nginx: build: context: . dockerfile: ./docker/nginx/Dockerfile ports: - '88:80' volumes: - app volumes: db_data:

・Dockerfile(rails)

FROM ruby:2.5.1 RUN apt-get update -qq && \ apt-get install -y apt-utils \ build-essential \ libpq-dev \ nodejs \ default-mysql-client \ yarn RUN mkdir /coffee_app WORKDIR /coffee_app ADD Gemfile /coffee_app/Gemfile ADD Gemfile.lock /coffee_app/Gemfile.lock RUN bundle install -j4 ADD . /coffee_app EXPOSE 3000

・Dockerfile(mysql)

FROM mysql:8.0.17 RUN apt-get update && \ apt-get install -y apt-utils \ locales && \ rm -rf /var/lib/apt/lists/* && \ echo "ja_JP.UTF-8 UTF-8" > /etc/locale.gen && \ locale-gen ja_JP.UTF-8 ENV LC_ALL ja_JP.UTF-8 ADD ./docker/mysql/charset.cnf /etc/mysql/conf.d/charset.cnf ・nginx/Dockerfile(rails) FROM ruby:2.5.1 RUN apt-get update -qq && \ apt-get install -y apt-utils \ build-essential \ libpq-dev \ nodejs \ default-mysql-client \ yarn RUN mkdir /coffee_app WORKDIR /coffee_app ADD Gemfile /coffee_app/Gemfile ADD Gemfile.lock /coffee_app/Gemfile.lock RUN bundle install -j4 ADD . /coffee_app EXPOSE 3000

#環境
ruby 2.5.1
rails 5.1.6
docker version 19.03.6
docker-compose version 1.24.0

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

yarnがインストールされていないとのことなので、Dockerfileに追記。

コンテナに直接yarnをインストールしたところE: Unable to locate package yarnが出力されました。

単純にインストールの方法が間違っているだけだと思います。

公式サイトを見てコンテナのベースイメージのディストリビューション(たぶんdebianのリポジトリ登録をやってないというオチでしょう)の手順に従ってインストールすれば良いと思いますが。

投稿2020/06/01 22:08

gentaro

総合スコア8949

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ryouya

2020/06/01 22:14

ご回答ありがとうございますm(_ _)m 添付してくださったサイト確認します。
ryouya

2020/06/03 09:37

Dockerfile(rails)に下記を追記しdocker-compose run app rails db:migrateを実行しましたが、構文エラーが発生しました。 ``` FROM ruby:2.5.1 RUN apt-get update && apt-get install apt-transport-https -y RUN curl -sL https://deb.nodesource.com/setup_10.x RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN apt-get update -qq && \ apt-get install -y apt-utils \ build-essential \ libpq-dev \ nodejs \ default-mysql-client \ yarn : ``` ``` $ docker-compose run app rails assets:precompile Starting coffee_app_db_1 ... done /usr/share/yarn/lib/cli.js:46099 let { ^ SyntaxError: Unexpected token { at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/usr/share/yarn/bin/yarn.js:24:13) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) ```
ryouya

2020/06/04 00:03

ご回答ありがとうございますm(_ _)m ご指摘いただいた箇所を修正したところ、docker-compose run app rails assets:precompileが通りました! ありがとうございました!!m(_ _)m ``` $ docker-compose run app rails assets:precompile Starting coffee_app_db_1 ... done yarn install v1.22.4 [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... success Saved lockfile. Done in 0.15s. ```
gentaro

2020/06/04 00:10

どういたしまして。 解決されたなら解決済みとしておいてください。
ryouya

2020/06/04 00:17

すみません、遅れましたm(_ _)m ありがとうございましたm(_ _)m
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問