Openstatus www.openstatus.dev

build: Manage Dockerfile with Dofigen (#1014)

* build: Manage Dockerfile with Dofigen

* build: Improve bun install cache

* chore pnpm lock file

* docs: Dofigen update

---------

Co-authored-by: Thibault Le Ouay <thibaultleouay@gmail.Com>

authored by

Thomas DA ROCHA
Thibault Le Ouay
and committed by
GitHub
e829fa0a 5f6d2625

+217 -22
+9
apps/server/.dockerignore
··· 1 + # This file is generated by Dofigen v2.0.0 2 + # See https://github.com/lenra-io/dofigen 3 + 4 + node_modules 5 + /apps/docs 6 + /apps/screenshot-service 7 + /apps/web 8 + /packages/api 9 + /packages/integrations/vercel
+45 -16
apps/server/Dockerfile
··· 1 - FROM oven/bun 1 + # syntax=docker/dockerfile:1.7 2 + # This file is generated by Dofigen v2.0.0 3 + # See https://github.com/lenra-io/dofigen 2 4 3 - WORKDIR /app 5 + # install 6 + FROM oven/bun@sha256:eb409bed239c3adff079a6b71283f151e802d66b99f643ba7a71e1be7d3da513 AS install 7 + WORKDIR /app/ 8 + RUN \ 9 + --mount=type=bind,target=package.json,source=package.json \ 10 + --mount=type=bind,target=apps/server/package.json,source=apps/server/package.json \ 11 + --mount=type=bind,target=packages/analytics/package.json,source=packages/analytics/package.json \ 12 + --mount=type=bind,target=packages/db/package.json,source=packages/db/package.json \ 13 + --mount=type=bind,target=packages/emails/package.json,source=packages/emails/package.json \ 14 + --mount=type=bind,target=packages/error/package.json,source=packages/error/package.json \ 15 + --mount=type=bind,target=packages/notifications/discord/package.json,source=packages/notifications/discord/package.json \ 16 + --mount=type=bind,target=packages/notifications/email/package.json,source=packages/notifications/email/package.json \ 17 + --mount=type=bind,target=packages/notifications/pagerduty/package.json,source=packages/notifications/pagerduty/package.json \ 18 + --mount=type=bind,target=packages/notifications/slack/package.json,source=packages/notifications/slack/package.json \ 19 + --mount=type=bind,target=packages/notifications/twillio-sms/package.json,source=packages/notifications/twillio-sms/package.json \ 20 + --mount=type=bind,target=packages/tinybird/package.json,source=packages/tinybird/package.json \ 21 + --mount=type=bind,target=packages/tracker/package.json,source=packages/tracker/package.json \ 22 + --mount=type=bind,target=packages/upstash/package.json,source=packages/upstash/package.json \ 23 + --mount=type=bind,target=packages/utils/package.json,source=packages/utils/package.json \ 24 + --mount=type=bind,target=packages/tsconfig/package.json,source=packages/tsconfig/package.json \ 25 + --mount=type=bind,target=packages/assertions/package.json,source=packages/assertions/package.json \ 26 + --mount=type=cache,target=/root/.bun/install/cache,sharing=locked \ 27 + bun install --production --ignore-scripts --frozen-lockfile --verbose 4 28 5 - # Copy project 6 - COPY . . 7 - 8 - # To keep the image small ;) 9 - RUN rm -rf /app/apps/docs 10 - RUN rm -rf /app/apps/screenshot-service 11 - RUN rm -rf /app/apps/web 12 - RUN rm -rf /app/packages/api 13 - RUN rm -rf /app/packages/integrations/vercel 14 - # Temp solution for bun 15 - RUN bun install --ignore-scripts 29 + # build 30 + FROM oven/bun@sha256:eb409bed239c3adff079a6b71283f151e802d66b99f643ba7a71e1be7d3da513 AS build 16 31 WORKDIR /app/apps/server 17 - 18 - # Compile the TypeScript application 32 + COPY \ 33 + --link \ 34 + "." "/app/" 35 + COPY \ 36 + --from=install \ 37 + --link \ 38 + "/app/node_modules" "/app/node_modules" 19 39 RUN bun build --compile --sourcemap src/index.ts --outfile=app 20 40 41 + # runtime 42 + FROM debian@sha256:00558f781b91e90469812bad32002f311ab26ef241b4a1996f6600680ec82f5c AS runtime 43 + COPY \ 44 + --from=build \ 45 + --chown=1000:1000 \ 46 + --chmod=555 \ 47 + --link \ 48 + "/app/apps/server/app" "/bin/" 49 + USER 1000:1000 21 50 EXPOSE 3000 22 - CMD ["./app"] 51 + ENTRYPOINT ["/bin/app"]
+9
apps/server/README.md
··· 15 15 16 16 ## Docker 17 17 18 + The Dockerfile is generated thanks to [Dofigen](https://github.com/lenra-io/dofigen). To generate the Dockerfile, run the following command from the `apps/server` directory: 19 + 20 + ```bash 21 + # Update the dependent image versions 22 + dofigen update 23 + # Generate the Dockerfile 24 + dofigen gen 25 + ``` 26 + 18 27 Build the docker image locally 19 28 20 29 ```bash
+95
apps/server/dofigen.lock
··· 1 + effective: | 2 + ignore: 3 + - node_modules 4 + - /apps/docs 5 + - /apps/screenshot-service 6 + - /apps/web 7 + - /packages/api 8 + - /packages/integrations/vercel 9 + builders: 10 + build: 11 + fromImage: 12 + path: oven/bun 13 + digest: sha256:eb409bed239c3adff079a6b71283f151e802d66b99f643ba7a71e1be7d3da513 14 + workdir: /app/apps/server 15 + copy: 16 + - paths: 17 + - . 18 + target: /app/ 19 + - fromBuilder: install 20 + paths: 21 + - /app/node_modules 22 + target: /app/node_modules 23 + run: 24 + - bun build --compile --sourcemap src/index.ts --outfile=app 25 + install: 26 + fromImage: 27 + path: oven/bun 28 + digest: sha256:eb409bed239c3adff079a6b71283f151e802d66b99f643ba7a71e1be7d3da513 29 + workdir: /app/ 30 + run: 31 + - bun install --production --ignore-scripts --frozen-lockfile --verbose 32 + cache: 33 + - target: /root/.bun/install/cache 34 + bind: 35 + - target: package.json 36 + source: package.json 37 + - target: apps/server/package.json 38 + source: apps/server/package.json 39 + - target: packages/analytics/package.json 40 + source: packages/analytics/package.json 41 + - target: packages/db/package.json 42 + source: packages/db/package.json 43 + - target: packages/emails/package.json 44 + source: packages/emails/package.json 45 + - target: packages/error/package.json 46 + source: packages/error/package.json 47 + - target: packages/notifications/discord/package.json 48 + source: packages/notifications/discord/package.json 49 + - target: packages/notifications/email/package.json 50 + source: packages/notifications/email/package.json 51 + - target: packages/notifications/pagerduty/package.json 52 + source: packages/notifications/pagerduty/package.json 53 + - target: packages/notifications/slack/package.json 54 + source: packages/notifications/slack/package.json 55 + - target: packages/notifications/twillio-sms/package.json 56 + source: packages/notifications/twillio-sms/package.json 57 + - target: packages/tinybird/package.json 58 + source: packages/tinybird/package.json 59 + - target: packages/tracker/package.json 60 + source: packages/tracker/package.json 61 + - target: packages/upstash/package.json 62 + source: packages/upstash/package.json 63 + - target: packages/utils/package.json 64 + source: packages/utils/package.json 65 + - target: packages/tsconfig/package.json 66 + source: packages/tsconfig/package.json 67 + - target: packages/assertions/package.json 68 + source: packages/assertions/package.json 69 + fromImage: 70 + path: debian 71 + digest: sha256:00558f781b91e90469812bad32002f311ab26ef241b4a1996f6600680ec82f5c 72 + copy: 73 + - fromBuilder: build 74 + paths: 75 + - /app/apps/server/app 76 + target: /bin/ 77 + chmod: '555' 78 + entrypoint: 79 + - /bin/app 80 + expose: 81 + - port: 3000 82 + images: 83 + registry.hub.docker.com:443: 84 + oven: 85 + bun: 86 + latest: 87 + digest: sha256:eb409bed239c3adff079a6b71283f151e802d66b99f643ba7a71e1be7d3da513 88 + library: 89 + debian: 90 + bullseye-slim: 91 + digest: sha256:00558f781b91e90469812bad32002f311ab26ef241b4a1996f6600680ec82f5c 92 + resources: 93 + dofigen.yml: 94 + hash: adf3f9674023b48f97b9d48996067d36db5da23a2ee73685c1d85079e1328320 95 + content: "ignore:\n - node_modules\n - /apps/docs\n - /apps/screenshot-service\n - /apps/web\n - /packages/api\n - /packages/integrations/vercel\nbuilders:\n install:\n fromImage: oven/bun\n workdir: /app/\n # Copy project\n bind:\n - package.json\n - apps/server/package.json\n - packages/analytics/package.json\n - packages/db/package.json\n - packages/emails/package.json\n - packages/error/package.json\n - packages/notifications/discord/package.json\n - packages/notifications/email/package.json\n - packages/notifications/pagerduty/package.json\n - packages/notifications/slack/package.json\n - packages/notifications/twillio-sms/package.json\n - packages/tinybird/package.json\n - packages/tracker/package.json\n - packages/upstash/package.json\n - packages/utils/package.json\n - packages/tsconfig/package.json\n - packages/assertions/package.json\n # Install dependencies\n run: bun install --production --ignore-scripts --frozen-lockfile --verbose\n cache:\n - /root/.bun/install/cache\n build:\n fromImage: oven/bun\n workdir: /app/apps/server\n copy: \n - . /app/\n - fromBuilder: install\n source: /app/node_modules\n target: /app/node_modules\n # Compile the TypeScript application\n run: bun build --compile --sourcemap src/index.ts --outfile=app\nfromImage: debian:bullseye-slim\ncopy:\n - fromBuilder: build\n source: /app/apps/server/app\n target: /bin/\n chmod: \"555\"\nexpose: 3000\nentrypoint: /bin/app\n"
+52
apps/server/dofigen.yml
··· 1 + ignore: 2 + - node_modules 3 + - /apps/docs 4 + - /apps/screenshot-service 5 + - /apps/web 6 + - /packages/api 7 + - /packages/integrations/vercel 8 + builders: 9 + install: 10 + fromImage: oven/bun 11 + workdir: /app/ 12 + # Copy project 13 + bind: 14 + - package.json 15 + - apps/server/package.json 16 + - packages/analytics/package.json 17 + - packages/db/package.json 18 + - packages/emails/package.json 19 + - packages/error/package.json 20 + - packages/notifications/discord/package.json 21 + - packages/notifications/email/package.json 22 + - packages/notifications/pagerduty/package.json 23 + - packages/notifications/slack/package.json 24 + - packages/notifications/twillio-sms/package.json 25 + - packages/tinybird/package.json 26 + - packages/tracker/package.json 27 + - packages/upstash/package.json 28 + - packages/utils/package.json 29 + - packages/tsconfig/package.json 30 + - packages/assertions/package.json 31 + # Install dependencies 32 + run: bun install --production --ignore-scripts --frozen-lockfile --verbose 33 + cache: 34 + - /root/.bun/install/cache 35 + build: 36 + fromImage: oven/bun 37 + workdir: /app/apps/server 38 + copy: 39 + - . /app/ 40 + - fromBuilder: install 41 + source: /app/node_modules 42 + target: /app/node_modules 43 + # Compile the TypeScript application 44 + run: bun build --compile --sourcemap src/index.ts --outfile=app 45 + fromImage: debian:bullseye-slim 46 + copy: 47 + - fromBuilder: build 48 + source: /app/apps/server/app 49 + target: /bin/ 50 + chmod: "555" 51 + expose: 3000 52 + entrypoint: /bin/app
+3 -2
packages/assertions/package.json
··· 4 4 "description": "", 5 5 "main": "src/index.ts", 6 6 "scripts": {}, 7 - "dependencies": {}, 7 + "dependencies": { 8 + "jsonpath-plus": "7.2.0" 9 + }, 8 10 "devDependencies": { 9 11 "@openstatus/tsconfig": "workspace:*", 10 - "jsonpath-plus": "7.2.0", 11 12 "typescript": "5.5.2", 12 13 "zod": "3.23.8" 13 14 },
+4 -4
pnpm-lock.yaml
··· 530 530 version: 5.5.2 531 531 532 532 packages/assertions: 533 + dependencies: 534 + jsonpath-plus: 535 + specifier: 7.2.0 536 + version: 7.2.0 533 537 devDependencies: 534 538 '@openstatus/tsconfig': 535 539 specifier: workspace:* 536 540 version: link:../tsconfig 537 - jsonpath-plus: 538 - specifier: 7.2.0 539 - version: 7.2.0 540 541 typescript: 541 542 specifier: 5.5.2 542 543 version: 5.5.2 ··· 7261 7262 7262 7263 libsql@0.4.5: 7263 7264 resolution: {integrity: sha512-sorTJV6PNt94Wap27Sai5gtVLIea4Otb2LUiAUyr3p6BPOScGMKGt5F1b5X/XgkNtcsDKeX5qfeBDj+PdShclQ==} 7264 - cpu: [x64, arm64, wasm32] 7265 7265 os: [darwin, linux, win32] 7266 7266 7267 7267 lie@3.1.1: