Deploying Docusaurus with Docker
What is Docusaurus?
Docusaurus is an open-source static site generator built by Facebook. It is designed for documentation websites, blogs, and knowledge bases. Docusaurus uses Markdown for content creation and provides a React-based frontend.
Key Components of Docusaurus
Docusaurus consists of several components that make it easy to build and maintain a documentation site.
1. docs/
(Documentation Pages)
- Stores Markdown files for your documentation.
- Each
.md
file in this directory becomes a documentation page. - The navigation order is controlled by
sidebars.js
.
2. blog/
(Blog Posts)
- Contains Markdown blog posts (
YYYY-MM-DD-title.md
). - Docusaurus automatically generates a blog listing page.
3. static/
(Static Assets)
- Stores images, CSS, JavaScript, and other static files.
- These files are directly accessible via the
/
URL path.
4. src/
(Custom React Components)
- Used for adding custom React components to enhance documentation.
- Contains custom pages (
src/pages/
) and UI enhancements.
5. docusaurus.config.js
(Configuration File)
- The main configuration file for site settings, themes, and plugins.
- Defines the site title, URL, navbar, footer, and more.
6. sidebars.js
(Sidebar Navigation)
- Controls the navigation structure of the documentation.
- Organizes docs into categories and sections.
Docusaurus Build Process
To create a new Docusaurus project:
npx create-docusaurus@latest my-website classic
cd my-website
npm install
The process of containerizing and deploying your Docusaurus project to Google Compute Engine (GCE) involves the following steps:
Containerize the Docusaurus Project
- Create a Dockerfile.
- Build a Docker image.
- Test the container locally.
Push the Docker Image to Google Container Registry (GCR)
- Tag and push the image to Google Container Registry.
- Deploy the Container on Google Compute Engine (GCE)