DocusaurusSite
The DocusaurusSite
construct is an AWS CDK (Cloud Development Kit) construct tailored for deploying Docusaurus websites on AWS infrastructure. It extends the capabilities of the StaticSiteBase
construct to manage the deployment of Docusaurus sites with optional custom domain configurations and Docker-based build environments.
Features
- Docker Build Environment: Utilizes a Docker container to install dependencies and build the Docusaurus site.
- Custom Domain Configuration: Supports custom domain configuration with an ACM (AWS Certificate Manager) certificate for HTTPS.
- Built on
StaticSiteBase
: Inherits features and AWS resource provisioning from theStaticSiteBase
construct.
Properties
- image (optional): A
DockerImage
instance for the Docker container used in the build process. - nodeEnv: The Node.js environment to use when building the Docusaurus site.
- certificateArn (optional): The ARN (Amazon Resource Name) of an ACM certificate.
- domainNames (optional): An array of domain names for the website.
- sourcePath (optional): The path to the source files for the Docusaurus site.
Usage
Below is an example of how to use the DocusaurusSite
construct:
import * as path from 'path';
import { DocusaurusSite, DocusaurusSiteProps } from 'path-to-docusaurus-site';
import { DockerImage } from 'aws-cdk-lib';
import { App, Stack } from 'aws-cdk-lib';
const app = new App();
const stack = new Stack(app, 'DocusaurusWebsiteStack');
const siteProps: DocusaurusSiteProps = {
nodeEnv: 'production',
certificateArn: 'arn:aws:acm:region:account:certificate/id',
domainNames: ['docs.example.com'],
sourcePath: path.join(__dirname, '../website'),
};
new DocusaurusSite(stack, 'MyDocusaurusSite', siteProps);
In this example, a new DocusaurusSite
construct is created with custom domain configuration, a specified source path, and a production Node.js environment for building the Docusaurus site.
AWS Resources
- Docker Container: Utilized for building the Docusaurus site with the specified Node.js environment.
- S3 Bucket: Inherits the S3 bucket provisioning from
StaticSiteBase
for hosting the website's static assets. - CloudFront Distribution: Inherits the CloudFront distribution configuration from
StaticSiteBase
for content delivery. - ACM Certificate (optional): Utilized for HTTPS when custom domains are configured.