Skip to content

Commit

Permalink
ci: pagefind worker Dockerfile and ci action
Browse files Browse the repository at this point in the history
  • Loading branch information
cdxker committed Dec 19, 2024
1 parent c56c246 commit 5ae3c4b
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/push-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -802,3 +802,53 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


pagefind-worker:
name: Push Pagefind Index worker
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: [blacksmith-8vcpu-ubuntu-2204]
platform: [linux/amd64]
exclude:
- runner: blacksmith-8vcpu-ubuntu-2204
platform: linux/arm64
- runner: blacksmith-8vcpu-ubuntu-2204-arm
platform: linux/amd64
steps:
- name: Checkout the repo
uses: actions/checkout@v4

# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3

- name: Setup buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
trieve/pagefind-worker
tags: |
type=raw,latest
type=sha
- name: Build and push Docker image
uses: useblacksmith/[email protected]
with:
platforms: ${{ matrix.platform }}
context: server/
file: ./server/Dockerfile.pagefind-worker
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
25 changes: 25 additions & 0 deletions helm/templates/pagefind-worker-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pagefind-worker
labels:
app.kubernetes.io/name: pagefind-worker
app.kubernetes.io/instance: {{ $.Release.Name }}
spec:
replicas: {{ $.Values.containers.crawl_worker.replicas | default 1 }}
selector:
matchLabels:
app.kubernetes.io/name: pagefind-worker
app.kubernetes.io/instance: {{ $.Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: pagefind-worker
app.kubernetes.io/instance: {{ $.Release.Name }}
spec:
containers:
- name: pagefind-worker
image: {{ printf "%s:%s" "trieve/pagefind-worker" $.Values.containers.pagefind_worker.tag }}
envFrom:
- configMapRef:
name: trieve-server-config
6 changes: 6 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ containers:
csv_jsonl_worker:
tag: latest
resources: {}
pagefind_worker:
tag: latest
resources: {}
video_worker:
tag: latest
resources: {}
search:
tag: latest
resources: {}
Expand Down
43 changes: 43 additions & 0 deletions server/Dockerfile.pagefind-worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM rust:1.81-slim-bookworm AS chef
# We only pay the installation cost once,
# it will be cached from the second build onwards
RUN apt-get update -y && apt-get -y install pkg-config libssl-dev libpq-dev g++ curl
RUN cargo install cargo-chef
WORKDIR /app

FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json --bin "pagefind-worker"
# Build application
COPY . .
RUN cargo build --release --features "runtime-env" --bin "pagefind-worker"

FROM debian:bookworm-slim AS runtime

WORKDIR /app

RUN apt-get update -y; \
apt-get install -y \
pkg-config \
build-essential\
libssl-dev \
libpq-dev \
ca-certificates \
curl \
redis-tools \
;

RUN curl -fsSLO https://github.com/subtrace/subtrace/releases/download/b143/subtrace-linux-amd64 \
&& chmod +x ./subtrace-linux-amd64

COPY ./migrations/ /app/migrations
COPY --from=builder /app/target/release/pagefind-worker /app/pagefind-worker


EXPOSE 8090
ENTRYPOINT ["/app/pagefind-worker"]

0 comments on commit 5ae3c4b

Please sign in to comment.