Files
v2x-server/.devcontainer/compose.override.yaml
T
gnickensandClaude Opus 5 c7838acbbf
CI / check (push) Canceled after 0s
Fix devcontainer build, event-loop scope, and UTC timestamps
Found by running the stack for the first time:

- compose build context pointed outside the repo. Relative paths in
  .devcontainer/compose.override.yaml resolve against the project
  directory (the repo root), not the file's own directory, so "context: .."
  escaped the repository and the image could not build at all.
- The devcontainers/python base image ships a yarn apt source whose
  signing key has rotated, failing apt-get update and the whole build.
  Drop that source list; we don't use yarn.
- pytest-asyncio ran fixtures on a session-scoped loop while tests ran on
  per-function loops, so asyncmy raised "Future attached to a different
  loop" on every database-backed test. aiosqlite masked this; MySQL does
  not. Fixture loop scope now matches the test loop scope.
- MySQL DATETIME stores no offset, so timestamps serialized bare and left
  clients guessing. Connections are pinned to UTC, so DeviceRead now
  attaches that offset explicitly, with a test covering it.

Verified end to end against real MySQL 8.4 and Keycloak 26.7: cold start
from destroyed volumes, uv sync --frozen, migrations, 41 tests, ruff,
mypy --strict, and the live authorization matrix driven by real tokens.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-10 13:02:13 -04:00

49 lines
2.0 KiB
YAML

# Adds the development container to the stack defined in ../compose.yaml.
# Merged by devcontainer.json; not useful on its own.
#
# NOTE: relative paths below resolve against the *project directory* -- the
# directory of the first compose file (the repo root), not this file's own
# directory. Hence "." rather than "..".
services:
app:
build:
context: .
dockerfile: .devcontainer/Dockerfile
command: sleep infinity
ports:
- "8000:8000"
volumes:
- .:/workspaces/v2x-server:cached
# Keep the Linux venv out of the macOS/Windows bind mount. Without this,
# host-side tooling and platform-specific wheels collide.
- venv:/workspaces/v2x-server/.venv
environment:
APP_ENV: local
DEBUG: "true"
DATABASE_URL: mysql+asyncmy://v2x:v2xpassword@mysql:3306/v2x?charset=utf8mb4
TEST_DATABASE_URL: mysql+asyncmy://v2x:v2xpassword@mysql:3306/v2x_test?charset=utf8mb4
# Validated against the `iss` claim -- must match the URL the browser used
# to obtain the token, not the one this container dials.
KEYCLOAK_ISSUER: http://localhost:8080/realms/v2x
# Where this container actually reaches Keycloak for discovery + JWKS.
# KC_HOSTNAME_BACKCHANNEL_DYNAMIC makes discovery hand back a jwks_uri on
# this same host, so the fetch stays on the compose network.
KEYCLOAK_INTERNAL_URL: http://keycloak:8080
KEYCLOAK_REALM: v2x
KEYCLOAK_AUDIENCE: v2x-api
KEYCLOAK_SWAGGER_CLIENT_ID: v2x-swagger
CORS_ORIGINS: '["http://localhost:3000","http://localhost:8000"]'
depends_on:
# Migrations need a live database, so wait for MySQL properly.
mysql:
condition: service_healthy
# Keycloak is only contacted lazily, on the first token validation. Not
# blocking on its health keeps a slow or failed realm import from
# preventing the devcontainer from opening at all.
keycloak:
condition: service_started
volumes:
venv: