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
26 changes: 0 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,29 +153,3 @@ jobs:
BETTER_AUTH_SECRET: 'test-secret-minimum-32-characters-long-for-ci'
BETTER_AUTH_URL: 'http://localhost:8080'
NEXT_PUBLIC_API_URL: 'http://localhost:8080/api'

docker-build:
runs-on: ubuntu-latest
needs: [lint, typecheck]
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build API image
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/api/Dockerfile
push: false

- name: Build Web image
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/web/Dockerfile
push: false
build-args: |
NEXT_PUBLIC_API_URL=http://localhost:8080/api
49 changes: 49 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Docker Build

on:
pull_request:
branches: [main, development]
push:
branches: [main]

# Cancel in-progress runs when a new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build API image
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/api/Dockerfile
push: false
cache-from: type=gha
cache-to: type=gha,mode=max

build-web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Web image
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/web/Dockerfile
push: false
build-args: |
NEXT_PUBLIC_API_URL=http://localhost:8080/api
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 1 addition & 1 deletion create-blitzpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-blitzpack",
"version": "0.1.17",
"version": "0.1.18",
"description": "Create a new Blitzpack project - full-stack TypeScript monorepo with Next.js and Fastify",
"type": "module",
"bin": {
Expand Down
27 changes: 0 additions & 27 deletions create-blitzpack/src/ci-workflow-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,31 +156,4 @@ jobs:
BETTER_AUTH_URL: 'http://localhost:8080'
NEXT_PUBLIC_API_URL: 'http://localhost:8080/api'

# @feature dockerDeploy
docker-build:
runs-on: ubuntu-latest
needs: [lint, typecheck]
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build API image
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/api/Dockerfile
push: false

- name: Build Web image
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/web/Dockerfile
push: false
build-args: |
NEXT_PUBLIC_API_URL=http://localhost:8080/api
# @endfeature
`;
1 change: 1 addition & 0 deletions create-blitzpack/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const FEATURE_EXCLUSIONS: Record<FeatureKey, string[]> = {
'apps/api/Dockerfile',
'apps/web/Dockerfile',
'deploy/docker',
'.github/workflows/docker-build.yml',
],
ciCd: ['.github/workflows/cd.yml'],
};
Expand Down
50 changes: 50 additions & 0 deletions create-blitzpack/src/docker-ci-workflow-template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export const DOCKER_CI_WORKFLOW_TEMPLATE = `name: Docker Build

on:
pull_request:
branches: [main, development]
push:
branches: [main]

# Cancel in-progress runs when a new commit is pushed
concurrency:
group: \${{ github.workflow }}-\${{ github.ref }}
cancel-in-progress: true

jobs:
build-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build API image
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/api/Dockerfile
push: false
cache-from: type=gha
cache-to: type=gha,mode=max

build-web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Web image
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/web/Dockerfile
push: false
build-args: |
NEXT_PUBLIC_API_URL=http://localhost:8080/api
cache-from: type=gha
cache-to: type=gha,mode=max
`;
21 changes: 21 additions & 0 deletions create-blitzpack/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
REPLACEABLE_FILES,
type TemplateVariables,
} from './constants.js';
import { DOCKER_CI_WORKFLOW_TEMPLATE } from './docker-ci-workflow-template.js';

const TESTING_SCRIPTS = [
'test',
Expand Down Expand Up @@ -42,6 +43,7 @@ const TESTING_FILE_PATTERNS = [
const TS_CONFIG_FILE_PATTERN = /^tsconfig(?:\.[^.]+)?\.json$/;
const AGENT_DOC_TARGETS = ['CLAUDE.md', 'AGENTS.md'];
const CI_WORKFLOW_RELATIVE_PATH = '.github/workflows/ci.yml';
const DOCKER_CI_WORKFLOW_RELATIVE_PATH = '.github/workflows/docker-build.yml';

const MARKER_FILES = [
'apps/api/src/app.ts',
Expand Down Expand Up @@ -283,6 +285,7 @@ async function applyFeatureTransforms(
}

await transformCiWorkflow(targetDir, disabledFeatures);
await transformDockerCiWorkflow(targetDir, features);
await transformAgentDocs(targetDir, disabledFeatures);
}

Expand Down Expand Up @@ -515,3 +518,21 @@ async function transformCiWorkflow(
content = cleanEmptyLines(content).trimEnd() + '\n';
await fs.writeFile(workflowPath, content, 'utf-8');
}

async function transformDockerCiWorkflow(
targetDir: string,
features: FeatureOptions
): Promise<void> {
const workflowPath = path.join(targetDir, DOCKER_CI_WORKFLOW_RELATIVE_PATH);

if (!features.dockerDeploy) {
if (await fs.pathExists(workflowPath)) {
await fs.remove(workflowPath);
}
return;
}

await fs.ensureDir(path.dirname(workflowPath));
const content = DOCKER_CI_WORKFLOW_TEMPLATE.trimEnd() + '\n';
await fs.writeFile(workflowPath, content, 'utf-8');
}