Skip to main content
LabsApplicationStack is a comprehensive workflow stack designed for the common Penn Labs architecture: a Django backend and React frontend. It orchestrates the entire CI/CD pipeline from code quality checks to production deployment.

Overview

The LabsApplicationStack creates a complete GitHub Actions workflow that:
  • Lints and tests both Django and React projects
  • Builds and publishes Docker images
  • Optionally runs integration tests
  • Deploys to production on the default branch
By default, it publishes two Docker images: {dockerImageBaseName}-backend and {dockerImageBaseName}-frontend.

Constructor

new LabsApplicationStack(
  scope: Construct,
  config: LabsApplicationStackProps,
  overrides?: Partial<WorkflowProps>
)

Parameters

scope
Construct
required
The cdkactions App instance that serves as the parent scope.
config
LabsApplicationStackProps
required
Configuration object for the stack.
config.djangoProjectName
string
required
Name of the Django project to test and build.
config.dockerImageBaseName
string
required
Base name for Docker images. Will publish {base}-backend and {base}-frontend images.
config.backendPath
string
default:"backend"
Path to the Django project directory within the repository.
config.frontendPath
string
default:"frontend"
Path to the React project directory within the repository.
config.integrationTests
boolean
default:false
If true, runs integration tests using docker-compose before deploying.
config.djangoCheckProps
Partial<DjangoCheckJobProps>
Optional props to customize the Django check job.
config.djangoCheckOverrides
Partial<JobProps>
Optional overrides for the Django check job configuration.
config.djangoDockerProps
Partial<DockerPublishJobProps>
Optional props to customize the Django Docker publish job.
config.djangoDockerOverrides
Partial<JobProps>
Optional overrides for the Django Docker publish job configuration.
config.reactCheckProps
Partial<ReactCheckJobProps>
Optional props to customize the React check job.
config.reactCheckOverrides
Partial<JobProps>
Optional overrides for the React check job configuration.
config.reactDockerProps
Partial<DockerPublishJobProps>
Optional props to customize the React Docker publish job.
config.reactDockerOverrides
Partial<JobProps>
Optional overrides for the React Docker publish job configuration.
config.integrationProps
Partial<IntegrationTestsJobProps>
Optional props to customize the integration tests job.
config.integrationOverrides
Partial<JobProps>
Optional overrides for the integration tests job configuration.
config.deployProps
Partial<DeployJobProps>
Optional props to customize the deploy job.
config.deployOverrides
Partial<JobProps>
Optional overrides for the deploy job configuration.
overrides
Partial<WorkflowProps>
Optional overrides for the workflow itself (name, triggers, etc.).

Basic Usage

The simplest configuration for a standard Django + React project:
import { LabsApplicationStack } from '@pennlabs/kraken';
import { App } from 'cdkactions';

const app = new App();

new LabsApplicationStack(app, {
  djangoProjectName: 'exampleDjangoProject',
  dockerImageBaseName: 'example-product',
});

app.synth();
This creates a workflow that:
  1. Checks out code
  2. Runs Django linting and tests in backend/
  3. Runs React linting and tests in frontend/
  4. Builds and publishes example-product-backend Docker image
  5. Builds and publishes example-product-frontend Docker image
  6. Deploys to production (on master branch only)

Advanced Usage

Custom Paths

If your project structure differs from the defaults:
new LabsApplicationStack(app, {
  djangoProjectName: 'myproject',
  dockerImageBaseName: 'my-app',
  backendPath: 'server',
  frontendPath: 'client',
});

With Integration Tests

Enable integration tests that run after building Docker images:
new LabsApplicationStack(app, {
  djangoProjectName: 'myproject',
  dockerImageBaseName: 'my-app',
  integrationTests: true,
  integrationProps: {
    testCommand: 'docker-compose -f docker-compose.test.yml run --rm integration-tests',
  },
});

Custom Job Configuration

Customize individual jobs within the stack:
new LabsApplicationStack(app, {
  djangoProjectName: 'myproject',
  dockerImageBaseName: 'my-app',
  djangoCheckProps: {
    pythonVersion: '3.11',
  },
  reactCheckProps: {
    nodeVersion: '18',
  },
  deployProps: {
    defaultBranch: 'main',
  },
});

Generated Workflow

The stack generates a GitHub Actions workflow with the following job dependency graph:

Without Integration Tests

Django Check → Django Docker Publish ┐
                                      ├→ Deploy
React Check → React Docker Publish  ┘

With Integration Tests

Django Check → Django Docker Build ┐
                                    ├→ Integration Tests → Deploy
React Check → React Docker Build   ┘
When integrationTests is enabled, Docker images are built but not published until integration tests pass. This ensures only validated images reach the registry.

See Also

Build docs developers (and LLMs) love