Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
**/node_modules
dist
**/dist
.build
web/dist
web/node_modules
.git
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ updates:
interval: "weekly"
cooldown:
default-days: 7
- package-ecosystem: "vcpkg"
directory: "/native/fit-decoder"
schedule:
interval: "weekly"
cooldown:
default-days: 7
- package-ecosystem: "docker-compose"
directory: "/"
schedule:
Expand Down
58 changes: 56 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,47 @@ jobs:
name: coverage-unit
path: coverage/

test-fit-decoder:
name: Native FIT Decoder
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
${{ runner.temp }}/vcpkg/downloads
~/.cache/vcpkg/archives
key: vcpkg-fit-${{ hashFiles('native/fit-decoder/vcpkg.json', 'native/fit-decoder/vcpkg-configuration.json', 'native/fit-decoder/vcpkg-ports/**') }}
- name: Bootstrap vcpkg
env:
VCPKG_DOWNLOADS: ${{ runner.temp }}/vcpkg/downloads
VCPKG_ROOT: ${{ runner.temp }}/vcpkg/repo
run: |
git clone https://github.com/microsoft/vcpkg.git "$VCPKG_ROOT"
git -C "$VCPKG_ROOT" checkout ec62869cdd9f80413abb5e4c1d8b68688df932f4
"$VCPKG_ROOT/bootstrap-vcpkg.sh" -disableMetrics
- name: Build and test FIT decoder
working-directory: native/fit-decoder
env:
VCPKG_DOWNLOADS: ${{ runner.temp }}/vcpkg/downloads
VCPKG_ROOT: ${{ runner.temp }}/vcpkg/repo
run: |
cmake --preset release
cmake --build --preset release
ctest --preset release
- name: Upload FIT decoder binary
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fit-decoder-linux
path: .build/fit-decoder/bin/dofek-fit-decoder

test-integration:
name: Integration Tests (${{ matrix.shard }}/4)
needs: test-fit-decoder
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
Expand Down Expand Up @@ -613,6 +652,13 @@ jobs:
with:
persist-credentials: false
- uses: ./.github/actions/setup-node-pnpm
- name: Download FIT decoder binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: fit-decoder-linux
path: .build/fit-decoder/bin
- name: Make FIT decoder executable
run: chmod +x .build/fit-decoder/bin/dofek-fit-decoder
- run: pnpm exec vitest run --project integration --coverage --shard=${{ matrix.shard }}/4
timeout-minutes: 12
env:
Expand Down Expand Up @@ -683,14 +729,15 @@ jobs:

test-gate:
name: Unit & Integration Tests
needs: [test-unit, test-integration, coverage]
needs: [test-unit, test-fit-decoder, test-integration, coverage]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check results
run: |
for result in \
"${{ needs.test-unit.result }}" \
"${{ needs.test-fit-decoder.result }}" \
"${{ needs.test-integration.result }}" \
"${{ needs.coverage.result }}"; do
if [ "$result" = "failure" ] || [ "$result" = "cancelled" ]; then
Expand Down Expand Up @@ -986,7 +1033,7 @@ jobs:

mutation:
name: Stryker (${{ strategy.job-index }})
needs: mutation-prep
needs: [mutation-prep, test-fit-decoder]
if: needs.mutation-prep.outputs.shards != '[]'
runs-on: ubuntu-latest
timeout-minutes: 75
Expand Down Expand Up @@ -1044,6 +1091,13 @@ jobs:
persist-credentials: false
fetch-depth: 0
- uses: ./.github/actions/setup-node-pnpm
- name: Download FIT decoder binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: fit-decoder-linux
path: .build/fit-decoder/bin
- name: Make FIT decoder executable
run: chmod +x .build/fit-decoder/bin/dofek-fit-decoder
- name: Run Stryker
env:
MUTATE_FILES: ${{ matrix.files }}
Expand Down
33 changes: 31 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,35 @@ RUN apk add --no-cache build-base && \
sqlfluff==4.2.2 \
sqlfluff-templater-dbt==4.2.2

# ── Native FIT decoder: CMake + vcpkg ────────────────────────────────
FROM alpine:3.24 AS fit-decoder-build
ENV VCPKG_ROOT=/opt/vcpkg
ENV VCPKG_FORCE_SYSTEM_BINARIES=1
ARG VCPKG_COMMIT=ec62869cdd9f80413abb5e4c1d8b68688df932f4
RUN apk add --no-cache \
bash \
build-base \
cmake \
curl \
git \
linux-headers \
ninja \
pkgconfig \
tar \
unzip \
zip && \
git clone https://github.com/microsoft/vcpkg.git "$VCPKG_ROOT" && \
git -C "$VCPKG_ROOT" checkout "$VCPKG_COMMIT" && \
"$VCPKG_ROOT/bootstrap-vcpkg.sh" -disableMetrics
WORKDIR /src/native/fit-decoder
COPY native/fit-decoder ./
COPY src/fit/fixtures/test.fit /src/src/fit/fixtures/test.fit
RUN --mount=type=cache,id=vcpkg-downloads,target=/opt/vcpkg/downloads \
--mount=type=cache,id=vcpkg-archives,target=/root/.cache/vcpkg/archives \
cmake --preset release && \
cmake --build --preset release && \
ctest --preset release

# ── Source stage: just copy files, no install ─────────────────────────
FROM base AS source
WORKDIR /app
Expand Down Expand Up @@ -80,7 +109,7 @@ ENV NODE_ENV=production
WORKDIR /app

# Docker CLI for worker container management (startWorker)
RUN apk add --no-cache curl ca-certificates libbz2 && \
RUN apk add --no-cache curl ca-certificates libbz2 libstdc++ && \
ARCH=$(uname -m) && \
curl -fsSL "https://download.docker.com/linux/static/stable/${ARCH}/docker-29.5.3.tgz" | \
tar xz --strip-components=1 -C /usr/local/bin docker/docker && \
Expand All @@ -90,7 +119,7 @@ COPY --from=dbt-tools /usr/local/bin/dbt /usr/local/bin/dbt
COPY --from=dbt-tools /usr/local/bin/sqlfluff /usr/local/bin/sqlfluff
COPY --from=dbt-tools /usr/local/lib/python3.13 /usr/local/lib/python3.13
COPY --from=dbt-tools /usr/local/lib/libpython3.13.so* /usr/local/lib/

COPY --from=fit-decoder-build /src/.build/fit-decoder/bin/dofek-fit-decoder /usr/local/bin/

COPY --from=source --chown=node:node /app/src ./src
COPY --from=source --chown=node:node /app/analytics ./analytics
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ dofek/
│ ├── velohero-client/ # RE'd VeloHero API client
│ ├── garmin-connect/ # RE'd Garmin Connect SSO + API client
│ └── trainingpeaks-connect/ # RE'd TrainingPeaks internal API client
├── native/fit-decoder/ # C++ Garmin FIT streaming decoder (CMake + vcpkg)
├── cypress/ # E2E tests (Cypress)
├── drizzle/ # SQL migrations (0000_baseline.sql + forward migrations)
│ └── _views/ # Canonical materialized view definitions
Expand Down Expand Up @@ -225,16 +226,17 @@ A single image is built from a multi-stage Dockerfile:

```text
Dockerfile (multi-stage)
├── fit-decoder-build — CMake/vcpkg build and CTest for the Garmin FIT decoder
├── workspace-manifests — lockfile and workspace package manifests only
├── workspace-deps — full pnpm install for Vite build tooling
├── server-deps — production pnpm install filtered to dofek-server
├── client-build — full source + Vite build
└── server target — Node 26 runtime with TypeScript sources + built web assets + entrypoint
└── server target — Node 26 runtime with native decoder, TypeScript sources, web assets, and entrypoint
```

Dependency layers are intentionally source-independent: `workspace-manifests` copies only package manifests, the lockfile, and patches, then `workspace-deps` and `server-deps` install from that stable input set. `server-deps` uses `pnpm install --prod --frozen-lockfile --filter dofek-server...` rather than `pnpm deploy`, keeping the image on pnpm's regular install path and avoiding `deploy --legacy`. See pnpm's docs for filtered installs and deploy behavior: https://pnpm.io/filtering, https://pnpm.io/cli/install, https://pnpm.io/cli/deploy.

The server image copies the workspace source tree plus production dependencies from `server-deps`, then creates explicit symlinks for workspace packages so bare imports resolve at runtime. Built web assets from `packages/web/dist` are included in the server image — Express serves them directly with SPA fallback. BuildKit cache mounts keep the pnpm store warm across builds, and CI exports E2E/server build caches to GitHub Actions cache plus GHCR registry cache for reuse across PRs. See Docker's cache backend docs: https://docs.docker.com/build/cache/backends/gha/, https://docs.docker.com/build/cache/backends/registry/. Production runs TypeScript directly on Node 26; there is no separate server transpile step inside the container.
The `fit-decoder-build` stage builds and tests the C++ decoder with Garmin's official [FIT C++ SDK](https://github.com/garmin/fit-cpp-sdk), [CMake presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html), and [vcpkg manifest mode](https://learn.microsoft.com/vcpkg/concepts/manifest-mode). The server image copies only the resulting executable into the runtime. It then copies the workspace source tree plus production dependencies from `server-deps` and creates explicit symlinks for workspace packages so bare imports resolve at runtime. Built web assets from `packages/web/dist` are included in the server image — Express serves them directly with SPA fallback. BuildKit cache mounts keep the pnpm and vcpkg caches warm across builds, and CI exports E2E/server build caches to GitHub Actions cache plus GHCR registry cache for reuse across PRs. See Docker's cache backend docs: https://docs.docker.com/build/cache/backends/gha/, https://docs.docker.com/build/cache/backends/registry/. Production runs TypeScript directly on Node 26; there is no separate server transpile step inside the container.

### Building locally

Expand Down
Loading
Loading