请在我的 Dockerfile , run.sh 文件和 index.js 文件源代码。通过运行此Dockerfile,我可以获得较旧的版本,但我想安装 Redis-4.0.1,node-10.15.3和MongoDB最新 版本 注意:这是工作代码。 https://stackoverflow.com/a/56875583/3815050
Dockerfile:
# Pull base image.
FROM ubuntu:14.04
# Install Node.js
RUN apt-get update
RUN apt-get install -y curl
RUN curl --silent --location https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install --yes nodejs
RUN apt-get install --yes build-essential
# Bundle angular app source
# Trouble with COPY http://stackoverflow.com/a/30405787/2926832
COPY . /src
# Install app dependencies
RUN cd /src
RUN npm install -g npm
#RUN npm install
# Binds to port 8080
EXPOSE 8080
# Installing redis server
RUN apt-get update && apt-get install -y redis-server
EXPOSE 6379
# Update the repository sources list
RUN apt-get update
# Install MongoDB.
RUN \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 && \
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' > /etc/apt/sources.list.d/mongodb.list && \
apt-get update && \
apt-get install -y mongodb-org && \
rm -rf /var/lib/apt/lists/* && \
cd /
COPY index.js .
# Define mountable directories.
VOLUME ["/data/db"]
# Define working directory.
WORKDIR /data
# Define default command.
#CMD ["mongod"]
# Expose ports.
# - 27017: process
# - 28017: http
EXPOSE 27017
EXPOSE 28017
ADD run.sh /run.sh
RUN chmod +x /run.sh
# Defines your runtime(define default command)
# These commands unlike RUN (they are carried out in the construction of the container) are run when the container
#ENTRYPOINT ["/usr/bin/redis-server"]
#CMD ["node", "index.js"]
RUN apt-get update && apt-get install -y dos2unix && dos2unix /run.sh
CMD ["/run.sh"]
run.sh文件中的代码:
#!/bin/bash
cd /data
/usr/bin/redis-server &
mongod &
node /index.js
index.js文件中的代码:
console.log("helllllllooooo");