現在、Dockerを使ってRailsの環境構築をしております。
application.htmlのbodyタグにhello_vueを読み込むようにしているのですが、呼ばれません。
(呼ばれているならHello Vue!と表示されます)
コンソール上にも、ログにもエラーが出ていないので戸惑っております。
どこか気になった点でも、ご教示頂けますと幸いです。
dockerfile
FROM
1 2RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ 3 && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list 4 5RUN apt-get update -qq && apt-get install -y nodejs postgresql-client yarn 6RUN mkdir /app 7WORKDIR /app 8COPY Gemfile /app/Gemfile 9COPY Gemfile.lock /app/Gemfile.lock 10RUN bundle install 11COPY . /myapp 12 13# Add a script to be executed every time the container starts. 14COPY entrypoint.sh /usr/bin/ 15RUN chmod +x /usr/bin/entrypoint.sh 16ENTRYPOINT ["entrypoint.sh"] 17EXPOSE 3000 18 19# Start the main process. 20CMD ["rails", "server", "-b", "0.0.0.0"]
docker-compose.yaml
version: '3' services: db: image: postgres volumes: - ./tmp/db:/var/lib/postgresql/data app: build: . command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/app ports: - "3000:3000" depends_on: - db
application.html
<body> <%= yield %> <%= javascript_pack_tag 'hello_vue' %> </body>
hello_vue.js
import Vue from 'vue' import App from '../app.vue' document.addEventListener('DOMContentLoaded', () => { const app = new Vue({ render: h => h(App) }).$mount() document.body.appendChild(app.$el) console.log(app) })
app.vue
<template> <div id="app"> <p>{{ message }}</p> </div> </template> <script> export default { data: function () { return { message: "Hello Vue!" } } } </script> <style scoped> p { font-size: 2em; text-align: center; } </style>
やったこと
上記の環境で、docker-compose up
ルーティングは合わせております。
hello_vue.js
とapp.vue
は初期状態のままで編集はしていません
回答1件
あなたの回答
tips
プレビュー