Merge pull request #1613 from chshouyu/new-dockerfile

Dockerfile 重构
This commit is contained in:
binaryify 2022-11-20 16:18:05 +08:00 committed by GitHub
commit 07f5842230
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
/**
!/module
!/plugins
!/public
!/static
!/util
!/app.js
!/server.js
!/package.json
!/package-lock.json

View File

@ -1,11 +1,16 @@
FROM node:lts-alpine FROM node:lts-alpine
WORKDIR /app RUN apk add --no-cache tini
COPY . /app
RUN npm config set registry "https://registry.npmmirror.com/" \ ENV NODE_ENV production
&& npm install -g npm husky \ USER node
&& npm install --production
WORKDIR /app
COPY --chown=node:node . ./
RUN npm i --omit=dev --ignore-scripts
EXPOSE 3000 EXPOSE 3000
CMD ["node", "app.js"]
CMD [ "/sbin/tini", "--", "node", "app.js" ]