From 8f638ccf84726ed7d94714c5cde43f0135e157a7 Mon Sep 17 00:00:00 2001 From: Justin Brooks Date: Sun, 25 Aug 2024 23:12:49 -0400 Subject: [PATCH] add dispatcher docker image --- .github/workflows/apps-job-dispatcher.yaml | 62 +++++++++++++++++++ .../workflows/apps-job-policy-checker.yaml | 4 +- apps/job-dispatcher/Dockerfile | 40 ++++++++++++ apps/job-policy-checker/Dockerfile | 1 - 4 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/apps-job-dispatcher.yaml create mode 100644 apps/job-dispatcher/Dockerfile diff --git a/.github/workflows/apps-job-dispatcher.yaml b/.github/workflows/apps-job-dispatcher.yaml new file mode 100644 index 00000000..37927473 --- /dev/null +++ b/.github/workflows/apps-job-dispatcher.yaml @@ -0,0 +1,62 @@ +name: Apps / Job Policy Checker + +on: + pull_request: + branches: ["*"] + paths: + - apps/job-dispatcher/** + - packages/db/** + - .github/workflows/apps-job-dispatcher.yaml + - pnpm-lock.yaml + push: + branches: ["main"] + paths: + - apps/job-dispatcher/** + - packages/db/** + - .github/workflows/apps-job-dispatcher.yaml + - pnpm-lock.yaml + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ctrlplane/job-dispatchers + tags: | + type=sha,format=short,prefix= + + - name: Build + uses: docker/build-push-action@v6 + if: github.ref != 'refs/heads/main' + with: + push: false + file: apps/job-dispatchers/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + + - name: Build and Push + uses: docker/build-push-action@v6 + if: github.ref == 'refs/heads/main' + with: + push: true + file: apps/job-dispatchers/Dockerfile + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/apps-job-policy-checker.yaml b/.github/workflows/apps-job-policy-checker.yaml index 3b87dbb3..8895c8c8 100644 --- a/.github/workflows/apps-job-policy-checker.yaml +++ b/.github/workflows/apps-job-policy-checker.yaml @@ -5,7 +5,7 @@ on: branches: ["*"] paths: - apps/job-policy-checker/** - - packages/job-dispatcher/** + - packages/job-dispatch/** - packages/db/** - .github/workflows/apps-job-policy-checker.yaml - pnpm-lock.yaml @@ -13,7 +13,7 @@ on: branches: ["main"] paths: - apps/job-policy-checker/** - - packages/job-dispatcher/** + - packages/job-dispatch/** - packages/db/** - .github/workflows/apps-job-policy-checker.yaml - pnpm-lock.yaml diff --git a/apps/job-dispatcher/Dockerfile b/apps/job-dispatcher/Dockerfile new file mode 100644 index 00000000..f492f5e0 --- /dev/null +++ b/apps/job-dispatcher/Dockerfile @@ -0,0 +1,40 @@ +ARG NODE_VERSION=22 +FROM node:${NODE_VERSION}-alpine + +RUN apk add --no-cache libc6-compat python3 make g++ bash nano + +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" + +RUN npm install -g turbo +RUN corepack enable pnpm + +WORKDIR /app + +COPY .gitignore .gitignore +COPY turbo.json turbo.json +RUN pnpm add -g turbo + +COPY package.json package.json +COPY pnpm-*.yaml . + +COPY tooling/prettier/package.json ./tooling/prettier/package.json +COPY tooling/eslint/package.json ./tooling/eslint/package.json +COPY tooling/typescript/package.json ./tooling/typescript/package.json + +COPY packages/db/package.json ./packages/db/package.json +COPY packages/job-dispatch/package.json ./packages/job-dispatch/package.json + +COPY apps/job-dispatcher/package.json ./apps/job-dispatcher/package.json + +RUN pnpm install --frozen-lockfile + +COPY . . + +RUN turbo build --filter=...@ctrlplane/job-dispatcher + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nodejs +USER nodejs + +CMD node apps/job-dispatcher/dist/index.js \ No newline at end of file diff --git a/apps/job-policy-checker/Dockerfile b/apps/job-policy-checker/Dockerfile index 3c0e554d..54c3b72a 100644 --- a/apps/job-policy-checker/Dockerfile +++ b/apps/job-policy-checker/Dockerfile @@ -18,7 +18,6 @@ RUN pnpm add -g turbo COPY package.json package.json COPY pnpm-*.yaml . -COPY tooling/tailwind/package.json ./tooling/tailwind/package.json COPY tooling/prettier/package.json ./tooling/prettier/package.json COPY tooling/eslint/package.json ./tooling/eslint/package.json COPY tooling/typescript/package.json ./tooling/typescript/package.json