Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

docs: add docker deployment guide #3331

Closed
wants to merge 5 commits into from
Closed

docs: add docker deployment guide #3331

wants to merge 5 commits into from

Conversation

misaon
Copy link
Contributor

@misaon misaon commented Feb 19, 2022

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Add Docker deployment document.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify
Copy link

netlify bot commented Feb 19, 2022

βœ… Deploy Preview for nuxt3-docs ready!

Name Link
πŸ”¨ Latest commit 0366ceb
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/624ecf941a546e000907e1df
😎 Deploy Preview https://deploy-preview-3331--nuxt3-docs.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 settings.

Comment on lines 119 to 125
```bash [Docker compose]
docker-compose build
```

```bash [Docker compose v2]
docker compose build
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalize here as well.

Comment on lines 88 to 94
```bash [Docker compose]
docker-compose exec nuxt sh
```

```bash [Docker compose v2]
docker compose exec nuxt sh
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalize here as well.

Comment on lines 74 to 80
```bash [Docker compose]
docker-compose up -d
```

```bash [Docker compose v2]
docker compose up -d
```
Copy link
Contributor

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".

docs/content/3.docs/3.deployment/7.docker.md Outdated Show resolved Hide resolved
docs/content/3.docs/3.deployment/7.docker.md Outdated Show resolved Hide resolved
docs/content/3.docs/3.deployment/7.docker.md Outdated Show resolved Hide resolved

WORKDIR /app

COPY ./package.json /app/package.json
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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?

Suggested change
COPY --from=nuxtBuild /nuxtBuild/.output /app/.output
COPY --from=nuxtBuild /nuxtBuild/.output /app

Copy link
Contributor Author

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.

Copy link
Member

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' \
Copy link
Member

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] ?

Copy link
Contributor Author

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

Copy link
Member

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)

Copy link
Contributor Author

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:
Copy link
Member

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.

misaon and others added 3 commits February 21, 2022 12:34
Co-authored-by: pooya parsa <pyapar@gmail.com>
Co-authored-by: pooya parsa <pyapar@gmail.com>
Co-authored-by: pooya parsa <pyapar@gmail.com>
@pi0 pi0 changed the title docs: add Docker deployment document docs: add docker deployment guide Mar 3, 2022
@pi0
Copy link
Member

pi0 commented Mar 3, 2022

Hi @misaon. Would you like me to help with improvement suggestions?

@misaon
Copy link
Contributor Author

misaon commented Mar 3, 2022

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?

@pi0 pi0 added documentation Improvements or additions to documentation pending labels Mar 16, 2022
@pi0
Copy link
Member

pi0 commented Apr 15, 2022

Hi @misaon. Again really appreciate your efforts on this πŸ’š

I'm working on an official docker preset for nitro (unjs/nitro#54). Let's come back to the documentation once had it. Also for development, we probably need a different kind of documentation.

@pi0 pi0 closed this Apr 15, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x documentation Improvements or additions to documentation pending
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants