mirror of
https://github.com/SunRed/haste-server.git
synced 2025-09-04 04:50:14 +02:00
Make Docker image smaller and fix issue with ignore files
* Exclude a bunch of files and directories not needed for Docker image * Exclude dev dependencies for Docker image build by introducing a production build script * Using a different alpine base image and multi-stage build reduces the Docker image by roughly 35 MB alone * Move babel to dev dependencies * Fix highlight.min.js accidentally being ignored
This commit is contained in:
parent
062bdb3dec
commit
3606db4d90
5 changed files with 479 additions and 72 deletions
23
Dockerfile
23
Dockerfile
|
@ -1,19 +1,11 @@
|
|||
FROM node:lts-alpine
|
||||
|
||||
RUN apk add --no-cache curl
|
||||
|
||||
RUN mkdir -p /usr/src/app && \
|
||||
chown node:node /usr/src/app
|
||||
|
||||
USER node:node
|
||||
FROM mhart/alpine-node:14 AS build
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
COPY . .
|
||||
|
||||
COPY --chown=node:node . .
|
||||
|
||||
# Replace build with build-min to exclude the optional dbms dependencies
|
||||
# Replace prod with prod-min to exclude the optional dbms dependencies
|
||||
# and uncomment the needed one below to build a smaller Docker image.
|
||||
RUN npm run build
|
||||
RUN npm run prod
|
||||
#RUN npm install pg
|
||||
#RUN npm install aws-sdk
|
||||
#RUN npm install memcached
|
||||
|
@ -21,8 +13,13 @@ RUN npm run build
|
|||
#RUN npm install ioredis
|
||||
#RUN npm install rethinkdbdash
|
||||
|
||||
ENV PORT=7777
|
||||
FROM mhart/alpine-node:slim-14
|
||||
RUN apk add --no-cache curl
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=build /usr/src/app .
|
||||
|
||||
ENV PORT=7777
|
||||
EXPOSE ${PORT}
|
||||
STOPSIGNAL SIGINT
|
||||
ENTRYPOINT [ "node", "server.js" ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue