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
4 changes: 0 additions & 4 deletions .devcontainer/Dockerfile

This file was deleted.

17 changes: 0 additions & 17 deletions .devcontainer/compose.yml

This file was deleted.

34 changes: 9 additions & 25 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,24 @@
{
"name": "Nix",

"dockerComposeFile": "compose.yml",
"service": "dev",
"workspaceFolder": "/workspace",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
"build": {
"context": "..",
"dockerfile": "../packaging/docker/Dockerfile-dev"
},
"overrideCommand": true,

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
"workspaceFolder": "/workspace",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",

"overrideCommand": false,
"userEnvProbe": "loginShell",
"updateRemoteUserUID": false,
"remoteUser": "ubuntu",

"portsAttributes": {
"5173": {
"label": "Transcribee",
"label": "transcribee",
"onAutoForward": "notify"
}
},

"onCreateCommand": "nix-shell shell.nix --command ./packaging/install_dependencies.sh",

// Configure tool-specific properties.
"customizations": {
"vscode": {
Expand All @@ -34,15 +29,4 @@
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"

// This is purely informative: https://containers.dev/implementors/json_reference/#min-host-reqs
// "hostRequirements": {
// "cpus": 4,
// "memory": "8gb",
// "storage": "20gb",
// "gpu": true
// }
}
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ backend/storage
backend/.venv
worker/.venv
frontend/node_modules/
frontend/dist/
frontend/testData
.git
packaging/Dockerfile
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build docker images

on:
pull_request:
push:
branches: [main]
merge_group:

env:
REGISTRY: ghcr.io

jobs:
build-backend:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Build
uses: docker/build-push-action@v7
with:
context: .
pull: true # always pull dependency images
file: packaging/docker/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create and publish a Docker image
name: Publish docker images
Comment thread
anuejn marked this conversation as resolved.

on:
push:
Expand All @@ -17,21 +17,21 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: actions/checkout@v6

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
Expand All @@ -42,13 +42,14 @@ jobs:
# set latest tag for main branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
push: true
pull: true # always pull dependency images
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: packaging/Dockerfile
file: packaging/docker/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.direnv
.DS_Store
1 change: 1 addition & 0 deletions .python-version
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to not have this as a toplevel file. I would be okay to leave the versions separate (we already have to change it in multiple places anyway) and this suggests, that this is the only place to change it (it is not).

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
12 changes: 7 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"python.autoComplete.extraPaths": [
"backend/.venv/lib/python3.11/site-packages",
"worker/.venv/lib/python3.11/site-packages"
"backend/.venv/lib/python3.12/site-packages",
"worker/.venv/lib/python3.12/site-packages"
],
"python.analysis.extraPaths": [
"backend/.venv/lib/python3.11/site-packages",
"worker/.venv/lib/python3.11/site-packages"
"backend/.venv/lib/python3.12/site-packages",
"worker/.venv/lib/python3.12/site-packages"
],
"python.analysis.typeCheckingMode": "basic",
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
"nixEnvSelector.nixFile": "${workspaceFolder}/flake.nix",
"nixEnvSelector.useFlakes": true,
"nixEnvSelector.flakeShell": "default",
}
1 change: 1 addition & 0 deletions backend/.python-version
10 changes: 0 additions & 10 deletions backend/openapi-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -752,16 +752,6 @@ info:
version: 0.1.0
openapi: 3.1.0
paths:
/:
get:
operationId: root__get
responses:
'200':
content:
application/json:
schema: {}
description: Successful Response
summary: Root
/api/v1/config/:
get:
operationId: get_config_api_v1_config__get
Expand Down
Empty file added backend/public/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies = [
"prometheus-fastapi-instrumentator~=6.1",
"pydantic~=2.2",
"pydantic-settings>=2.7",
"poethepoet>=0.46.0",
]
requires-python = "~=3.12.0"
readme = "./README.md"
Expand Down
18 changes: 13 additions & 5 deletions backend/transcribee_backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from transcribee_backend.routers.task import task_router
from transcribee_backend.routers.user import user_router
from transcribee_backend.routers.worker import worker_router
from transcribee_backend.spa_static_files import SPAStaticFiles

from .media_storage import serve_media

Expand Down Expand Up @@ -61,10 +62,17 @@ async def lifespan(_: FastAPI):
app.include_router(page_router, prefix="/api/v1/page")
app.include_router(worker_router, prefix="/api/v1/worker")


@app.get("/")
async def root():
return {"message": "🎤🐝: *taps mic* bzzp bzzp"}
app.get("/media/{file}")(serve_media)


app.get("/media/{file}")(serve_media)
app.mount(
"/",
SPAStaticFiles(
directory="public",
html=True,
no_cache_paths=[".", "index.html"],
assets_prefix="assets/",
assets_cache_header="public, max-age=86400, immutable", # aggressively cache for 1 day
),
name="static-files",
)
41 changes: 41 additions & 0 deletions backend/transcribee_backend/spa_static_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from fastapi import HTTPException
from fastapi.staticfiles import StaticFiles
from starlette.exceptions import HTTPException as StarletteHTTPException


class SPAStaticFiles(StaticFiles):
def __init__(
self,
*args,
no_cache_paths: list[str],
assets_prefix: str,
assets_cache_header: str | None,
**kwargs,
):
super().__init__(*args, **kwargs)
self.no_cache_paths = no_cache_paths
self.assets_prefix = assets_prefix
self.assets_cache_header = assets_cache_header

async def get_response(self, path: str, scope):
try:
res = await super().get_response(path, scope)
if path in self.no_cache_paths:
res.headers["cache-control"] = "no-cache"
elif self.assets_cache_header is not None and path.startswith(
self.assets_prefix
):
res.headers["cache-control"] = self.assets_cache_header
return res
except (HTTPException, StarletteHTTPException) as ex:
if ex.status_code == 404:
if path.startswith(self.assets_prefix):
# Return 404 for missing assets
raise ex
else:
res = await super().get_response("index.html", scope)
if "index.html" in self.no_cache_paths:
res.headers["cache-control"] = "no-cache"
return res
else:
raise ex
47 changes: 36 additions & 11 deletions backend/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions compose.dev.yml

This file was deleted.

Loading