我正在尝试通过具有NGINX前端的Docker容器(带有Docker Compose)将使用create-react-app创建的应用构建和部署到EC2实例。
npm run build
之后,我启动了容器并收到以下错误:
docker-compose up nodejs
Starting app_nodejs_1 ... done
Attaching to app_nodejs_1
app_nodejs_1 exited with code 0
docker-compose.yml
version: '2'
services:
nodejs:
build:
context: ./nodejs
args:
- PUID=1100
- PGID=1100
expose:
- "3000"
extra_hosts:
- "dockerhost:10.0.75.1"
nginx:
restart: always
build:
context: ./nginx
args:
- NODEJS_UPSTREAM=nodejs
ports:
- "80:80"
volumes:
- ./logs/nginx/:/var/log/nginx
links:
- nodejs:nodejs
extra_hosts:
- "dockerhost:10.0.75.1"
NGINX Dockerfile
FROM nginx:alpine
ADD nginx.conf /etc/nginx/
COPY sites/*.conf /etc/nginx/sites-available/
ARG NODEJS_UPSTREAM=nodejs
RUN apk update \
&& apk upgrade \
&& apk add --no-cache bash \
&& adduser -D -H -u 1000 -s /bin/bash www-data \
&& rm /etc/nginx/conf.d/default.conf \
&& echo "upstream nodejs-upstream { server ${NODEJS_UPSTREAM}:3000; }" > /etc/nginx/conf.d/upstream.conf
CMD ["nginx"]
EXPOSE 80 443
Nodejs Dockerfile
FROM node:8.9
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "vim"]
ARG PUID=1100
ARG PGID=1100
RUN groupadd -g $PGID appuser && \
useradd -u $PUID -g appuser -m appuser
RUN mkdir -p /usr/src/app
RUN chown -R appuser:appuser /usr/src/app
USER appuser
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
RUN npm run build
EXPOSE 3000
有人可以解释此错误的含义以及如何解决或解决该问题吗?