Dockerfile优化
Dockerfile优化
Dockerfile文件优化
$cat > Dockerfile <<EOF FROM node:9.11.1-alpine as build-stage RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY package*.json /usr/src/app/ RUN npm install COPY . . RUN npm run build # production stage FROM nginx:1.13.12-alpine as production-stage COPY --from=build-stage /usr/src/app/dist /usr/share/nginx/html COPY ./nginx/nginx.conf /etc/nginx/nginx.conf COPY ./nginx/sites-enabled /etc/nginx/sites-enabled COPY ./nginx/general.conf /etc/nginx/general.conf WORKDIR /app RUN go build -o main . RUN adduser -S -D -H -h /app appuser USER appuser EXPOSE 80 VOLUME [ "/testdata","/testdata2" ] CMD ["nginx", "-g", "daemon off;"] EOF
.dockerignore
$ cat > .dockerignore <<EOF node_modules npm-debug.log Dockerfile* docker-compose* .dockerignore .git .gitignore .env */bin */obj README.md LICENSE .vscode EOF