Rails 5.2.3
Puma 3.12.1
我已经对我的rails应用程序进行了docker化,当我使用命令rails s puma
启动容器时,Puma会启动,然后静默退出:
=> Booting Puma
=> Rails 5.2.3 application starting in production
=> Run `rails server -h` for more startup options
此后没有更多日志,并且容器不再运行。 Puma在docker之外仍然可以正常工作。
有什么想法吗?
编辑
Dockerfile
FROM ruby:2.4.5
RUN sed -i '/jessie-updates/d' /etc/apt/sources.list
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt-get update -qq && apt-get install -y build-essential nodejs && \
apt-get clean
RUN gem install bundler # ensure bundler 2
RUN gem cleanup
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 && \
apt-get update && apt-get install -y apt-utils yarn && \
gem install rails -v 5.2.3
ARG environment
RUN echo $environment
ENV RAILS_ENV=$environment
ENV DOCKER_IMAGE_BUILD=true
# ------------------------
# SSH Server support
# ------------------------
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssh-server build-essential nodejs cron nano systemd \
&& echo "root:Docker!" | chpasswd
COPY sshd_config /etc/ssh/
RUN mkdir /myapp
WORKDIR /myapp
COPY . /myapp
RUN bundle -v
RUN bundle install
RUN yarn install
EXPOSE 3000 2222
COPY init_container.sh /myapp
RUN chmod 755 /myapp/init_container.sh
ENTRYPOINT ["/myapp/init_container.sh"]
init_container.sh:
#!/usr/bin/env bash
cat >/etc/motd <<EOL
_____
/ _ \ __________ _________ ____
/ /_\ \\___ / | \_ __ \_/ __ \
/ | \/ /| | /| | \/\ ___/
\____|__ /_____ \____/ |__| \___ >
\/ \/ \/
A P P S E R V I C E O N L I N U X
Documentation: http://aka.ms/webapp-linux
NodeJS quickstart: https://aka.ms/node-qs
EOL
cat /etc/motd
service ssh start
# whenever has to be run from the main app folder.
# it will look for schedule.rb in /myapp/config folder
cd /myapp
whenever --update-crontab
# restart cron after updating crontab
service cron restart
# for logging
crontab -l
bundle exec rails assets:precompile
yarn install
rails s puma
答案 0 :(得分:0)
不是红宝石专家,但这是我将要看到的事情。
猛扑到容器中,查看您在/myapp
目录中复制的应用文件是否实际存在。
docker exec -it <container name> /bin/bash
如果这样做,请尝试手动运行./init_container.sh
,然后看看会发生什么。
使用bash,您实际上可以检查日志并弄清楚发生了什么,因为容器仍在运行。