This install is based on an example of Mac OS X using Podman and version 3.10 of Docusaurs.
First create a Containerfile that will be used to build an image, the Containerfile should be as follows:-
FROM node:lts-alpine
RUN npx create-docusaurus@latest /home/node/docusaurus classic --javascript && \
chown -R node:node /home/node/docusaurus
USER node
WORKDIR /home/node/docusaurus
RUN cd /home/node/docusaurus && yarn install
COPY . .
CMD ["yarn", "start", "--host", "0.0.0.0"]
Now build the images using the following command. Note that all files and execution of the build command will be in ~/Container/Podman/docusaurus
podman build -t docusaurus:latest .
First create a base container based on the image, this why it'll be possible to take a copy of all the base files used by Docusaurus. Keeping a local copy of these files means keeping persistent data when running the container in the future, not these container will be dumped once a copy of the files has been taken.
podman container create --name base docusaurus:latest
Run the container from Podman desktop
To keep persistent data with the container locally, copy the base files from container to a local directory, in this case it'll be ~/Container/Podman/docusaurus.
podman cp base:/home/node/docusaurus/. ~/Container/Podman/docusaurus
Note: can remove the directory node_modules as these are not required to be mounted.
With a copy of the files from the base container, this can be stopped in Podman Desktop and deleted.
Create the container again and map the local volumes to the conatiner to keep persistent data,
podman container create -p 3000:3000 --name docusaurus \
-v ${PWD}/blog:/home/node/docusaurus/blog \
-v ${PWD}/docs:/home/node/docusaurus/docs \
-v ${PWD}/static:/home/node/docusaurus/static \
-v ${PWD}/src:/home/node/docusaurus/src \
-v ${PWD}/docusaurus.config.js:/home/node/docusaurus/docusaurus.config.js \
-v ${PWD}/package-lock.json:/home/node/docusaurus/package-lock.json \
-v ${PWD}/package.json:/home/node/docusaurus/package.json \
-v ${PWD}/sidebars.js:/home/node/docusaurus/sidebars.js \
-v ${PWD}/sidebars.js:/home/node/docusaurus/yarn.lock \
docusaurus:latest
A new container will be created, use Podman Desktop to start and stop this container and develop as required.