質問編集履歴
1
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -77,18 +77,21 @@
|
|
77
77
|
```
|
78
78
|
で探していると思うのですが、Dockerコンテナがあるmyappディレクトリがないために、このエラーが出ているのではないかと考えました。
|
79
79
|
|
80
|
-
そこでDockerfileに```apt-get install -y yarn```を追記し、build後、コンテナ内に入り```yarn add admin-lte```コマンドを入力しましたができませんでした。
|
81
|
-
|
82
|
-
|
80
|
+
そこでDockerfileを以下に変更しbuildし直しました。
|
83
81
|
```
|
84
82
|
FROM ruby:3.1.2
|
85
83
|
|
86
84
|
ENV TZ Asia/Tokyo
|
87
85
|
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs && apt-get install -y vim
|
88
86
|
|
89
|
-
# Install npm and yarn
|
90
|
-
RUN apt-get install -y npm && \
|
91
|
-
|
87
|
+
# Install yarn
|
88
|
+
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
|
89
|
+
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
|
90
|
+
&& apt-get update \
|
91
|
+
&& apt-get install -y yarn
|
92
|
+
|
93
|
+
# Install npm
|
94
|
+
RUN apt-get update && apt-get install -y npm
|
92
95
|
|
93
96
|
# 作業ディレクトリを指定
|
94
97
|
RUN mkdir /myapp
|
@@ -96,18 +99,8 @@
|
|
96
99
|
ADD Gemfile /myapp/Gemfile
|
97
100
|
ADD Gemfile.lock /myapp/Gemfile.lock
|
98
101
|
RUN bundle install
|
102
|
+
COPY . /myapp
|
99
103
|
|
100
|
-
# Add yarn and install admin-lte
|
101
|
-
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
|
102
|
-
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
|
103
|
-
apt-get update && \
|
104
|
-
apt-get install -y yarn && \
|
105
|
-
mkdir -p node_modules/admin-lte && \
|
106
|
-
cd /myapp/node_modules/admin-lte && \
|
107
|
-
yarn install && \
|
108
|
-
cd /myapp
|
109
|
-
|
110
|
-
COPY . /myapp
|
111
104
|
COPY entrypoint.sh /usr/bin/
|
112
105
|
RUN chmod +x /usr/bin/entrypoint.sh
|
113
106
|
ENTRYPOINT ["entrypoint.sh"]
|
@@ -116,4 +109,34 @@
|
|
116
109
|
CMD ["rails", "server", "-b", "0.0.0.0"]
|
117
110
|
```
|
118
111
|
|
112
|
+
build後、ターミナルで```docker-compose run api yarn add admin-lte```を入力しインストールは成功。
|
113
|
+
```
|
114
|
+
hoge@MacBook-Air-2 sample_app % docker-compose run api yarn add admin-lte
|
115
|
+
Creating sample_app_api_run ... done
|
116
|
+
yarn add v1.22.19
|
117
|
+
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
|
118
|
+
[1/4] Resolving packages...
|
119
|
+
[2/4] Fetching packages...
|
120
|
+
[3/4] Linking dependencies...
|
121
|
+
warning " > tempusdominus-core@5.19.3" has unmet peer dependency "moment@^2.29.2".
|
122
|
+
[4/4] Building fresh packages...
|
123
|
+
success Saved lockfile.
|
124
|
+
success Saved 1 new dependency.
|
125
|
+
info Direct dependencies
|
126
|
+
└─ admin-lte@3.2.0
|
127
|
+
info All dependencies
|
128
|
+
└─ admin-lte@3.2.0
|
129
|
+
Done in 57.63s.
|
130
|
+
```
|
119
131
|
|
132
|
+
コンテナ内にあるか確認しました
|
133
|
+
```
|
134
|
+
hoge@MacBook-Air-2 sample_app % docker exec -it sample_app_api_1 bash
|
135
|
+
root@2c0e86939cec:/myapp# ls /myapp/node_modules/admin-lte/plugins/bootstrap/js/
|
136
|
+
bootstrap.bundle.js bootstrap.bundle.min.js bootstrap.js bootstrap.min.js
|
137
|
+
bootstrap.bundle.js.map bootstrap.bundle.min.js.map bootstrap.js.map bootstrap.min.js.map
|
138
|
+
root@2c0e86939cec:/myapp#
|
139
|
+
```
|
140
|
+
|
141
|
+
再度コンテナを立ち上げましたが、エラー内容は変わりませんでした。
|
142
|
+
|