Skip to content

Commit

Permalink
chore: lighten docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Jun 20, 2024
1 parent f9f17d3 commit 9dd16e7
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,22 @@ ENV SMTP_PORT=2500
ENV SMTP_USER=fake_mail_user
ENV SMTP_PASS=fake_mail_password

COPY package.json .
COPY --from=builder /usr/src/app/client/out ./client/out
COPY --chown=node package.json .
COPY --chown=node --from=builder /usr/src/app/client/out ./client/out
COPY --chown=node server/package.json server/package-lock.json ./server/

COPY server/package.json server/package-lock.json ./server/
RUN npm ci --omit=dev --prefix server

COPY --from=builder /usr/src/app/server/index.js ./server/index.js
COPY --from=builder /usr/src/app/server/node_modules/.prisma ./server/node_modules/.prisma
COPY --from=builder /usr/src/app/server/prisma ./server/prisma
RUN apk --no-cache add curl
COPY --from=builder /usr/src/app/data ./data

RUN chown -R node:node /usr/src/app
COPY --chown=node --from=builder /usr/src/app/server/index.js ./server/index.js
COPY --chown=node --from=builder /usr/src/app/server/node_modules/.prisma ./server/node_modules/.prisma
COPY --chown=node --from=builder /usr/src/app/server/prisma ./server/prisma
COPY --chown=node --from=builder /usr/src/app/data ./data

HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl -f http://localhost:$PORT/health && curl -f http://localhost:$CLIENT_PORT || exit 1
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD wget --quiet --spider http://localhost:$PORT/health && wget --quiet --spider http://localhost:$CLIENT_PORT || exit 1

EXPOSE ${PORT} ${CLIENT_PORT}
VOLUME ["/usr/src/app/data"]

USER node
ENTRYPOINT ["sh", "-c", "sudo chown -R node /usr/src/app/data && ls -l /usr/src/app && exec \"$@\"", "--"]

CMD ["npm", "start"]

0 comments on commit 9dd16e7

Please sign in to comment.