我通常是docker和DevOps的新手。我在一些在线文章的帮助下构建了Docker容器,就像在照片中一样,我看到该容器正在与Nginx一起运行,但是当我尝试检查日志时,我在日志中什么也没有看到,并且我的站点已关闭。 react是react typescript应用程序,我正在使用Amazon EC2实例。这是我的docker-compose代码
version: '3.7'
services:
react-frontend:
container_name: react-frontend
build:
context: .
dockerfile: Dockerfile
volumes:
- '.:/app'
- '/app/node_modules'
ports:
- '3000:3000'
environment:
- NODE_ENV=development
这是我的docker代码`
FROM node:10-alpine as builder
# install and cache app dependencies
COPY package.json package-lock.json ./
RUN npm install && mkdir /react-frontend && mv ./node_modules ./react-frontend
WORKDIR /react-frontend
COPY . .
RUN npm run build
# ------------------------------------------------------
# Production Build
# ------------------------------------------------------
FROM nginx:1.16.0-alpine
COPY --from=builder /react-frontend/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]`