首页 > 其他分享 >Dockerfile优化

Dockerfile优化

时间:2022-12-20 18:44:18浏览次数:37  
标签:优化 Dockerfile 文件 dockerignore cat

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

 

标签:优化,Dockerfile,文件,dockerignore,cat
From: https://www.cnblogs.com/weiweirui/p/16994883.html

相关文章