Unit 3 Chapter 3: Docusaurus Neutrino
In this chapter, you will use Docusaurus Neutrino to create a new Docusaurus app. As was the case with the previous chapters, you will use a Docker environment. Unlike the case with the previous chapters, you will execute this process as a regular user instead of as root.
Downloading the Docusaurus Neutrino Code
- In a shell terminal, enter the following commands:
cd
mkdir -p docker-docu
cd docker-docu
git clone https://github.com/rubyonracetracks/docusaurus_neutrino
- Enter the command
cd docusaurus_neutrino
.
Creating the Docusaurus App
- Enter the command
bash main.sh
. - When prompted for an app name, just press "Enter" to use the default app name. When prompted, press "Enter" again to continue.
- Docusaurus Neutrino will take a few moments to download a special Docker image customized for Docusaurus. Note that this Docker image comes with Node.js pre-installed AND is run as a regular user (instead of root) by default.
- Once the Docker image has been downloaded and the associated Docker container has been created, the process of creating the new app will begin. When the process is finished, you are ready to move on to the next step.
Docker Container and Images
- Enter the command
docker ps -a
to list all of the Docker containers. The list should be blank. While the Docker container was present during the above app building process, it was terminated as soon as it was finished. - Enter the command
docker images -a
to list all of the Docker images. The result should look something like this:
REPOSITORY TAG IMAGE ID CREATED SIZE
rubyonracetracks/node_user latest 2cb33daa3bde 14 hours ago 930MB
- The rubyonracetracks/node_user Docker image is the one used by Docusaurus Neutrino to create the new app.
- Run the nuke.sh script by entering the command
bash nuke.sh
. This removes the excess Docker networks, all Docker containers, and all Docker images. The next step is to rebuild and view your new Docusaurus app.
Rebuilding and Viewing the Docusaurus App
- In your terminal shell, use the "cd" command to enter your new Docusaurus app's root directory. Then run the command
bash build.sh; bash server.sh
to build the Docusaurus app and run the local server. Note that your new app contains its own Dockerfile and docker-compose.yml file. The Docker image used in your new Docusaurus app is different from the one used by Docusaurus Neutrino. When the build process is finished, the Docusaurus server will start up, and you will then be ready to view your app. - Open your web browser, and go to the URL http://localhost:3000/ on your host system. Your new Docusaurus app should appear.
- Open your web browser and go to the URL http://localhost:35729/ on your host sytem. Once again, you're looking at the output of the LiveReload server, and you'll see something similar to this:
{"tinylr":"Welcome","version":"1.1.1"}
Docker Container and Images
- Start a new shell terminal tab for entering additional commands.
- Enter the command
docker ps -a
to list all of the Docker containers. The result should look something like this:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6b651b513c33 docu-20200705-183451-626_docusaurus "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:3000->3000/tcp, 0.0.0.0:35729->35729/tcp docu-20200705-183451-626_docusaurus_1
- Note that the Docker container listed above is dedicated to running your app's Docusaurus server.
- Enter the command
docker images -a
to list all of the Docker images. The result should look something like this:
REPOSITORY TAG IMAGE ID CREATED SIZE
docu-20200705-183451-626_docusaurus latest 8aa7f0b3ac01 About a minute ago 918MB
node lts 1fa6026dd8bb 4 days ago 918MB
- Note that the "node/lts" Docker image is the base image specified in your app's Dockerfile. The "docu-20200705-183451-626_docusaurus" Docker image is the result of running the "docker-compose build" command (part of the build.sh script), which involves following the instructions provided by the Dockerfile.
Cleaning Up
- In the shell terminal tab dedicated to the host OS, run the nuke.sh script by entering the command
bash nuke.sh
. This removes the excess Docker networks, all Docker containers, and all Docker images. - The Docusaurus server you started earlier in this chapter was automatically shut down during the process of removing the Docker container that it ran in.
Deleting the App
Open the file manager app in the host OS, and delete your app from there. Because the app was created as a regular user instead of as root, you do NOT need to be root to delete it, and there should be no permission issues.