-
-
Notifications
You must be signed in to change notification settings - Fork 724
Add supervisor build pipeline #1772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
11b0b6a
dockerignore node_modules in subdirectories
nicktrn e1eb2e4
image tag action should handle re2 tags
nicktrn d4100f9
add supervisor containerfile
nicktrn 35797f8
add publish worker re2 workflow
nicktrn 63cb42a
Merge remote-tracking branch 'origin/main' into feat/supervisor-publish
nicktrn 2fc4959
fix copypasta
nicktrn 4e27ced
require branch check
nicktrn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
# dependencies | ||
|
||
node_modules | ||
**/node_modules | ||
.pnp | ||
.pnp.js | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: "⚒️ Publish Worker RE2" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image_tag: | ||
description: The image tag to publish | ||
type: string | ||
required: false | ||
default: "" | ||
push: | ||
tags: | ||
- "re2-test-*" | ||
- "re2-prod-*" | ||
|
||
permissions: | ||
packages: write | ||
contents: read | ||
|
||
jobs: | ||
check-branch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fail if re2-prod-* is pushed from a non-main branch | ||
if: startsWith(github.ref_name, 're2-prod-') && github.base_ref != 'main' | ||
run: | | ||
echo "🚫 re2-prod-* tags can only be pushed from the main branch." | ||
exit 1 | ||
build: | ||
needs: check-branch | ||
strategy: | ||
matrix: | ||
package: [supervisor] | ||
runs-on: ubuntu-latest | ||
env: | ||
DOCKER_BUILDKIT: "1" | ||
steps: | ||
- name: ⬇️ Checkout git repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: 📦 Get image repo | ||
id: get_repository | ||
run: | | ||
if [[ "${{ matrix.package }}" == *-provider ]]; then | ||
provider_type=$(echo "${{ matrix.package }}" | cut -d- -f1) | ||
repo=provider/${provider_type} | ||
else | ||
repo="${{ matrix.package }}" | ||
fi | ||
echo "repo=${repo}" >> "$GITHUB_OUTPUT" | ||
|
||
- id: get_tag | ||
uses: ./.github/actions/get-image-tag | ||
with: | ||
tag: ${{ inputs.image_tag }} | ||
|
||
- name: 🐋 Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
# ..to avoid rate limits when pulling images | ||
- name: 🐳 Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: 🚢 Build Container Image | ||
run: | | ||
docker build -t infra_image -f ./apps/${{ matrix.package }}/Containerfile . | ||
|
||
# ..to push image | ||
- name: 🐙 Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: 🐙 Push to GitHub Container Registry | ||
run: | | ||
docker tag infra_image "$REGISTRY/$REPOSITORY:$IMAGE_TAG" | ||
docker push "$REGISTRY/$REPOSITORY:$IMAGE_TAG" | ||
env: | ||
REGISTRY: ghcr.io/triggerdotdev | ||
REPOSITORY: ${{ steps.get_repository.outputs.repo }} | ||
IMAGE_TAG: ${{ steps.get_tag.outputs.tag }} | ||
|
||
- name: 🐙 Push 'v3' tag to GitHub Container Registry | ||
if: steps.get_tag.outputs.is_semver == 'true' | ||
run: | | ||
docker tag infra_image "$REGISTRY/$REPOSITORY:v3" | ||
docker push "$REGISTRY/$REPOSITORY:v3" | ||
env: | ||
REGISTRY: ghcr.io/triggerdotdev | ||
REPOSITORY: ${{ steps.get_repository.outputs.repo }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
FROM node:22-alpine@sha256:9bef0ef1e268f60627da9ba7d7605e8831d5b56ad07487d24d1aa386336d1944 AS node-22-alpine | ||
|
||
WORKDIR /app | ||
|
||
FROM node-22-alpine AS pruner | ||
|
||
COPY --chown=node:node . . | ||
RUN npx -q turbo@1.10.9 prune --scope=supervisor --docker | ||
RUN find . -name "node_modules" -type d -prune -exec rm -rf '{}' + | ||
|
||
FROM node-22-alpine AS base | ||
|
||
RUN apk add --no-cache dumb-init | ||
|
||
COPY --chown=node:node .gitignore .gitignore | ||
COPY --from=pruner --chown=node:node /app/out/json/ . | ||
COPY --from=pruner --chown=node:node /app/out/pnpm-lock.yaml ./pnpm-lock.yaml | ||
COPY --from=pruner --chown=node:node /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml | ||
|
||
FROM base AS dev-deps | ||
RUN corepack enable | ||
ENV NODE_ENV development | ||
|
||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --no-frozen-lockfile | ||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --ignore-scripts --no-frozen-lockfile | ||
|
||
FROM base AS prod-deps | ||
RUN corepack enable | ||
ENV NODE_ENV production | ||
|
||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --prod --no-frozen-lockfile | ||
|
||
COPY --from=pruner --chown=node:node /app/internal-packages/database/prisma/schema.prisma /app/internal-packages/database/prisma/schema.prisma | ||
|
||
ENV NPM_CONFIG_IGNORE_WORKSPACE_ROOT_CHECK true | ||
RUN pnpx prisma@5.4.1 generate --schema /app/internal-packages/database/prisma/schema.prisma | ||
|
||
FROM base AS builder | ||
RUN corepack enable | ||
|
||
COPY --from=pruner --chown=node:node /app/out/full/ . | ||
COPY --from=dev-deps --chown=node:node /app/ . | ||
COPY --chown=node:node turbo.json turbo.json | ||
COPY --chown=node:node .configs/tsconfig.base.json .configs/tsconfig.base.json | ||
COPY --chown=node:node scripts/updateVersion.ts scripts/updateVersion.ts | ||
|
||
RUN pnpm run generate && \ | ||
pnpm run -r --filter supervisor... build | ||
|
||
FROM base AS runner | ||
|
||
RUN corepack enable | ||
ENV NODE_ENV production | ||
|
||
COPY --from=pruner --chown=node:node /app/out/full/ . | ||
COPY --from=prod-deps --chown=node:node /app . | ||
COPY --from=builder --chown=node:node /app/apps/supervisor ./apps/supervisor | ||
|
||
EXPOSE 8000 | ||
|
||
USER node | ||
|
||
CMD [ "/usr/bin/dumb-init", "--", "pnpm", "run", "--filter", "supervisor", "start"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.