diff --git a/apps/server/.dockerignore b/apps/server/.dockerignore new file mode 100644 index 0000000000..15fdd66022 --- /dev/null +++ b/apps/server/.dockerignore @@ -0,0 +1,9 @@ +# This file is generated by Dofigen v2.0.0 +# See https://github.com/lenra-io/dofigen + +node_modules +/apps/docs +/apps/screenshot-service +/apps/web +/packages/api +/packages/integrations/vercel diff --git a/apps/server/Dockerfile b/apps/server/Dockerfile index b2d9583e87..a53975f89f 100644 --- a/apps/server/Dockerfile +++ b/apps/server/Dockerfile @@ -1,22 +1,51 @@ -FROM oven/bun +# syntax=docker/dockerfile:1.7 +# This file is generated by Dofigen v2.0.0 +# See https://github.com/lenra-io/dofigen -WORKDIR /app +# install +FROM oven/bun@sha256:eb409bed239c3adff079a6b71283f151e802d66b99f643ba7a71e1be7d3da513 AS install +WORKDIR /app/ +RUN \ + --mount=type=bind,target=package.json,source=package.json \ + --mount=type=bind,target=apps/server/package.json,source=apps/server/package.json \ + --mount=type=bind,target=packages/analytics/package.json,source=packages/analytics/package.json \ + --mount=type=bind,target=packages/db/package.json,source=packages/db/package.json \ + --mount=type=bind,target=packages/emails/package.json,source=packages/emails/package.json \ + --mount=type=bind,target=packages/error/package.json,source=packages/error/package.json \ + --mount=type=bind,target=packages/notifications/discord/package.json,source=packages/notifications/discord/package.json \ + --mount=type=bind,target=packages/notifications/email/package.json,source=packages/notifications/email/package.json \ + --mount=type=bind,target=packages/notifications/pagerduty/package.json,source=packages/notifications/pagerduty/package.json \ + --mount=type=bind,target=packages/notifications/slack/package.json,source=packages/notifications/slack/package.json \ + --mount=type=bind,target=packages/notifications/twillio-sms/package.json,source=packages/notifications/twillio-sms/package.json \ + --mount=type=bind,target=packages/tinybird/package.json,source=packages/tinybird/package.json \ + --mount=type=bind,target=packages/tracker/package.json,source=packages/tracker/package.json \ + --mount=type=bind,target=packages/upstash/package.json,source=packages/upstash/package.json \ + --mount=type=bind,target=packages/utils/package.json,source=packages/utils/package.json \ + --mount=type=bind,target=packages/tsconfig/package.json,source=packages/tsconfig/package.json \ + --mount=type=bind,target=packages/assertions/package.json,source=packages/assertions/package.json \ + --mount=type=cache,target=/root/.bun/install/cache,sharing=locked \ + bun install --production --ignore-scripts --frozen-lockfile --verbose -# Copy project -COPY . . - -# To keep the image small ;) -RUN rm -rf /app/apps/docs -RUN rm -rf /app/apps/screenshot-service -RUN rm -rf /app/apps/web -RUN rm -rf /app/packages/api -RUN rm -rf /app/packages/integrations/vercel -# Temp solution for bun -RUN bun install --ignore-scripts +# build +FROM oven/bun@sha256:eb409bed239c3adff079a6b71283f151e802d66b99f643ba7a71e1be7d3da513 AS build WORKDIR /app/apps/server - -# Compile the TypeScript application +COPY \ + --link \ + "." "/app/" +COPY \ + --from=install \ + --link \ + "/app/node_modules" "/app/node_modules" RUN bun build --compile --sourcemap src/index.ts --outfile=app +# runtime +FROM debian@sha256:00558f781b91e90469812bad32002f311ab26ef241b4a1996f6600680ec82f5c AS runtime +COPY \ + --from=build \ + --chown=1000:1000 \ + --chmod=555 \ + --link \ + "/app/apps/server/app" "/bin/" +USER 1000:1000 EXPOSE 3000 -CMD ["./app"] +ENTRYPOINT ["/bin/app"] diff --git a/apps/server/README.md b/apps/server/README.md index 2139079dd0..34197e3fea 100644 --- a/apps/server/README.md +++ b/apps/server/README.md @@ -15,6 +15,15 @@ flyctl deploy --config apps/server/fly.toml --dockerfile apps/server/Dockerfile ## Docker +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: + +```bash +# Update the dependent image versions +dofigen update +# Generate the Dockerfile +dofigen gen +``` + Build the docker image locally ```bash diff --git a/apps/server/dofigen.lock b/apps/server/dofigen.lock new file mode 100644 index 0000000000..c908a97059 --- /dev/null +++ b/apps/server/dofigen.lock @@ -0,0 +1,95 @@ +effective: | + ignore: + - node_modules + - /apps/docs + - /apps/screenshot-service + - /apps/web + - /packages/api + - /packages/integrations/vercel + builders: + build: + fromImage: + path: oven/bun + digest: sha256:eb409bed239c3adff079a6b71283f151e802d66b99f643ba7a71e1be7d3da513 + workdir: /app/apps/server + copy: + - paths: + - . + target: /app/ + - fromBuilder: install + paths: + - /app/node_modules + target: /app/node_modules + run: + - bun build --compile --sourcemap src/index.ts --outfile=app + install: + fromImage: + path: oven/bun + digest: sha256:eb409bed239c3adff079a6b71283f151e802d66b99f643ba7a71e1be7d3da513 + workdir: /app/ + run: + - bun install --production --ignore-scripts --frozen-lockfile --verbose + cache: + - target: /root/.bun/install/cache + bind: + - target: package.json + source: package.json + - target: apps/server/package.json + source: apps/server/package.json + - target: packages/analytics/package.json + source: packages/analytics/package.json + - target: packages/db/package.json + source: packages/db/package.json + - target: packages/emails/package.json + source: packages/emails/package.json + - target: packages/error/package.json + source: packages/error/package.json + - target: packages/notifications/discord/package.json + source: packages/notifications/discord/package.json + - target: packages/notifications/email/package.json + source: packages/notifications/email/package.json + - target: packages/notifications/pagerduty/package.json + source: packages/notifications/pagerduty/package.json + - target: packages/notifications/slack/package.json + source: packages/notifications/slack/package.json + - target: packages/notifications/twillio-sms/package.json + source: packages/notifications/twillio-sms/package.json + - target: packages/tinybird/package.json + source: packages/tinybird/package.json + - target: packages/tracker/package.json + source: packages/tracker/package.json + - target: packages/upstash/package.json + source: packages/upstash/package.json + - target: packages/utils/package.json + source: packages/utils/package.json + - target: packages/tsconfig/package.json + source: packages/tsconfig/package.json + - target: packages/assertions/package.json + source: packages/assertions/package.json + fromImage: + path: debian + digest: sha256:00558f781b91e90469812bad32002f311ab26ef241b4a1996f6600680ec82f5c + copy: + - fromBuilder: build + paths: + - /app/apps/server/app + target: /bin/ + chmod: '555' + entrypoint: + - /bin/app + expose: + - port: 3000 +images: + registry.hub.docker.com:443: + oven: + bun: + latest: + digest: sha256:eb409bed239c3adff079a6b71283f151e802d66b99f643ba7a71e1be7d3da513 + library: + debian: + bullseye-slim: + digest: sha256:00558f781b91e90469812bad32002f311ab26ef241b4a1996f6600680ec82f5c +resources: + dofigen.yml: + hash: adf3f9674023b48f97b9d48996067d36db5da23a2ee73685c1d85079e1328320 + 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" diff --git a/apps/server/dofigen.yml b/apps/server/dofigen.yml new file mode 100644 index 0000000000..4907a31ecd --- /dev/null +++ b/apps/server/dofigen.yml @@ -0,0 +1,52 @@ +ignore: + - node_modules + - /apps/docs + - /apps/screenshot-service + - /apps/web + - /packages/api + - /packages/integrations/vercel +builders: + install: + fromImage: oven/bun + workdir: /app/ + # Copy project + bind: + - package.json + - apps/server/package.json + - packages/analytics/package.json + - packages/db/package.json + - packages/emails/package.json + - packages/error/package.json + - packages/notifications/discord/package.json + - packages/notifications/email/package.json + - packages/notifications/pagerduty/package.json + - packages/notifications/slack/package.json + - packages/notifications/twillio-sms/package.json + - packages/tinybird/package.json + - packages/tracker/package.json + - packages/upstash/package.json + - packages/utils/package.json + - packages/tsconfig/package.json + - packages/assertions/package.json + # Install dependencies + run: bun install --production --ignore-scripts --frozen-lockfile --verbose + cache: + - /root/.bun/install/cache + build: + fromImage: oven/bun + workdir: /app/apps/server + copy: + - . /app/ + - fromBuilder: install + source: /app/node_modules + target: /app/node_modules + # Compile the TypeScript application + run: bun build --compile --sourcemap src/index.ts --outfile=app +fromImage: debian:bullseye-slim +copy: + - fromBuilder: build + source: /app/apps/server/app + target: /bin/ + chmod: "555" +expose: 3000 +entrypoint: /bin/app diff --git a/packages/assertions/package.json b/packages/assertions/package.json index b91c9b2f98..3e63ce58c5 100644 --- a/packages/assertions/package.json +++ b/packages/assertions/package.json @@ -4,10 +4,11 @@ "description": "", "main": "src/index.ts", "scripts": {}, - "dependencies": {}, + "dependencies": { + "jsonpath-plus": "7.2.0" + }, "devDependencies": { "@openstatus/tsconfig": "workspace:*", - "jsonpath-plus": "7.2.0", "typescript": "5.5.2", "zod": "3.23.8" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c26e464580..61bcec64f7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -530,13 +530,14 @@ importers: version: 5.5.2 packages/assertions: + dependencies: + jsonpath-plus: + specifier: 7.2.0 + version: 7.2.0 devDependencies: '@openstatus/tsconfig': specifier: workspace:* version: link:../tsconfig - jsonpath-plus: - specifier: 7.2.0 - version: 7.2.0 typescript: specifier: 5.5.2 version: 5.5.2 @@ -7261,7 +7262,6 @@ packages: libsql@0.4.5: resolution: {integrity: sha512-sorTJV6PNt94Wap27Sai5gtVLIea4Otb2LUiAUyr3p6BPOScGMKGt5F1b5X/XgkNtcsDKeX5qfeBDj+PdShclQ==} - cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] lie@3.1.1: