我正在将节点应用程序部署到aws eb,这是我的Dockerfile
FROM ubuntu:14.04
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Install base packages
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
zsh \
vim \
git \
curl \
build-essential \
nodejs \
npm \
supervisor
RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
RUN mkdir -p /var/run/sshd /var/log/supervisor
COPY build/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN mkdir -p /app
ADD api/ /app
RUN cd /app && npm install
WORKDIR /app
EXPOSE 8090
CMD ["/usr/bin/supervisord"]
这是我的supervisord.conf
[supervisord]
nodaemon=true
[program:nodejs]
directory=/app
command=node server.js web
autorestart = true
stdout_logfile=/var/log/%(program_name)s.log
stderr_logfile=/var/log/%(program_name)s.log
这是我的stdouterr.log
/usr/lib/python2.7/dist-packages/supervisor/options.py:295: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching '
2016-04-08 16:48:37,892 CRIT Supervisor running as root (no user in config file)
2016-04-08 16:48:37,892 WARN Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
2016-04-08 16:48:37,909 INFO RPC interface 'supervisor' initialized
2016-04-08 16:48:37,909 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2016-04-08 16:48:37,910 INFO supervisord started with pid 1
2016-04-08 16:48:38,912 INFO spawned: 'nodejs' with pid 11
2016-04-08 16:48:39,332 INFO exited: nodejs (exit status 8; not expected)
2016-04-08 16:48:40,334 INFO spawned: 'nodejs' with pid 13
2016-04-08 16:48:40,732 INFO exited: nodejs (exit status 8; not expected)
2016-04-08 16:48:42,736 INFO spawned: 'nodejs' with pid 15
2016-04-08 16:48:43,414 INFO exited: nodejs (exit status 8; not expected)
2016-04-08 16:48:46,419 INFO spawned: 'nodejs' with pid 17
2016-04-08 16:48:47,288 INFO exited: nodejs (exit status 8; not expected)
2016-04-08 16:48:48,289 INFO gave up: nodejs entered FATAL state, too many start retries too quickly
此时任何建议都有帮助。
答案 0 :(得分:0)
在提到的评论中,@ AssafLavie节点应用程序崩溃了。它崩溃的原因是因为我必须将npm
和package.json
版本设置为Dockerfile
文件中的指定版本。
我的FROM ubuntu:14.04
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Install base packages
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
zsh \
vim \
git \
curl \
build-essential \
nodejs \
npm \
supervisor
RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
# Added the following 5 lines
RUN npm install -g n
RUN n 5.0.0
RUN rm /usr/bin/node
RUN ln -s /usr/local/bin/node /usr/bin/node
RUN npm install npm@3.8.5 -g
# End of the added lines to specify node and npm versions
RUN mkdir -p /var/run/sshd /var/log/supervisor
COPY build/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN mkdir -p /app
ADD api/ /app
RUN cd /app && npm install
WORKDIR /app
EXPOSE 8090
CMD ["/usr/bin/supervisord"]
现在看起来像
{{1}}