Unit 2 Chapter 2: Hugo Neutrino
In this chapter, you will use Hugo Neutrino to create a new Hugo app. As was the case with the previous chapter, you will use a Docker environment. Unlike the case with the previous chapter, you will execute this process as a regular user instead of as root.
Downloading the Hugo Neutrino Code
- In a shell terminal, enter the following commands:
cd
mkdir -p docker-hugo
cd docker-hugo
git clone https://github.com/rubyonracetracks/hugo_neutrino.git
- Enter the command
cd hugo_neutrino
.
Creating the Hugo App
- Enter the command
bash main.sh
. - When prompted for an app name, just press "Enter" to use the default app name.
- Hugo Neutrino will take a few moments to download a special Docker image customized for Hugo Neutrino. Note that this Docker image comes with Hugo pre-installed AND comes with a regular user. This makes it possible to run the Hugo app creation scripts as a regular user instead of as root.
- Once the Docker image has been downloaded and the associated Docker container has been created, the process of creating the new app will take a second or two at most. When the process is finished, you are ready to move on to the next step.
Docker Container and Image
- Enter the command
docker ps -a
to list all of the Docker containers. The list should be empty. Note that your shell terminal is in the host OS and not a Docker environment. 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 shoud look something like this:
REPOSITORY TAG IMAGE ID CREATED SIZE
rubyonracetracks/hugo_neutrino latest 8e3e708ee590 4 hours ago 314MB
Rebuilding and Viewing the Hugo App
- In your terminal shell, use the "cd" command to enter your new Hugo app's root directory. Then run the command
bash build.sh; bash server.sh
to build the Hugo 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 Hugo app is different from the one used by Hugo Neutrino. - Open your web browser, and go to the URL http://localhost:1313/ on your host system. Your new app should appear with the Minimal theme. Leave the Hugo server running for now. (You'll stop when it's time to clean up at the end of this chapter.)
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
a4e884bbe0d1 hugo-20200618-211206-118_hugo "hugo server -D --bi…" About a minute ago Up About a minute 0.0.0.0:1313->1313/tcp hugo-20200618-211206-118_hugo_1
- Note that the Docker container listed above is dedicated to running your app's Hugo 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
<none> <none> 2c71bd0c37c0 2 minutes ago 314MB
hugo-20200618-211206-118_hugo latest 1b71146a67cf 2 minutes ago 314MB
<none> <none> 1ecabb4f9542 2 minutes ago 314MB
<none> <none> 70dff2fbd26a 3 minutes ago 117MB
rubyonracetracks/hugo_neutrino latest 8e3e708ee590 4 hours ago 314MB
debian testing afb6626cbf32 9 days ago 117MB
- Note that the "rubyonracetracks/hugo_neutrino" Docker image is left over from running the Hugo Neutrino scripts earlier in this chapter. The "hugo-20200618-211206-118_hugo" 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. Note that the "debian:testing" Docker image was used by the Dockerfile to create the "hugo-20200618-211206-118_hugo" image.
- The "none" images are the results of intermediate steps in the process of creating the "hugo-20200618-211206-118_hugo" image from the "debian:testing" Docker image.
Cleaning Up Docker
- 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 Hugo 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.