-
-
Notifications
You must be signed in to change notification settings - Fork 1k
docs: add docker deployment guide #3331
Conversation
β Deploy Preview for nuxt3-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
```bash [Docker compose] | ||
docker-compose build | ||
``` | ||
|
||
```bash [Docker compose v2] | ||
docker compose build | ||
``` |
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.
Capitalize here as well.
```bash [Docker compose] | ||
docker-compose exec nuxt sh | ||
``` | ||
|
||
```bash [Docker compose v2] | ||
docker compose exec nuxt sh | ||
``` |
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.
Capitalize here as well.
```bash [Docker compose] | ||
docker-compose up -d | ||
``` | ||
|
||
```bash [Docker compose v2] | ||
docker compose up -d | ||
``` |
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.
How about capitalizing "compose"? e.g. "Docker Compose" and "Docker Compose V2".
|
||
WORKDIR /app | ||
|
||
COPY ./package.json /app/package.json |
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.
Why do we need package.json in second layer?
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're right, I'll delete it
WORKDIR /app | ||
|
||
COPY ./package.json /app/package.json | ||
COPY --from=nuxtBuild /nuxtBuild/.output /app/.output |
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.
Maybe directly .output
to /app
?
COPY --from=nuxtBuild /nuxtBuild/.output /app/.output | |
COPY --from=nuxtBuild /nuxtBuild/.output /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.
It is safer to copy only the builded folder, it can copy to the production eg ".yarn", error logs, etc.
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.
We could surely document this but i'm afraid this is not needed for actual nuxt deployments. .output
directory is fully standalone with node_modules
and even niro build meta in a json file.
|
||
RUN ( \ | ||
echo '#!/bin/sh'; \ | ||
echo 'if [[ "$NODE_ENV" == "development" ]]; then yarn run dev; else node /app/.output/server/index.mjs; fi' \ |
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.
Why not simply use CMD with [node, /app/server/index.mjs]
?
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.
Because there is support for local development controlled by the variable "NODE_ENV", it is possible to run the image in dev mode
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.
Ah, I see! Well for development we could directly override the command in docker-compose.yml
(or last arg of docker
in case of directly using docker CLI)
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.
Good idea!
|
||
### Build into production | ||
|
||
To build into production you need to modify the environment `NODE_ENV` and remove `volumes` property, example: |
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'm thinking we could have docker-compose it's whole section and use docker build
docker start
for initial docs. Not all deployments are based on compose while guide for building image is an essential part.
Co-authored-by: pooya parsa <pyapar@gmail.com>
Co-authored-by: pooya parsa <pyapar@gmail.com>
Co-authored-by: pooya parsa <pyapar@gmail.com>
Hi @misaon. Would you like me to help with improvement suggestions? |
hello, I'll take a look at it over the weekend and put it in its final form. So do we divide docker and docker compose into two sections? |
Hi @misaon. Again really appreciate your efforts on this π I'm working on an official docker preset for nitro (nitrojs/nitro#54). Let's come back to the documentation once had it. Also for development, we probably need a different kind of documentation. |
π Linked issue
β Type of change
π Description
Add Docker deployment document.
π Checklist