Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(api): Optimize dockerfile - WIP #5454

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

SokratisVidros
Copy link
Contributor

What changed? Why was the change needed?

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

netlify bot commented Apr 25, 2024

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit 0de0c7e
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/662a724feab84f0008bcdad7
😎 Deploy Preview https://deploy-preview-5454--dev-web-novu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Apr 25, 2024

Deploy Preview for novu-design ready!

Name Link
🔨 Latest commit 0de0c7e
🔍 Latest deploy log https://app.netlify.com/sites/novu-design/deploys/662a724fa3096e00089b538d
😎 Deploy Preview https://deploy-preview-5454--novu-design.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

WORKDIR /usr/src/app/apps/api
CMD [ "pm2-runtime","start", "dist/main.js" ]
CMD [ "dump-init", "node", "dist/main.js" ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this one be dumb-init?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed some best practices and found out about https://github.com/Yelp/dumb-init. Maybe we need it, maybe not. We will review it as soon as this is more testable.

Note that my goal is to remove PM2. I don't think it adds value at this point.

COPY --chown=1000:1000 ./meta .
COPY --chown=1000:1000 ./deps .
COPY --chown=1000:1000 ./pkg .
COPY --chown=1000:1000 ./meta ./deps ./pkg ./
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's interim stage, I think we don't have to unite these layers because we won't use dev, it's important to decrease dev_base and prod. Docker caches each line in the Dockerfile, and that the output of one line is the input of the next. So if a line generates new output all subsequent caches are invalidated. In this case we lost an opportunity to use cache even if only last folder will be changed we copy all of them.

@@ -1,11 +1,10 @@
FROM node:20-alpine3.19 as dev_base
RUN apk add g++ make py3-pip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can exclude cache because we use dev_base in the final step RUN apk add --no-cache g++ make py3-pip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants