Skip to content

Open-source status page, incident response and uptime monitoring

build: improve biuld (#2296)

Thibault Le Ouay59c35ef85607
diff --git a/.github/workflows/restart-workflows.yml b/.github/workflows/restart-workflows.yml
new file mode 100644
index 000000000..02f64b445
--- /dev/null
+++ b/.github/workflows/restart-workflows.yml
@@ -0,0 +1,33 @@
+name: Restart Workflows Machines
+
+# Periodic rolling restart to cap the native libsql embedded-replica memory growth
+# (see apps/workflows/research.md). Restarts machines one at a time so the app stays up.
+on:
+ schedule:
+ - cron: "0 */12 * * *"
+ workflow_dispatch: {}
+
+concurrency:
+ group: restart-workflows
+ cancel-in-progress: false
+
+jobs:
+ restart:
+ name: Rolling restart
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ steps:
+ - uses: superfly/flyctl-actions/setup-flyctl@master
+ - name: Restart machines one at a time
+ env:
+ FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
+ FLY_APP: openstatus-workflows
+ run: |
+ set -euo pipefail
+ ids=$(flyctl machines list -a "$FLY_APP" --json | jq -r '.[].id')
+ for id in $ids; do
+ echo "Restarting machine $id"
+ flyctl machine restart "$id" -a "$FLY_APP"
+ # Let the machine pass its health check before touching the next one.
+ sleep 45
+ done
diff --git a/apps/server/.dockerignore b/apps/server/.dockerignore
index c8236a8b4..36b713083 100644
--- a/apps/server/.dockerignore
+++ b/apps/server/.dockerignore
@@ -1,4 +1,4 @@
-# This file is generated by Dofigen v2.7.0
+# This file is generated by Dofigen v2.8.0
# See https://github.com/lenra-io/dofigen
node_modules
diff --git a/apps/server/Dockerfile b/apps/server/Dockerfile
index bb3d41d99..f4c19c32f 100644
--- a/apps/server/Dockerfile
+++ b/apps/server/Dockerfile
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.19.0
-# This file is generated by Dofigen v2.7.0
+# This file is generated by Dofigen v2.8.0
# See https://github.com/lenra-io/dofigen
# install
@@ -52,10 +52,10 @@ pnpm install --prod --frozen-lockfile --verbose
EOF
# build
-FROM oven/bun@sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a AS build
+FROM oven/bun@sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7 AS build
LABEL \
- org.opencontainers.image.base.digest="sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a" \
- org.opencontainers.image.base.name="docker.io/oven/bun:1.3.6" \
+ org.opencontainers.image.base.digest="sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7" \
+ org.opencontainers.image.base.name="docker.io/oven/bun:1.3.11" \
org.opencontainers.image.stage="build"
ENV NODE_ENV="production"
WORKDIR /app/apps/server
@@ -79,7 +79,7 @@ RUN bun build --compile --sourcemap src/index.ts --outfile=app
# runtime
FROM debian@sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604 AS runtime
LABEL \
- io.dofigen.version="2.7.0" \
+ io.dofigen.version="2.8.0" \
org.opencontainers.image.authors="OpenStatus Team" \
org.opencontainers.image.base.digest="sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604" \
org.opencontainers.image.base.name="docker.io/debian:bullseye-slim" \
diff --git a/apps/server/dofigen.lock b/apps/server/dofigen.lock
index d9ad0a9f9..b2a4213e3 100644
--- a/apps/server/dofigen.lock
+++ b/apps/server/dofigen.lock
@@ -10,14 +10,43 @@ effective: |
- /packages/api
- /packages/integrations/vercel
builders:
+ build:
+ fromImage:
+ path: oven/bun
+ digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
+ label:
+ org.opencontainers.image.stage: build
+ org.opencontainers.image.base.name: docker.io/oven/bun:1.3.11
+ org.opencontainers.image.base.digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
+ workdir: /app/apps/server
+ env:
+ NODE_ENV: production
+ copy:
+ - paths:
+ - .
+ target: /app/
+ - fromBuilder: install
+ paths:
+ - /app/node_modules
+ target: /app/node_modules
+ - fromBuilder: install
+ paths:
+ - /app/apps/server/node_modules
+ target: /app/apps/server/node_modules
+ - fromBuilder: install
+ paths:
+ - /app/packages
+ target: /app/packages
+ run:
+ - bun build --compile --sourcemap src/index.ts --outfile=app
install:
fromImage:
path: node
digest: sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf
label:
- org.opencontainers.image.stage: install
- org.opencontainers.image.base.digest: sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf
org.opencontainers.image.base.name: docker.io/node:24-slim
+ org.opencontainers.image.base.digest: sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf
+ org.opencontainers.image.stage: install
workdir: /app/
run:
- corepack enable pnpm
@@ -95,46 +124,17 @@ effective: |
source: packages/services/package.json
- target: packages/importers/package.json
source: packages/importers/package.json
- build:
- fromImage:
- path: oven/bun
- digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a
- label:
- org.opencontainers.image.base.name: docker.io/oven/bun:1.3.6
- org.opencontainers.image.base.digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a
- org.opencontainers.image.stage: build
- workdir: /app/apps/server
- env:
- NODE_ENV: production
- copy:
- - paths:
- - .
- target: /app/
- - fromBuilder: install
- paths:
- - /app/node_modules
- target: /app/node_modules
- - fromBuilder: install
- paths:
- - /app/apps/server/node_modules
- target: /app/apps/server/node_modules
- - fromBuilder: install
- paths:
- - /app/packages
- target: /app/packages
- run:
- - bun build --compile --sourcemap src/index.ts --outfile=app
fromImage:
path: debian
digest: sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604
label:
- org.opencontainers.image.title: OpenStatus Server
+ io.dofigen.version: 2.8.0
org.opencontainers.image.authors: OpenStatus Team
org.opencontainers.image.source: https://github.com/openstatusHQ/openstatus
+ org.opencontainers.image.title: OpenStatus Server
+ org.opencontainers.image.base.digest: sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604
org.opencontainers.image.vendor: OpenStatus
org.opencontainers.image.description: REST API server with Hono framework for OpenStatus
- org.opencontainers.image.base.digest: sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604
- io.dofigen.version: 2.7.0
org.opencontainers.image.base.name: docker.io/debian:bullseye-slim
user:
user: '1000'
@@ -162,20 +162,20 @@ effective: |
retries: 3
images:
docker.io:
+ oven:
+ bun:
+ 1.3.11:
+ digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
library:
- debian:
- bullseye-slim:
- digest: sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604
node:
24-slim:
digest: sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf
- oven:
- bun:
- 1.3.6:
- digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a
+ debian:
+ bullseye-slim:
+ digest: sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604
resources:
dofigen.yml:
- hash: 4cc23ad9bfc0f05d70c6249323f4baaad4fc11aa5cd7f61660abba8221aa6755
+ hash: 4ad3de79c65a09ba1ba428b29a15ab9131c66e271eb7c4376b4fdcc825ebd770
content: |
# Files to exclude from Docker context
ignore:
@@ -240,7 +240,7 @@ resources:
# Stage 2: Build application (compile to binary)
build:
- fromImage: oven/bun:1.3.6
+ fromImage: oven/bun:1.3.11
workdir: /app/apps/server
labels:
org.opencontainers.image.stage: build
diff --git a/apps/server/dofigen.yml b/apps/server/dofigen.yml
index d48bcded7..bdb9641f6 100644
--- a/apps/server/dofigen.yml
+++ b/apps/server/dofigen.yml
@@ -61,7 +61,7 @@ builders:
# Stage 2: Build application (compile to binary)
build:
- fromImage: oven/bun:1.3.6
+ fromImage: oven/bun:1.3.11
workdir: /app/apps/server
labels:
org.opencontainers.image.stage: build
diff --git a/apps/workflows/.dockerignore b/apps/workflows/.dockerignore
index d5d76ff57..6ae672226 100644
--- a/apps/workflows/.dockerignore
+++ b/apps/workflows/.dockerignore
@@ -1,4 +1,4 @@
-# This file is generated by Dofigen v2.7.0
+# This file is generated by Dofigen v2.8.0
# See https://github.com/lenra-io/dofigen
node_modules
diff --git a/apps/workflows/Dockerfile b/apps/workflows/Dockerfile
index ec6ee2efd..42ee8271f 100644
--- a/apps/workflows/Dockerfile
+++ b/apps/workflows/Dockerfile
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.19.0
-# This file is generated by Dofigen v2.7.0
+# This file is generated by Dofigen v2.8.0
# See https://github.com/lenra-io/dofigen
# docker
@@ -85,25 +85,21 @@ COPY \
RUN bun build --compile --target bun --sourcemap src/index.ts --outfile=app
# libsql
-FROM node@sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf AS libsql
+FROM oven/bun@sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7 AS libsql
LABEL \
- org.opencontainers.image.base.digest="sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf" \
- org.opencontainers.image.base.name="docker.io/node:24-slim"
+ org.opencontainers.image.base.digest="sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7" \
+ org.opencontainers.image.base.name="docker.io/oven/bun:1.3.11"
WORKDIR /app/
COPY \
--from=docker \
--link \
"/app/apps/build-docker/package.json" "/app/package.json"
-RUN <<EOF
-corepack enable pnpm
-pnpm install --prod --lockfile-only
-pnpm install --prod --frozen-lockfile --config.node-linker=hoisted
-EOF
+RUN bun install --production
# runtime
FROM debian@sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604 AS runtime
LABEL \
- io.dofigen.version="2.7.0" \
+ io.dofigen.version="2.8.0" \
org.opencontainers.image.authors="OpenStatus Team" \
org.opencontainers.image.base.digest="sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604" \
org.opencontainers.image.base.name="docker.io/debian:bullseye-slim" \
diff --git a/apps/workflows/dofigen.lock b/apps/workflows/dofigen.lock
index f8180e800..cb7e8ab90 100644
--- a/apps/workflows/dofigen.lock
+++ b/apps/workflows/dofigen.lock
@@ -17,8 +17,8 @@ effective: |
path: oven/bun
digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
label:
- org.opencontainers.image.base.name: docker.io/oven/bun:1.3.11
org.opencontainers.image.base.digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
+ org.opencontainers.image.base.name: docker.io/oven/bun:1.3.11
workdir: /app/apps/workflows
copy:
- paths:
@@ -31,9 +31,9 @@ effective: |
path: node
digest: sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf
label:
- org.opencontainers.image.base.digest: sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf
- org.opencontainers.image.base.name: docker.io/node:24-slim
org.opencontainers.image.stage: install
+ org.opencontainers.image.base.name: docker.io/node:24-slim
+ org.opencontainers.image.base.digest: sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf
workdir: /app/
run:
- corepack enable pnpm
@@ -107,11 +107,11 @@ effective: |
source: packages/status-fetcher/package.json
libsql:
fromImage:
- path: node
- digest: sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf
+ path: oven/bun
+ digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
label:
- org.opencontainers.image.base.digest: sha256:242549cd46785b480c832479a730f4f2a20865d61ea2e404fdb2a5c3d3b73ecf
- org.opencontainers.image.base.name: docker.io/node:24-slim
+ org.opencontainers.image.base.name: docker.io/oven/bun:1.3.11
+ org.opencontainers.image.base.digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
workdir: /app/
copy:
- fromBuilder: docker
@@ -119,17 +119,15 @@ effective: |
- /app/apps/build-docker/package.json
target: /app/package.json
run:
- - corepack enable pnpm
- - pnpm install --prod --lockfile-only
- - pnpm install --prod --frozen-lockfile --config.node-linker=hoisted
+ - bun install --production
build:
fromImage:
path: oven/bun
digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
label:
org.opencontainers.image.base.name: docker.io/oven/bun:1.3.11
- org.opencontainers.image.base.digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
org.opencontainers.image.stage: build
+ org.opencontainers.image.base.digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
workdir: /app/apps/workflows
env:
NODE_ENV: production
@@ -155,14 +153,14 @@ effective: |
path: debian
digest: sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604
label:
- org.opencontainers.image.source: https://github.com/openstatusHQ/openstatus
- io.dofigen.version: 2.7.0
+ org.opencontainers.image.description: Background job processing and probe scheduling for OpenStatus
+ org.opencontainers.image.authors: OpenStatus Team
org.opencontainers.image.base.digest: sha256:cd1bc32f233a49f1b82149c9edb8ef34fb1e6c45f37211445c51a97603468604
+ org.opencontainers.image.title: OpenStatus Workflows
+ org.opencontainers.image.source: https://github.com/openstatusHQ/openstatus
org.opencontainers.image.base.name: docker.io/debian:bullseye-slim
- org.opencontainers.image.authors: OpenStatus Team
+ io.dofigen.version: 2.8.0
org.opencontainers.image.vendor: OpenStatus
- org.opencontainers.image.title: OpenStatus Workflows
- org.opencontainers.image.description: Background job processing and probe scheduling for OpenStatus
workdir: /app/
copy:
- fromBuilder: build
@@ -200,7 +198,7 @@ images:
digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
resources:
dofigen.yml:
- hash: 84357196743d6620d9e8adb7b2a0a599060e730c7f5a4f55f29e9306c023528a
+ hash: 9ad08ee36ff20abe093e58fc36235d056b6ed3e22b8ae2f3fb30399e34cdaebe
content: |
ignore:
- node_modules
@@ -292,18 +290,16 @@ resources:
run: bun run src/build-docker.ts
libsql:
- fromImage: node:24-slim
+ fromImage: oven/bun:1.3.11
workdir: /app/
copy:
- fromBuilder: docker
source: /app/apps/build-docker/package.json
target: /app/package.json
- run:
- - corepack enable pnpm
- - pnpm install --prod --lockfile-only
- # node-linker=hoisted gives a flat node_modules (like npm/bun) so the compiled bun
- # binary can resolve the libsql native addon (@libsql/<platform>) from disk at runtime.
- - pnpm install --prod --frozen-lockfile --config.node-linker=hoisted
+ # bun install is hoisted by default -> flat node_modules so the compiled bun binary can
+ # resolve the libsql native addon (@libsql/<platform>) from disk at runtime. No lockfile
+ # is needed (the generated package.json pins one exact version), so a single install does it.
+ run: bun install --production
fromImage: debian:bullseye-slim
workdir: /app/
diff --git a/apps/workflows/dofigen.yml b/apps/workflows/dofigen.yml
index 2d8a81b00..89c086ddd 100644
--- a/apps/workflows/dofigen.yml
+++ b/apps/workflows/dofigen.yml
@@ -88,18 +88,16 @@ builders:
run: bun run src/build-docker.ts
libsql:
- fromImage: node:24-slim
+ fromImage: oven/bun:1.3.11
workdir: /app/
copy:
- fromBuilder: docker
source: /app/apps/build-docker/package.json
target: /app/package.json
- run:
- - corepack enable pnpm
- - pnpm install --prod --lockfile-only
- # node-linker=hoisted gives a flat node_modules (like npm/bun) so the compiled bun
- # binary can resolve the libsql native addon (@libsql/<platform>) from disk at runtime.
- - pnpm install --prod --frozen-lockfile --config.node-linker=hoisted
+ # bun install is hoisted by default -> flat node_modules so the compiled bun binary can
+ # resolve the libsql native addon (@libsql/<platform>) from disk at runtime. No lockfile
+ # is needed (the generated package.json pins one exact version), so a single install does it.
+ run: bun install --production
fromImage: debian:bullseye-slim
workdir: /app/
diff --git a/apps/workflows/src/incident/index.ts b/apps/workflows/src/incident/index.ts
index fe2f0a711..770d9fb02 100644
--- a/apps/workflows/src/incident/index.ts
+++ b/apps/workflows/src/incident/index.ts
@@ -1,9 +1,8 @@
-import { schema } from "@openstatus/db";
+import { db, schema } from "@openstatus/db";
import { and, eq, inArray, isNull, ne } from "drizzle-orm";
import { Hono } from "hono";
import { env } from "../env";
-import { db } from "../lib/db";
export const incidentRoute = new Hono({ strict: false });