From b7161b200d52e48e48eade139f35ba977d3e169c Mon Sep 17 00:00:00 2001 From: solufa Date: Thu, 20 Jun 2024 15:05:03 +0900 Subject: [PATCH] chore: lighten docker image --- Dockerfile | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3e78de8..1612fc7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -40,19 +37,17 @@ 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 @@ -60,6 +55,4 @@ 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"]