-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(node): add docker as a build target #14475
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -0,0 +1,6 @@ | |||
FROM node:alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want something more elaborate in the lines of
ROM docker.io/node:lts-alpine
ENV NODE_ENV production
WORKDIR <%= app %>
RUN npm install -g npm@latest
COPY <%= buildLocation %> ./
RUN npm install --omit=dev
RUN chown -R node:node .
USER node
CMD [ "node", "<%= main %>" ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FROM docker.io/node:lts-alpine
makse sense, I wouldn't do npm install
in Dockerfile
since the dist
should already be present andd bundled.
If users have external dependencies (e.g. not bundled in) then it makes sense to include install step -- I think they can add the install it manually for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for can run COPY --chown node:node <%= buildLocation %> .
Like:
RUN addgroup --system node && \
adduser --system -G node node
COPY --chown node:node <%= buildLocation %> .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't do npm install in Dockerfile since the dist should already be present and bundled.
In my setup (node app / webpack) the deps are not bundled.
I was not aware of the possibility that deps could be bundled for a node app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's possible if you use esbuild or webpack... not plain tsc though. I highly recommend it since you benefit from a smaller image size as well. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't though tsc does bundling or tree shaking!
87f432a
to
a3873be
Compare
@@ -0,0 +1,6 @@ | |||
FROM node:alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FROM docker.io/node:lts-alpine
makse sense, I wouldn't do npm install
in Dockerfile
since the dist
should already be present andd bundled.
If users have external dependencies (e.g. not bundled in) then it makes sense to include install step -- I think they can add the install it manually for now.
@@ -0,0 +1,6 @@ | |||
FROM node:alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for can run COPY --chown node:node <%= buildLocation %> .
Like:
RUN addgroup --system node && \
adduser --system -G node node
COPY --chown node:node <%= buildLocation %> .
a3873be
to
76eac74
Compare
76eac74
to
d6999e2
Compare
packages/node/src/generators/setup-docker/files/Dockerfile__tmpl__
Outdated
Show resolved
Hide resolved
packages/node/src/generators/setup-docker/files/Dockerfile__tmpl__
Outdated
Show resolved
Hide resolved
d6999e2
to
995f3f1
Compare
995f3f1
to
dce7d08
Compare
packages/node/src/generators/setup-docker/files/Dockerfile__tmpl__
Outdated
Show resolved
Hide resolved
dce7d08
to
a0fded0
Compare
a0fded0
to
7978d81
Compare
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
This adds a docker configuration to a current node project (standalone / integrated)
It should create a Dockerfile which builds an image based off the output path for your node project
Running the command
Should create a folder structure similar to