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

Cannot use hot reloading in Docker #6722

Closed
6 of 7 tasks
cod3rshotout opened this issue Feb 19, 2022 · 5 comments
Closed
6 of 7 tasks

Cannot use hot reloading in Docker #6722

cod3rshotout opened this issue Feb 19, 2022 · 5 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@cod3rshotout
Copy link

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

I'm trying to run docusaurus over docker and use the hot reload feature so I don't need to recompile each time the project, but for some reason when I do a change the project doesn't recompile

Steps to reproduce

  1. Create a new project and install docusaurus, I have the version 2.0.0-beta.15
  2. Create this docker-compose:
  version: "3"

  services:
    docusaurus:
      build: .
      expose:
        - 3000
        - 35729
      ports:
        - 3000:3000
        - 35729:35729
      volumes:
        - ./docs:/app/docs
        - ./website/blog:/app/website/blog
        - ./website/core:/app/website/core
        - ./website/i18n:/app/website/i18n
        - ./website/pages:/app/website/pages
        - ./website/static:/app/website/static
        - ./website/sidebars.json:/app/website/sidebars.json
        - ./website/siteConfig.js:/app/website/siteConfig.js
      working_dir: /app/website
  1. Create this Dockerfile:
FROM node:lts

WORKDIR /app/website

EXPOSE 3000 35729
COPY ./docs /app/docs
COPY ./website /app/website
RUN yarn install

CMD ["yarn", "start", "--host", "0.0.0.0", "--port", "35729"]
  1. Now run docker-compose up --build -d
  2. Try to change a file within docs, nothing happen

Expected behavior

When an update is made, the code should reload automatically

Actual behavior

When an update is made no changes are reflected on the live site

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Reproducible demo

No response

Self-service

  • I'd be willing to fix this bug myself.
@cod3rshotout cod3rshotout added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Feb 19, 2022
@Josh-Cena Josh-Cena added status: needs more information There is not enough information to take action on the issue. and removed status: needs triage This issue has not been triaged by maintainers labels Feb 20, 2022
@Josh-Cena Josh-Cena changed the title Cannot use hot reloading Cannot use hot reloading in Docker Feb 20, 2022
@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Feb 20, 2022

Not using Docker-compose, but someone else asked the same thing on Discord. Could you research if:

  • Docker exposes FS events like add or change, which docusaurus start listens to?
  • Chokidar works in Docker?

From my research, seems Docker doesn't support file watchers, and you have to use the --poll CLI option. Could you try setting that to something like --poll 1000?

@Josh-Cena Josh-Cena added closed: question This issue is a user error/misunderstanding. and removed status: needs more information There is not enough information to take action on the issue. labels Feb 20, 2022
@Josh-Cena
Copy link
Collaborator

Closing. If there's anything that Docusaurus could clearly improve, please follow-up. Otherwise I'd be considering this as a question.

@turbotimon
Copy link

turbotimon commented Mar 10, 2023

Using windows 10 together with a vscode devcontainer (javascript-node:0-18) i faced the same problem (no hot reload with yarn start). However, it worked with the poll option yarn start --poll.

@slorber
Copy link
Collaborator

slorber commented Mar 10, 2023

This is normally fixed in #7951 but will only appear in Docusaurus v3.
Try a canary release and please report if it works better

@turbotimon
Copy link

@slorber Thanks, I'm on 2.3.1. The workaround is enough for the moment. Just wanted to give a solution to other people that might search for "devcontainer" in the issues (as i was before finding this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

4 participants