Skip to content

Commit

Permalink
improve local setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dorukgezici committed Nov 3, 2024
1 parent ebc9d0c commit a1e4339
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 48 deletions.
1 change: 1 addition & 0 deletions .github/workflows/backend-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: "Backend: Lint & Test"

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/prefect-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,7 @@ jobs:
enable-cache: true

- name: Prefect Deploy
env:
PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }}
SUBABOT_BACKEND_URL: ${{ secrets.SUBABOT_BACKEND_URL }}
SUBABOT_FRONTEND_URL: ${{ secrets.SUBABOT_FRONTEND_URL }}
SLACK_CLIENT_ID: ${{ secrets.SLACK_CLIENT_ID }}
SLACK_CLIENT_SECRET: ${{ secrets.SLACK_CLIENT_SECRET }}
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }}
SLACK_APP_ID: ${{ secrets.SLACK_APP_ID }}
SLACK_TEAM_ID: ${{ secrets.SLACK_TEAM_ID }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
run: |
cd backend
uv sync --frozen
uv run task deploy
uv run prefect deploy --all --param build=null
14 changes: 7 additions & 7 deletions .zed/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@
{
"label": "prefect-server",
"cwd": "$ZED_WORKTREE_ROOT/backend",
"command": "uv run prefect server start",
"command": "uv run task server",
"reveal": "always"
},
{
"label": "prefect-worker",
"cwd": "$ZED_WORKTREE_ROOT/backend",
"command": "uv run prefect worker start --pool work-pool",
"command": "uv run task create-work-pool && uv run task worker",
"reveal": "always"
},
{
"label": "frontend-dev",
"cwd": "$ZED_WORKTREE_ROOT/frontend",
"command": "pnpm run dev",
"label": "prefect-deploy",
"cwd": "$ZED_WORKTREE_ROOT/backend",
"command": "uv run task deploy",
"reveal": "always"
},
{
"label": "frontend-typegen",
"label": "frontend-dev",
"cwd": "$ZED_WORKTREE_ROOT/frontend",
"command": "pnpm run typegen",
"command": "pnpm run dev",
"reveal": "always"
}
]
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.12 AS base
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
WORKDIR /app
COPY subabot/__init__.py pyproject.toml uv.lock README.md ./
COPY pyproject.toml uv.lock README.md ./
RUN uv sync --frozen

FROM base AS runtime
Expand Down
6 changes: 3 additions & 3 deletions backend/Dockerfile.prefect
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM prefecthq/prefect:3.0.9-python3.12-kubernetes AS base
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
WORKDIR /app
COPY subabot/__init__.py pyproject.toml uv.lock README.md ./
WORKDIR /opt/prefect
COPY pyproject.toml uv.lock README.md ./
RUN uv sync --frozen

FROM base AS runtime
ENV PYTHONUNBUFFERED=1
COPY . ./
COPY subabot/ ./subabot/
42 changes: 16 additions & 26 deletions backend/prefect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,33 @@ name: subabot
prefect-version: 3.0.9

build:
null
- prefect.deployments.steps.run_shell_script:
id: get-commit-hash
script: git rev-parse --short HEAD
stream_output: false
- prefect_docker.deployments.steps.build_docker_image:
id: build-image
requires: prefect-docker
image_name: dorukgezici/subabot
dockerfile: Dockerfile.prefect
tag: prefect-{{ get-commit-hash.stdout }}

# - prefect.deployments.steps.run_shell_script:
# id: get-commit-hash
# script: git rev-parse --short HEAD
# stream_output: false
# - prefect_docker.deployments.steps.build_docker_image:
# id: build-image
# requires: prefect-docker>=0.6.1
# image_name: dorukgezici/subabot
# tag: prefect-{{ get-commit-hash.stdout }}
# dockerfile: Dockerfile.prefect

push:
null
# - prefect_docker.deployments.steps.push_docker_image:
# requires: prefect-docker>=0.6.1
# image_name: "{{ build-image.image_name }}"
# tag: "{{ build-image.tag }}"
pull:
- prefect.deployments.steps.set_working_directory:
directory: .

deployments:
- name: subabot
# version: "{{ build-image.tag }}"
version: "latest"
version: "prefect-latest"
tags: []
description:
entrypoint: subabot/flows.py:rss_crawler
parameters: {}
work_pool:
name: workers
name: work-pool
work_queue_name: default
job_variables:
# image: "{{ build-image.image }}"
image: "dorukgezici/subabot:prefect-latest"
image: "{{ build-image.image }}"
enforce_parameter_schema: true
schedules:
- cron: 0 0 * * *
Expand All @@ -45,6 +38,3 @@ deployments:
max_active_runs: 1
catchup: false
concurrency_limit: 1
pull:
- prefect.deployments.steps.set_working_directory:
directory: /app
4 changes: 4 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ dev = "uvicorn subabot.api:app --host 0.0.0.0 --port 8000 --reload"
test = "pytest tests"
lint = "ruff check"
format = "ruff format"
# Prefect
server = "prefect server start"
create-work-pool = "prefect work-pool create work-pool --type process --overwrite"
worker = "prefect worker start --pool work-pool"
deploy = "prefect deploy --all"

[build-system]
Expand Down

0 comments on commit a1e4339

Please sign in to comment.