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 acf5425
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ FROM node:20-alpine

WORKDIR /usr/src/app

RUN apk add sudo
RUN echo '%node ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

ARG CLIENT_PORT=5001

ENV PORT=5000
Expand All @@ -40,26 +37,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
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
RUN apk --no-cache add curl
COPY --from=builder /usr/src/app/data ./data

RUN chown -R node:node /usr/src/app

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 --no-verbose --tries=1 --spider http://127.0.0.1:$PORT/health || 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 acf5425

Please sign in to comment.