Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Dependencies
node_modules
.pnp
.pnp.js

# Build outputs
build
.docusaurus
dist
coverage

# Git and GitHub
.git
.github

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Docker
Dockerfile
.dockerignore

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
39 changes: 39 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'react'],
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: 'detect',
},
},
env: {
browser: true,
node: true,
es6: true,
},
rules: {
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
ignorePatterns: [
'node_modules/',
'build/',
'.docusaurus/',
'dist/',
'**/*.d.ts',
],
};
56 changes: 56 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy Documentation to Cloud Run

on:
push:
branches:
- main
workflow_dispatch:

env:
REGION: us-central1
REGISTRY: us-central1-docker.pkg.dev
PROJECT_ID: drivecore-primary
SERVICE_NAME: mycoder-docs

jobs:
deploy:
name: Deploy to Cloud Run
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Google Auth
id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.WIF_PROVIDER }}
service_account: ${{ secrets.WIF_SERVICE_ACCOUNT }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2

- name: Configure Docker for GCP
run: |
gcloud auth configure-docker $REGISTRY --quiet

- name: Build and push Docker container
run: |
docker build -t $REGISTRY/$PROJECT_ID/cloud-run-deployments/$SERVICE_NAME:${{ github.sha }} .
docker push $REGISTRY/$PROJECT_ID/cloud-run-deployments/$SERVICE_NAME:${{ github.sha }}

- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ env.SERVICE_NAME }}
region: ${{ env.REGION }}
image: ${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/cloud-run-deployments/${{ env.SERVICE_NAME }}:${{ github.sha }}
flags: '--allow-unauthenticated'

- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}
36 changes: 36 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lint

on:
push:
branches: ["*"]
pull_request:
branches: [main]

env:
PNPM_VERSION: 10.2.1

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm lint
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:20-alpine

WORKDIR /app

# Install pnpm
RUN npm install -g pnpm

# Copy package.json and lock files
COPY package.json pnpm-lock.yaml ./

# Install dependencies
RUN pnpm install --frozen-lockfile

# Copy the rest of the application
COPY . .

# Build the Docusaurus site
ENV NODE_ENV=production
RUN pnpm build

# Expose the port the app will run on
ENV PORT=8080
EXPOSE ${PORT}

# Command to run the application
CMD ["pnpm", "serve", "--port", "8080", "--no-open"]
68 changes: 68 additions & 0 deletions docs/deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
sidebar_position: 99
title: Deployment
---

# Deployment Process

This documentation site is automatically deployed to Google Cloud Run whenever changes are pushed to the main branch. This document outlines the deployment process and how to make changes to it.

## Automated Deployment

The documentation site uses GitHub Actions for continuous integration and deployment (CI/CD):

1. When changes are pushed to the `main` branch, a GitHub workflow is triggered
2. The workflow builds the Docusaurus site and packages it in a Docker container
3. The container is pushed to Google Container Registry
4. The container is deployed to Google Cloud Run
5. The site is accessible at the Cloud Run URL (with custom domain mapping)

## Deployment Infrastructure

The deployment infrastructure consists of:

- **Docker Container**: The site is packaged in a Docker container for consistent deployment
- **Google Container Registry**: Stores the Docker images
- **Google Cloud Run**: Hosts the documentation site
- **GitHub Actions**: Automates the build and deployment process

## Local Development and Testing

To test the deployment locally:

1. Build the Docker image:
```bash
docker build -t mycoder-docs .
```

2. Run the container locally:
```bash
docker run -p 8080:8080 mycoder-docs
```

3. Access the site at http://localhost:8080

## Manual Deployment

While the deployment is automated, you can also trigger a manual deployment:

1. Go to the GitHub repository
2. Navigate to Actions → Deploy Documentation to Cloud Run workflow
3. Click "Run workflow" and select the branch to deploy

## Troubleshooting

If you encounter issues with the deployment:

1. Check the GitHub Actions logs for any errors
2. Verify that the Docker container builds successfully locally
3. Ensure the Google Cloud service account has the necessary permissions
4. Check the Cloud Run logs for runtime errors

## Modifying the Deployment Process

To modify the deployment process:

1. Update the `.github/workflows/deploy-docs.yml` file for changes to the CI/CD pipeline
2. Update the `Dockerfile` for changes to the container configuration
3. Test changes locally before pushing to the repository
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc"
"typecheck": "tsc",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@docusaurus/core": "3.7.0",
Expand All @@ -27,6 +28,10 @@
"@docusaurus/module-type-aliases": "3.7.0",
"@docusaurus/tsconfig": "3.7.0",
"@docusaurus/types": "3.7.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"eslint": "^8.56.0",
"eslint-plugin-react": "^7.33.2",
"typescript": "~5.6.2"
},
"browserslist": {
Expand Down
Loading
Loading