background
When I was building my blog with Pages provided by GitHub, I had no idea how the *.md file was compiled into HTML and provided with web services. Later, I saw the compilation script in Actions:
docker run \
-v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \
jekyll/builder:latest /bin/bash -c "chmod -R 777 /srv/jekyll && jekyll build --future"
Copy the code
Jekyll/Builder :latest (github.com/envygeeks/j…) Docker images of the same type are also found:
Image Types:
- jekyll/jekyll: Default image.
- jekyll/minimal: Very minimal image.
- jekyll/builder: Includes tools.
Here’s how to use mirrored Jekyll/Builder.
role
Docker image Jekyll/Builder is a jekyll build environment that includes some tools to compile local jekyll source files into static HTML
The learning process
Docker jekyll/ Builder :latest compiles files from/SRV /jekyll/_site to/SRV /jekyll/_site. ${{github. Workspace}}:/ SRV /jekyll
chmod -R 777 /srv/jekyll && jekyll build --future
Copy the code
Next, get rid of Github and run mirrored Jekyll/Builder in my local Docker environment alone
Mkdir /home/hanpanpan92/site_source && /home/hanpanpan92/site_source/_site //site_source create index.md docker pull file in site_source jekyll/builder docker run -v /home/hanpanpan92/site_source:/srv/jekyll -v /home/hanpanpan92/site_source/_site:/srv/jekyll/_site jekyll/builder:latest /bin/bash -c "chmod -R 777 /srv/jekyll && jekyll build"Copy the code
After executing the Docker run… /home/hanpanpan92/site_source/_site/index.md /home/hanpanpan92/site_source/_site/index.md /home/hanpanpan92/site_source/ site_site Then put the source code of my blog into site_source directory and execute docker run again… Found that the _site folder does generate static HTML files and the corresponding JS images CSS etc., that may be a configuration problem.
In my blog source code, I use the “strong misbeat deletion method” to get the simplest directory structure:
Docker run XXXX successfully compiles md file to _site folder
The simplest source: site_source.zip
The layout file _layouts/default. HTML generates the final HTML file in the _site directory after parsing the index.md file. Jekyll layouts/default. HTML generates the final HTML file in _site. For example, to build a single page, list page, list page, article classification such functions
Official document: jekyllcn.com/docs/home/
Now we can build the jekyll development environment locally, using the Docker image to compile, so that we do not need to install jekyll related tools on the local machine, because it is in the Docker.
Take flight: I can submit code to Github, customize the build process using Github’s Actions, and publish static files from the _site build to my own server. Perfect!
conclusion
Docker image jekyll/ Builder role, is jekyll compilation tools, from the local, or server installation of various tools, as long as the directory structure in accordance with its provisions of the source file, it can be very convenient to compile into static HTML
More of Jekyll’s rules can be found at jekyllcn.com/docs/home/
My blog:blog.hpanpan.ccThis blog is generated by the techniques mentioned in this article. The source code is on Github. Please check it out
knowledge
Jekyll/Builder :latest this image is not checked by docker ps -A like other images, it feels like a compilation tool, run it, change a to B, and exit. It seems to be related to the two running modes (Foreground and Detached) of Docker container, which is not clear yet