Deploying a Docusaurus App
Docusaurus is a modern static site generator designed for building documentation websites quickly and easily. It features Markdown support, versioning, and a rich plugin ecosystem, making it ideal for open-source and product documentation.
This guide explains how to deploy a Docusaurus application to Klutch.sh, both with and without a Dockerfile. It covers installation, sample code, and deployment steps.
Prerequisites
- Node.js & npm installed (Download)
- Git and GitHub account
- Klutch.sh account
Getting Started: Create a Docusaurus App
- Create a new Docusaurus app:
Terminal window npx create-docusaurus@latest my-docusaurus-app classiccd my-docusaurus-appnpm install - Start the development server:
Your app should be running at http://localhost:3000.
Terminal window npm run start
Sample Code (docs/hello-klutch.md)
Create a sample doc page:
---id: hello-klutchtitle: Hello from Docusaurus on Klutch.sh!---
Welcome to your Docusaurus site deployed on Klutch.sh!
Deploying Without a Dockerfile
Docusaurus apps are static sites after build. Klutch.sh can deploy static sites directly.
- Push your Docusaurus app to a GitHub repository.
- Log in to Klutch.sh.
- Create a new project.
- Create a new app:
- Select your Docusaurus GitHub repository and branch
- Choose “Static Site” as the app type
- Set build command:
npm run build
- Set output directory:
build
- Configure region, compute, and environment variables as needed
- Click “Create” to deploy. Klutch.sh will build and serve your static Docusaurus app.
Deploying With a Dockerfile
If you need custom server logic or want to use a Dockerfile:
- Add a
Dockerfile
to your project root. Example:# Build stageFROM node:20-alpine AS builderWORKDIR /appCOPY package*.json ./RUN npm installCOPY . .RUN npm run build# Production stageFROM nginx:alpineCOPY --from=builder /app/build /usr/share/nginx/htmlEXPOSE 80CMD ["nginx", "-g", "daemon off;"] - Push your code (with Dockerfile) to GitHub.
- In Klutch.sh, create a new app and select the Dockerfile option when prompted.
- Set service details and environment variables as needed.
- Click “Create” to deploy. Klutch.sh will build your Docker image and serve your Docusaurus app via Nginx.
Resources
Deploying Docusaurus to Klutch.sh is fast and flexible. Use static site deployment for most cases, or Dockerfile for custom setups.