Example configs

Three complete configs, one per way of running GenoaCMS. They are files in GenoaCMS's own repository, beside the configs core runs with, and CI type-checks each one and loads it through the config loader, so what this page shows is what the current release accepts. Read them on GitHub in packages/core/genoa.config/ .

Each imports the modules genoa init writes beside it: collections, authorization, security and languages. Replace the placeholder names — my-project, my-company, the bucket names — with your own resources: GenoaCMS works on buckets and databases that already exist.

Google Cloud

Users sign in through Firebase Authentication or Identity Platform; content lives in Cloud Storage and Firestore; GenoaCMS runs as a Cloud Run function. Every provider authenticates as the function's service account, so the config holds no credential.

import {
  defineConfig, storageProvider, databaseProvider, authenticationProvider,
  secretsProvider, deploymentTarget
} from '@genoacms/config'
import type {} from '@genoacms/adapter-gcp/authentication/identity-platform'
import type {} from '@genoacms/adapter-gcp/storage'
import type {} from '@genoacms/adapter-gcp/database'
import type {} from '@genoacms/adapter-gcp/secrets'
import type {} from '@genoacms/adapter-gcp/deployment'
import { collections } from './collections.js'
import { authorization } from './authorization.js'
import { security } from './security.js'
import { languages } from './languages.js'

/**
 * Example: production on Google Cloud. Users sign in through Firebase Authentication, and every
 * provider authenticates as the function's service account, so no credential is written here.
 *
 *   genoa deploy gcp --config genoa.config/gcp.ts
 */
export default defineConfig({
  authentication: {
    cookieName: '__session',
    providers: {
      firebase: authenticationProvider('@genoacms/adapter-gcp/authentication/identity-platform', { projectId: 'my-project' })
    }
  },
  secrets: {
    providers: { 'secret-manager': secretsProvider('@genoacms/adapter-gcp/secrets', { projectId: 'my-project' }) }
  },
  storage: {
    providers: {
      gcs: storageProvider('@genoacms/adapter-gcp/storage', { projectId: 'my-project' })
    },
    buckets: { 'my-project-cms': { provider: 'gcs' }, 'my-project-public': { provider: 'gcs' } },
    defaultBucket: 'my-project-cms'
  },
  database: {
    providers: {
      firestore: databaseProvider('@genoacms/adapter-gcp/database', { projectId: 'my-project', databaseId: '(default)' })
    },
    databases: { content: { provider: 'firestore', collections } }
  },
  languages,
  deployment: {
    targets: {
      gcp: deploymentTarget('@genoacms/adapter-gcp/deployment', {
        projectId: 'my-project',
        region: 'europe-west3',
        memory: '1Gi',
        serviceAccount: 'genoacms@my-project.iam.gserviceaccount.com'
      })
    }
  },
  authorization,
  security
})
ts
Expand code

Before the first deploy:

  • Authentication. Enable Firebase Authentication (or Identity Platform) with email and password sign-in in my-project, and create the users there. The first administrator's authorization.assignments key is that user's UID.
  • Runtime service account (serviceAccount above): roles/storage.objectAdmin on each bucket, roles/datastore.user, roles/secretmanager.admin or a narrower custom role, roles/iam.serviceAccountTokenCreator on itself (for signed URLs), and roles/firebaseauth.viewer.
  • You, deploying: roles/cloudfunctions.developer, and roles/iam.serviceAccountUser on the runtime service account. genoa deploy uses your Application Default Credentials (gcloud auth application-default login), since the target sets no credentials.
genoa deploy gcp --config genoa.config/gcp.ts
bash

AWS

Content lives in S3 and DynamoDB, secrets in Secrets Manager, and GenoaCMS runs as a Lambda function. Every provider takes the SDK's default credentials, which in Lambda are the function's execution role. AWS has no authentication adapter yet, so administrators sign in from a list kept in Secrets Manager.

import {
  defineConfig, storageProvider, databaseProvider, authenticationProvider,
  secretsProvider, deploymentTarget, secret
} from '@genoacms/config'
import type {} from '@genoacms/authentication-adapter-array'
import type {} from '@genoacms/adapter-aws/storage'
import type {} from '@genoacms/adapter-aws/database'
import type {} from '@genoacms/adapter-aws/secrets'
import type {} from '@genoacms/adapter-aws/deployment'
import { collections } from './collections.js'
import { authorization } from './authorization.js'
import { security } from './security.js'
import { languages } from './languages.js'

/**
 * Example: production on AWS. Every provider takes the SDK's default credentials, which are the
 * Lambda function's execution role once deployed; the administrators' credentials live in
 * Secrets Manager.
 *
 *   genoa deploy aws --config genoa.config/aws.ts
 */
export default defineConfig({
  authentication: {
    cookieName: '__session',
    providers: {
      admins: authenticationProvider('@genoacms/authentication-adapter-array', { credentials: secret('GENOACMS_ADMIN_CREDENTIALS') })
    }
  },
  secrets: {
    providers: { 'secrets-manager': secretsProvider('@genoacms/adapter-aws/secrets', { region: 'eu-central-1' }) }
  },
  storage: {
    providers: {
      s3: storageProvider('@genoacms/adapter-aws/storage', { region: 'eu-central-1' })
    },
    buckets: { 'my-company-cms': { provider: 's3' }, 'my-company-public': { provider: 's3' } },
    defaultBucket: 'my-company-cms'
  },
  database: {
    providers: {
      dynamodb: databaseProvider('@genoacms/adapter-aws/database', { region: 'eu-central-1' })
    },
    databases: { content: { provider: 'dynamodb', collections } }
  },
  languages,
  deployment: {
    targets: {
      aws: deploymentTarget('@genoacms/adapter-aws/deployment', {
        region: 'eu-central-1',
        role: 'arn:aws:iam::123456789012:role/genoacms',
        artifactBucket: 'my-company-deployments'
      })
    }
  },
  authorization,
  security
})
ts
Expand code

Before the first deploy:

  • Tables. Each collection is a DynamoDB table of the same name, with a string partition key named after its primaryKey.key.
  • Administrators. Store GENOACMS_ADMIN_CREDENTIALS in Secrets Manager as a JSON array of { "email", "password", "subject" }. The first administrator's authorization.assignments key is its subject.
  • Execution role (role above): s3:GetObject, PutObject, DeleteObject and ListBucket on each bucket; dynamodb:GetItem, PutItem, UpdateItem, DeleteItem and Scan on each table; secretsmanager:GetSecretValue, DescribeSecret, PutSecretValue, CreateSecret and DeleteSecret; and AWSLambdaBasicExecutionRole for logs.
  • You, deploying: create, read and update the function and its URL, iam:PassRole on the execution role, and s3:PutObject on artifactBucket.
genoa deploy aws --config genoa.config/aws.ts
bash

Self-hosted

Content lives in MinIO and PostgreSQL on machines you run, and Node serves GenoaCMS. No cloud account is involved.

import {
  defineConfig, storageProvider, databaseProvider, authenticationProvider,
  secretsProvider, deploymentTarget, secret
} from '@genoacms/config'
import type {} from '@genoacms/authentication-adapter-array'
import type {} from '@genoacms/adapter-minio'
import type {} from '@genoacms/adapter-postgres'
import type {} from '@genoacms/adapter-secrets-env'
import type {} from '@genoacms/adapter-node'
import { collections } from './collections.js'
import { authorization } from './authorization.js'
import { security } from './security.js'
import { languages } from './languages.js'

/**
 * Example: MinIO and PostgreSQL on your own machines, served by Node. Every secret lives in
 * .genoacms/secrets.env. That store is for development only, so this config is a development one:
 *
 *   genoa dev --config genoa.config/self-hosted.ts
 */
export default defineConfig({
  authentication: {
    cookieName: '__session',
    providers: {
      admins: authenticationProvider('@genoacms/authentication-adapter-array', { credentials: secret('GENOACMS_ADMIN_CREDENTIALS') })
    }
  },
  secrets: {
    providers: { local: secretsProvider('@genoacms/adapter-secrets-env', {}) }
  },
  storage: {
    providers: {
      minio: storageProvider('@genoacms/adapter-minio', {
        endPoint: 'localhost',
        port: 9000,
        useSSL: false,
        accessKey: secret('MINIO_ACCESS_KEY'),
        secretKey: secret('MINIO_SECRET_KEY')
      })
    },
    buckets: { cms: { provider: 'minio' }, public: { provider: 'minio' } },
    defaultBucket: 'cms'
  },
  database: {
    providers: {
      postgres: databaseProvider('@genoacms/adapter-postgres', {
        host: 'localhost',
        database: 'genoacms',
        user: 'genoacms',
        password: secret('POSTGRES_PASSWORD')
      })
    },
    databases: { content: { provider: 'postgres', collections } }
  },
  languages,
  deployment: { targets: { node: deploymentTarget('@genoacms/adapter-node', { outDir: 'build' }) } },
  authorization,
  security
})
ts
Expand code
A development config

Every secret here lives in .genoacms/secrets.env, the development store, and a production build refuses it. GenoaCMS has no secrets store yet that runs in production without a cloud account. To run self-hosted in production, keep MinIO, Postgres and Node, and point secrets at a cloud secret manager.

Before the first start:

  • MinIO: the buckets cms and public exist.
  • PostgreSQL: the database genoacms, a user genoacms that can read and write it, and one table per collection.
  • Secrets: .genoacms/secrets.env holds MINIO_ACCESS_KEY, MINIO_SECRET_KEY, POSTGRES_PASSWORD and GENOACMS_ADMIN_CREDENTIALS, the last as one line of JSON.
genoa dev --config genoa.config/self-hosted.ts
bash

To serve it without the dev server, genoa deploy node --mode development --config genoa.config/self-hosted.ts builds it and copies the artifact to build/; run npm install --omit=dev there, and start it with node build.