Skip to content
Open
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
55 changes: 55 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,58 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha,scope=${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.name }}

build-job-service:
name: Build knative-job-service
runs-on: ubuntu-latest

env:
REGISTRY: ghcr.io

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup pnpm
uses: pnpm/action-setup@v6

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Generate workspace packages
run: |
node --experimental-strip-types scripts/generate.ts

Comment on lines +120 to +131
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Log in to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/knative-job-service
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=sha,format=short,prefix=

- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: job/service/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha,scope=knative-job-service
cache-to: type=gha,mode=max,scope=knative-job-service
20 changes: 20 additions & 0 deletions job/service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:22-alpine AS build
RUN npm install -g pnpm@10.12.2
WORKDIR /app
COPY . .
RUN node --experimental-strip-types scripts/generate.ts \
&& pnpm install --frozen-lockfile \
&& pnpm --filter @constructive-io/knative-job-service... build

FROM node:22-alpine AS deploy
RUN npm install -g pnpm@10.12.2
COPY --from=build /app /app
WORKDIR /app
RUN pnpm --filter @constructive-io/knative-job-service deploy --legacy /deploy --prod

FROM node:22-alpine
WORKDIR /app
COPY --from=deploy /deploy .
ENV NODE_ENV=production
EXPOSE 8080
CMD ["node", "dist/run.js"]
7 changes: 4 additions & 3 deletions k8s/base/constructive/knative-job-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ spec:
spec:
containers:
- name: knative-job-service
image: ghcr.io/constructive-io/constructive:e0b55cc
# Pin to a short SHA at deploy time (e.g. ghcr.io/constructive-io/knative-job-service:abc1234).
# Built by .github/workflows/docker.yaml from job/service/Dockerfile.
image: ghcr.io/constructive-io/knative-job-service:latest
imagePullPolicy: Always

# Run the knative job service entrypoint from the root image
command: ["node"]
args: ["jobs/knative-job-service/dist/run.js"]
args: ["dist/run.js"]
Comment on lines +25 to +31

envFrom:
- configMapRef:
Expand Down
Loading