我正在构建和托管反应应用程序,运行它的脚本如下:
npm run build;
npm install -g serve
serve -s build
但是当我跑步时,它表示它正在localhost:5000
上运行,但当我转到它时它会返回一个空响应。
我是从继承自node
image。
搬运工-compose.yml:
version: '3'
services:
frontend:
build: ./frontend
command: ["./docker_up.sh"]
restart: always
volumes:
- ./frontend:/app/frontend
- node-modules:/app/frontend/node_modules
ports:
- "3000:3000"
- "5000:5000"
- "80:80"
- "443:443"
environment:
- MODE=PROD
volumes:
node-modules:
Dockerfile:
FROM node
WORKDIR /app/frontend
COPY package.json /app/frontend
COPY build/* /usr/share/nginx/html/
RUN npm install
EXPOSE 3000
EXPOSE 5000
EXPOSE 80
EXPOSE 443
CMD ["docker_up.sh"]
docker_up.sh:
#!/bin/bash
if [ $MODE == "PROD" ]; then
echo "Using production settings.";
apt-get update;
apt-get install xsel;
npm run build;
npm install -g serve
serve -s build
else
echo "Using development settings."
npm start;
fi;