Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

Build deploy service binaries with Nix (#3128)

Sean Ayef95e95207fac
diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml
new file mode 100644
index 0000000000..a8c628b578
--- /dev/null
+++ b/.github/actionlint.yaml
@@ -0,0 +1,3 @@
+self-hosted-runner:
+ labels:
+ - linux-extra-beefy
diff --git a/.github/actions/deploy-cloud-storage-pulumi/action.yml b/.github/actions/deploy-cloud-storage-pulumi/action.yml
index 69315944f0..7b4d72ca2c 100644
--- a/.github/actions/deploy-cloud-storage-pulumi/action.yml
+++ b/.github/actions/deploy-cloud-storage-pulumi/action.yml
@@ -40,6 +40,10 @@ inputs:
description: 'Datadog host'
required: false
default: 'https://api.us5.datadoghq.com/'
+ prebuilt-binaries-artifact:
+ description: 'Optional GitHub artifact containing prebuilt service binaries to copy into Docker images'
+ required: false
+ default: ''
runs:
using: composite
@@ -49,6 +53,21 @@ runs:
with:
lfs: ${{ inputs.use-lfs }}
+ - name: Download prebuilt service binaries
+ if: ${{ inputs.prebuilt-binaries-artifact != '' }}
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
+ with:
+ name: ${{ inputs.prebuilt-binaries-artifact }}
+ path: rust/cloud-storage/prebuilt-artifact
+
+ - name: Extract prebuilt service binaries
+ if: ${{ inputs.prebuilt-binaries-artifact != '' }}
+ shell: bash
+ run: |
+ set -euo pipefail
+ mkdir -p rust/cloud-storage/prebuilt
+ tar -xzf rust/cloud-storage/prebuilt-artifact/prebuilt-binaries.tar.gz -C rust/cloud-storage/prebuilt
+
# setup docker
- uses: docker/setup-buildx-action@v3
if: ${{ inputs.use-docker == 'true' }}
@@ -90,3 +109,4 @@ runs:
DD_APP_KEY: ${{ inputs.dd-app-key }}
DD_API_KEY: ${{ inputs.dd-api-key }}
DD_HOST: ${{ inputs.dd-host }}
+ USE_PREBUILT_SERVICE_BINARIES: ${{ inputs.prebuilt-binaries-artifact != '' && 'true' || 'false' }}
diff --git a/.github/actions/setup-cachix/action.yml b/.github/actions/setup-cachix/action.yml
new file mode 100644
index 0000000000..3f7ced3a98
--- /dev/null
+++ b/.github/actions/setup-cachix/action.yml
@@ -0,0 +1,35 @@
+name: Setup Cachix
+description: Install Cachix if needed and configure the macro-inc binary cache.
+
+inputs:
+ cachix-auth-token:
+ description: Cachix auth token used to configure authenticated pulls and pushes.
+ required: true
+ cache-name:
+ description: Cachix cache name.
+ required: false
+ default: macro-inc
+
+runs:
+ using: composite
+ steps:
+ - name: Configure Cachix
+ shell: bash
+ env:
+ CACHIX_AUTH_TOKEN: ${{ inputs.cachix-auth-token }}
+ CACHIX_CACHE_NAME: ${{ inputs.cache-name }}
+ run: |
+ set -euo pipefail
+ export NIX_REMOTE=daemon
+ export PATH="$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH"
+ echo "$HOME/.nix-profile/bin" >> "$GITHUB_PATH"
+ echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
+ echo "CACHIX_CACHE_NAME=$CACHIX_CACHE_NAME" >> "$GITHUB_ENV"
+
+ if ! command -v cachix >/dev/null 2>&1; then
+ nix profile add nixpkgs#cachix
+ fi
+
+ export PATH="$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH"
+ cachix authtoken "$CACHIX_AUTH_TOKEN"
+ cachix use "$CACHIX_CACHE_NAME"
diff --git a/.github/services-config.json b/.github/services-config.json
index 6f2663c720..e69a173f77 100644
--- a/.github/services-config.json
+++ b/.github/services-config.json
@@ -4,7 +4,10 @@
"source_paths": [
"rust/cloud-storage/scheduled_action/**"
],
- "stack_path": "infra/stacks/agent-schedule-service/**"
+ "stack_path": "infra/stacks/agent-schedule-service/**",
+ "deploy_binaries": [
+ "service"
+ ]
},
"authentication-service": {
"source_paths": [
@@ -12,7 +15,10 @@
"rust/cloud-storage/referral/**",
"rust/cloud-storage/teams/**"
],
- "stack_path": "infra/stacks/authentication-service/**"
+ "stack_path": "infra/stacks/authentication-service/**",
+ "deploy_binaries": [
+ "authentication_service"
+ ]
},
"bulk-upload": {
"source_paths": [
@@ -25,19 +31,28 @@
"source_paths": [
"rust/cloud-storage/connection_gateway/**"
],
- "stack_path": "infra/stacks/connection-gateway/**"
+ "stack_path": "infra/stacks/connection-gateway/**",
+ "deploy_binaries": [
+ "connection_gateway_service"
+ ]
},
"contacts-service": {
"source_paths": [
"rust/cloud-storage/contacts_service/**"
],
- "stack_path": "infra/stacks/contacts-service/**"
+ "stack_path": "infra/stacks/contacts-service/**",
+ "deploy_binaries": [
+ "contacts_service"
+ ]
},
"convert-service": {
"source_paths": [
"rust/cloud-storage/convert_service/**"
],
- "stack_path": "infra/stacks/convert-service/**"
+ "stack_path": "infra/stacks/convert-service/**",
+ "deploy_binaries": [
+ "convert_service"
+ ]
},
"deleted-item-poller": {
"source_paths": [
@@ -49,14 +64,20 @@
"source_paths": [
"rust/cloud-storage/document_cognition_service/**"
],
- "stack_path": "infra/stacks/document-cognition-service/**"
+ "stack_path": "infra/stacks/document-cognition-service/**",
+ "deploy_binaries": [
+ "document_cognition_service"
+ ]
},
"document-storage-service": {
"source_paths": [
"rust/cloud-storage/document_storage_service/**",
"rust/cloud-storage/github/**"
],
- "stack_path": "infra/stacks/cloud-storage-service/**"
+ "stack_path": "infra/stacks/cloud-storage-service/**",
+ "deploy_binaries": [
+ "document_storage_service"
+ ]
},
"document-storage": {
"source_paths": [
@@ -74,13 +95,20 @@
"source_paths": [
"rust/cloud-storage/email_service/**"
],
- "stack_path": "infra/stacks/email-service/**"
+ "stack_path": "infra/stacks/email-service/**",
+ "deploy_binaries": [
+ "email_service",
+ "pubsub_workers"
+ ]
},
"notification-service": {
"source_paths": [
"rust/cloud-storage/notification_service/**"
],
- "stack_path": "infra/stacks/notification-service/**"
+ "stack_path": "infra/stacks/notification-service/**",
+ "deploy_binaries": [
+ "notification_service"
+ ]
},
"organization-retention": {
"source_paths": [
@@ -92,7 +120,10 @@
"source_paths": [
"rust/cloud-storage/search_processing_service/**"
],
- "stack_path": "infra/stacks/search-processing-service/**"
+ "stack_path": "infra/stacks/search-processing-service/**",
+ "deploy_binaries": [
+ "search_processing_service"
+ ]
},
"search-upload": {
"source_paths": [
@@ -110,13 +141,19 @@
"source_paths": [
"rust/cloud-storage/static_file_service/**"
],
- "stack_path": "infra/stacks/static-file-service/**"
+ "stack_path": "infra/stacks/static-file-service/**",
+ "deploy_binaries": [
+ "static_file_service"
+ ]
},
"unfurl-service": {
"source_paths": [
"rust/cloud-storage/unfurl_service/**"
],
- "stack_path": "infra/stacks/unfurl-service/**"
+ "stack_path": "infra/stacks/unfurl-service/**",
+ "deploy_binaries": [
+ "unfurl_service"
+ ]
},
"opensearch": {
"stack_path": "infra/stacks/opensearch/**"
@@ -149,14 +186,20 @@
"source_paths": [
"rust/cloud-storage/image_proxy_service/**"
],
- "stack_path": "infra/stacks/image-proxy-service/**"
+ "stack_path": "infra/stacks/image-proxy-service/**",
+ "deploy_binaries": [
+ "image_proxy_service"
+ ]
},
"mcp-server": {
"source_paths": [
"rust/cloud-storage/mcp_service/**",
"rust/cloud-storage/ai_tools/**"
],
- "stack_path": "infra/stacks/mcp-server/**"
+ "stack_path": "infra/stacks/mcp-server/**",
+ "deploy_binaries": [
+ "mcp_service"
+ ]
}
}
}
diff --git a/.github/workflows/build-rust-ci-image.yml b/.github/workflows/build-rust-ci-image.yml
index 3b63c5cfbf..5eb9d6a0c2 100644
--- a/.github/workflows/build-rust-ci-image.yml
+++ b/.github/workflows/build-rust-ci-image.yml
@@ -40,17 +40,10 @@ jobs:
echo 'PATH="/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"' \
| sudo tee /etc/environment >/dev/null
- - name: Configure cachix substituter
- shell: bash
- env:
- CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: |
- set -euo pipefail
- export NIX_REMOTE=daemon
- export PATH="/nix/var/nix/profiles/default/bin:$PATH"
- nix profile add nixpkgs#cachix
- cachix authtoken "$CACHIX_AUTH_TOKEN"
- cachix use macro-inc
+ - name: Configure Cachix
+ uses: ./.github/actions/setup-cachix
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Materialize dev shell into /nix/store
shell: bash
diff --git a/.github/workflows/deploy-cloud-storage-on-push.yml b/.github/workflows/deploy-cloud-storage-on-push.yml
index ae5ae28a45..e55191f9a9 100644
--- a/.github/workflows/deploy-cloud-storage-on-push.yml
+++ b/.github/workflows/deploy-cloud-storage-on-push.yml
@@ -1,13 +1,38 @@
name: Deploy Cloud Storage Services on Push
on:
+ workflow_dispatch:
+ inputs:
+ service:
+ type: choice
+ required: true
+ default: static-file-service
+ description: Service to deploy to dev for end-to-end testing
+ options:
+ - agent-schedule-service
+ - authentication-service
+ - connection-gateway
+ - contacts-service
+ - convert-service
+ - document-cognition-service
+ - document-storage-service
+ - email-service
+ - image-proxy-service
+ - mcp-server
+ - notification-service
+ - search-processing-service
+ - static-file-service
+ - unfurl-service
push:
branches: [ 'main' ]
paths:
- 'rust/cloud-storage/**'
- 'infra/**'
- '.github/workflows/deploy-cloud-storage-on-push.yml'
+ - '.github/actions/deploy-cloud-storage-pulumi/**'
- '.github/services-config.json'
+ - 'flake.nix'
+ - 'flake.lock'
concurrency:
group: deploy-cloud-storage-${{ github.ref }}
@@ -33,6 +58,14 @@ jobs:
- name: Detect changed services
id: detect
run: |
+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
+ SERVICES=$(jq -cn --arg service "${{ inputs.service }}" '[$service]')
+ echo "services=$SERVICES" >> $GITHUB_OUTPUT
+ echo "has_changes=true" >> $GITHUB_OUTPUT
+ echo "Manually selected service: $SERVICES"
+ exit 0
+ fi
+
# Make the script executable
chmod +x .github/scripts/detect-affected-services.sh
@@ -66,9 +99,66 @@ jobs:
with:
environment: dev
+ build-service-binaries:
+ name: Build ${{ matrix.service }} binaries
+ needs: detect-changes
+ if: ${{ needs.detect-changes.outputs.has_changes == 'true' }}
+ runs-on: linux-extra-beefy
+ strategy:
+ fail-fast: false
+ max-parallel: 8
+ matrix:
+ service: ${{ fromJson(needs.detect-changes.outputs.services) }}
+ steps:
+ - uses: actions/checkout@v6
+ with:
+ clean: false
+
+ - name: Add Nix to PATH
+ run: echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
+
+ - name: Configure Cachix
+ uses: ./.github/actions/setup-cachix
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
+ - name: Build prebuilt binaries
+ shell: bash
+ env:
+ SERVICE: ${{ matrix.service }}
+ run: |
+ set -euo pipefail
+ mkdir -p prebuilt
+
+ binaries=$(jq -r --arg service "$SERVICE" '.services[$service].deploy_binaries // [] | @tsv' .github/services-config.json)
+ if [[ -n "$binaries" ]]; then
+ cachix watch-store "$CACHIX_CACHE_NAME" &
+ cachix_pid=$!
+ trap 'kill "$cachix_pid" || true' EXIT
+
+ nix build ".#deploy-service-binaries-${SERVICE}"
+ cp -r result/bin/* prebuilt/
+ mkdir -p prebuilt/nix-store
+ while IFS= read -r store_path; do
+ cp -a "$store_path" prebuilt/nix-store/
+ done < <(nix-store -qR result)
+ else
+ echo "No deploy binaries configured for $SERVICE; uploading an empty artifact"
+ fi
+
+ touch prebuilt/.keep
+ tar -C prebuilt -czf prebuilt-binaries.tar.gz .
+
+ - name: Upload prebuilt binaries
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: cloud-storage-service-binaries-${{ matrix.service }}-${{ github.sha }}
+ path: prebuilt-binaries.tar.gz
+ retention-days: 7
+
deploy-services:
name: Deploy ${{ matrix.service }}
- needs: [detect-changes, migrate-db]
+ needs: [detect-changes, migrate-db, build-service-binaries]
if: ${{ needs.detect-changes.outputs.has_changes == 'true' }}
runs-on:
[
@@ -93,6 +183,14 @@ jobs:
with:
service-name: ${{ matrix.service }}
+ - name: Check prebuilt binaries config
+ id: check-binaries
+ env:
+ SERVICE: ${{ matrix.service }}
+ run: |
+ has_binaries=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_binaries // []) | length) > 0' .github/services-config.json)
+ echo "has_binaries=$has_binaries" >> "$GITHUB_OUTPUT"
+
- name: Deploy ${{ matrix.service }}
uses: ./.github/actions/deploy-cloud-storage-pulumi
with:
@@ -101,13 +199,14 @@ jobs:
aws-secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
pulumi-access-token: ${{ secrets.PULUMI_ACCESS_TOKEN }}
pulumi-service-name: ${{ steps.project-name.outputs.project-name }}
+ prebuilt-binaries-artifact: ${{ steps.check-binaries.outputs.has_binaries == 'true' && format('cloud-storage-service-binaries-{0}-{1}', matrix.service, github.sha) || '' }}
dd-app-key: ${{ secrets.DD_APP_KEY }}
dd-api-key: ${{ secrets.DD_API_KEY }}
deployment-summary:
name: Deployment Summary
runs-on: ubuntu-latest
- needs: [detect-changes, migrate-db, deploy-services]
+ needs: [detect-changes, migrate-db, build-service-binaries, deploy-services]
if: always()
steps:
- name: Check deployment results
@@ -117,6 +216,9 @@ jobs:
elif [[ "${{ needs.migrate-db.result }}" == "failure" ]]; then
echo "❌ Database migrations failed"
exit 1
+ elif [[ "${{ needs.build-service-binaries.result }}" == "failure" ]]; then
+ echo "❌ One or more service binary builds failed"
+ exit 1
elif [[ "${{ needs.deploy-services.result }}" == "failure" ]]; then
echo "❌ One or more service deployments failed"
exit 1
diff --git a/.github/workflows/reusable-deploy-service.yml b/.github/workflows/reusable-deploy-service.yml
index 2a1acfa351..1bf1532684 100644
--- a/.github/workflows/reusable-deploy-service.yml
+++ b/.github/workflows/reusable-deploy-service.yml
@@ -35,9 +35,69 @@ on:
required: true
DD_API_KEY:
required: true
+ CACHIX_AUTH_TOKEN:
+ required: true
jobs:
+ build-service-binaries:
+ name: Build ${{ inputs.service-name }} binaries
+ runs-on: linux-extra-beefy
+ outputs:
+ has_binaries: ${{ steps.check-binaries.outputs.has_binaries }}
+ steps:
+ # Pinned actions/checkout v6: https://github.com/actions/checkout/commit/de0fac2e4500dabe0009e67214ff5f5447ce83dd
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
+ with:
+ ref: ${{ github.ref_name }}
+ clean: false
+
+ - name: Add Nix to PATH
+ run: echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
+
+ - name: Configure Cachix
+ uses: ./.github/actions/setup-cachix
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
+ - name: Check prebuilt binaries config
+ id: check-binaries
+ env:
+ SERVICE: ${{ inputs.service-name }}
+ run: |
+ has_binaries=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_binaries // []) | length) > 0' .github/services-config.json)
+ echo "has_binaries=$has_binaries" >> "$GITHUB_OUTPUT"
+
+ - name: Build prebuilt binaries
+ if: ${{ steps.check-binaries.outputs.has_binaries == 'true' }}
+ shell: bash
+ env:
+ SERVICE: ${{ inputs.service-name }}
+ run: |
+ set -euo pipefail
+ mkdir -p prebuilt
+ cachix watch-store "$CACHIX_CACHE_NAME" &
+ cachix_pid=$!
+ trap 'kill "$cachix_pid" || true' EXIT
+
+ nix build ".#deploy-service-binaries-${SERVICE}"
+ cp -r result/bin/* prebuilt/
+ mkdir -p prebuilt/nix-store
+ while IFS= read -r store_path; do
+ cp -a "$store_path" prebuilt/nix-store/
+ done < <(nix-store -qR result)
+ touch prebuilt/.keep
+ tar -C prebuilt -czf prebuilt-binaries.tar.gz .
+
+ - name: Upload prebuilt binaries
+ if: ${{ steps.check-binaries.outputs.has_binaries == 'true' }}
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: cloud-storage-service-binaries-${{ inputs.service-name }}-${{ github.sha }}
+ path: prebuilt-binaries.tar.gz
+ retention-days: 7
+
deploy:
+ needs: build-service-binaries
runs-on:
[
runs-on,
@@ -65,6 +125,7 @@ jobs:
aws-secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
pulumi-access-token: ${{ secrets.PULUMI_ACCESS_TOKEN }}
pulumi-service-name: ${{ inputs.pulumi-stack-name || steps.project-name.outputs.project-name }}
+ prebuilt-binaries-artifact: ${{ needs.build-service-binaries.outputs.has_binaries == 'true' && format('cloud-storage-service-binaries-{0}-{1}', inputs.service-name, github.sha) || '' }}
dd-app-key: ${{ secrets.DD_APP_KEY }}
dd-api-key: ${{ secrets.DD_API_KEY }}
use-docker: ${{ inputs.use-docker }}
diff --git a/flake.nix b/flake.nix
index 9af63488ee..c9781cc8a2 100644
--- a/flake.nix
+++ b/flake.nix
@@ -181,6 +181,52 @@
}
);
+ deployCargoArtifacts = craneLib.buildDepsOnly (
+ commonArgs
+ // {
+ pname = "cloud-storage-deploy-deps";
+ cargoExtraArgs = "--locked";
+ CARGO_PROFILE = "release";
+ }
+ );
+
+ deployServiceBinaryPackage =
+ serviceName: binaries:
+ craneLib.buildPackage (
+ commonArgs
+ // {
+ cargoArtifacts = deployCargoArtifacts;
+ pname = "cloud-storage-${serviceName}-binaries";
+ doCheck = false;
+ cargoExtraArgs = "--locked " + pkgs.lib.concatMapStringsSep " " (binary: "--bin ${binary}") binaries;
+ CARGO_PROFILE = "release";
+ installPhaseCommand = ''
+ mkdir -p $out/bin
+ for binary in ${pkgs.lib.concatStringsSep " " binaries}; do
+ cp target/release/$binary $out/bin/$binary
+ ${pkgs.binutils}/bin/strip $out/bin/$binary || true
+ done
+ '';
+ }
+ );
+
+ deployServiceBinaryPackages = {
+ deploy-service-binaries-agent-schedule-service = deployServiceBinaryPackage "agent-schedule-service" [ "service" ];
+ deploy-service-binaries-authentication-service = deployServiceBinaryPackage "authentication-service" [ "authentication_service" ];
+ deploy-service-binaries-connection-gateway = deployServiceBinaryPackage "connection-gateway" [ "connection_gateway_service" ];
+ deploy-service-binaries-contacts-service = deployServiceBinaryPackage "contacts-service" [ "contacts_service" ];
+ deploy-service-binaries-convert-service = deployServiceBinaryPackage "convert-service" [ "convert_service" ];
+ deploy-service-binaries-document-cognition-service = deployServiceBinaryPackage "document-cognition-service" [ "document_cognition_service" ];
+ deploy-service-binaries-document-storage-service = deployServiceBinaryPackage "document-storage-service" [ "document_storage_service" ];
+ deploy-service-binaries-email-service = deployServiceBinaryPackage "email-service" [ "email_service" "pubsub_workers" ];
+ deploy-service-binaries-image-proxy-service = deployServiceBinaryPackage "image-proxy-service" [ "image_proxy_service" ];
+ deploy-service-binaries-mcp-server = deployServiceBinaryPackage "mcp-server" [ "mcp_service" ];
+ deploy-service-binaries-notification-service = deployServiceBinaryPackage "notification-service" [ "notification_service" ];
+ deploy-service-binaries-search-processing-service = deployServiceBinaryPackage "search-processing-service" [ "search_processing_service" ];
+ deploy-service-binaries-static-file-service = deployServiceBinaryPackage "static-file-service" [ "static_file_service" ];
+ deploy-service-binaries-unfurl-service = deployServiceBinaryPackage "unfurl-service" [ "unfurl_service" ];
+ };
+
shellTools =
with pkgs;
[
@@ -388,7 +434,7 @@
packages = {
inherit cargoArtifacts workspaceArtifacts openApiBins nextestArchive;
default = cargoArtifacts;
- };
+ } // deployServiceBinaryPackages;
devShells = {
default = pkgs.mkShell (
diff --git a/infra/packages/service/src/ecr.ts b/infra/packages/service/src/ecr.ts
index 03a7d2147b..2f2eda2cfb 100644
--- a/infra/packages/service/src/ecr.ts
+++ b/infra/packages/service/src/ecr.ts
@@ -73,13 +73,38 @@ export class EcrImage extends pulumi.ComponentResource {
{ parent: this }
);
+ const usePrebuiltServiceBinaries =
+ process.env.USE_PREBUILT_SERVICE_BINARIES === 'true';
+ const prebuiltDockerfiles: { [key: string]: string } = {
+ Dockerfile: 'Dockerfile.prebuilt',
+ 'Dockerfile.convert_service': 'Dockerfile.convert_service.prebuilt',
+ 'Dockerfile.search_processing_service':
+ 'Dockerfile.search_processing_service.prebuilt',
+ };
+ const effectiveDockerfile = (() => {
+ if (!usePrebuiltServiceBinaries) {
+ return dockerfile;
+ }
+
+ const dockerfileKey = dockerfile ?? 'Dockerfile';
+ const prebuiltDockerfile = prebuiltDockerfiles[dockerfileKey];
+ if (!prebuiltDockerfile) {
+ throw new Error(
+ `No prebuilt Dockerfile mapping configured for ${dockerfileKey}`
+ );
+ }
+ return prebuiltDockerfile;
+ })();
+
this.image = new awsx.ecr.Image(
imageId,
{
imageTag: 'latest',
context: imagePath,
platform: `${platform.family}/${platform.architecture}`,
- dockerfile: dockerfile ? `${imagePath}/${dockerfile}` : undefined,
+ dockerfile: effectiveDockerfile
+ ? `${imagePath}/${effectiveDockerfile}`
+ : undefined,
repositoryUrl: this.ecr.url,
args: buildArgs,
},
diff --git a/infra/stacks/convert-service/service.ts b/infra/stacks/convert-service/service.ts
index e8da8f404f..3ea259a126 100644
--- a/infra/stacks/convert-service/service.ts
+++ b/infra/stacks/convert-service/service.ts
@@ -172,6 +172,9 @@ export class ConvertService extends pulumi.ComponentResource {
imagePath: BASE_PATH,
dockerfile: 'Dockerfile.convert_service',
platform,
+ buildArgs: {
+ SERVICE_NAME: 'convert_service',
+ },
tags: this.tags,
},
{ parent: this }
diff --git a/infra/stacks/search-processing-service/service.ts b/infra/stacks/search-processing-service/service.ts
index 9ccf2bb3d1..be8e58e967 100644
--- a/infra/stacks/search-processing-service/service.ts
+++ b/infra/stacks/search-processing-service/service.ts
@@ -176,6 +176,9 @@ export class SearchProcessingService extends pulumi.ComponentResource {
imagePath: BASE_PATH,
dockerfile: 'Dockerfile.search_processing_service',
platform,
+ buildArgs: {
+ SERVICE_NAME: 'search_processing_service',
+ },
tags: this.tags,
},
{ parent: this }
diff --git a/rust/cloud-storage/Dockerfile.convert_service.prebuilt b/rust/cloud-storage/Dockerfile.convert_service.prebuilt
new file mode 100644
index 0000000000..0926ee440b
--- /dev/null
+++ b/rust/cloud-storage/Dockerfile.convert_service.prebuilt
@@ -0,0 +1,43 @@
+FROM ubuntu:noble AS base
+ARG SERVICE_NAME=convert_service
+WORKDIR /app
+
+# Accept the Microsoft core fonts license
+RUN printf '%s\n' "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" > /tmp/ms-fonts-selections \
+ && debconf-set-selections /tmp/ms-fonts-selections \
+ && rm /tmp/ms-fonts-selections
+
+RUN : \
+ && apt-get update \
+ && apt-get install -y --no-install-recommends \
+ curl \
+ tar \
+ libreoffice \
+ libreofficekit-dev \
+ ca-certificates \
+ openssl \
+ dumb-init \
+ libkrb5-3 \
+ ttf-mscorefonts-installer \
+ wget xfonts-utils \
+ cabextract \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/*
+
+RUN fc-cache -f -v
+
+RUN curl --fail --show-error -L -o core-co-25.04-assets.tar.gz https://github.com/CollaboraOnline/online/releases/download/for-code-assets/core-co-25.04-assets.tar.gz \
+ && echo "751a4323b6dd26cc1b6c3353d96173f63ff9910618eba93d614b6dabe38afc23 core-co-25.04-assets.tar.gz" | sha256sum -c - \
+ && tar -xvf core-co-25.04-assets.tar.gz \
+ && mkdir -p /app/lok \
+ && mv instdir /app/lok/instdir \
+ && mv include /app/lok/include \
+ && rm core-co-25.04-assets.tar.gz
+
+COPY ./prebuilt/nix-store/ /nix/store/
+COPY ./prebuilt/${SERVICE_NAME} /app/svc
+RUN chmod +x /app/svc
+
+ENV PORT=8080
+EXPOSE ${PORT}
+ENTRYPOINT ["dumb-init", "./svc"]
diff --git a/rust/cloud-storage/Dockerfile.prebuilt b/rust/cloud-storage/Dockerfile.prebuilt
index e55a9c4ad4..2cf6dbbab3 100644
--- a/rust/cloud-storage/Dockerfile.prebuilt
+++ b/rust/cloud-storage/Dockerfile.prebuilt
@@ -1,5 +1,5 @@
FROM debian:trixie-slim AS runner
-ARG SERVICE_NAME
+ARG SERVICE_NAME=__MISSING_SERVICE_NAME__
WORKDIR /app
RUN apt-get update \
@@ -10,8 +10,9 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
-# Copy the pre-built Linux binary from Docker build
-COPY --from=release ${SERVICE_NAME} /app/svc
+# Copy the runtime closure and pre-built Linux binary from the GitHub Actions artifact.
+COPY ./prebuilt/nix-store/ /nix/store/
+COPY ./prebuilt/${SERVICE_NAME} /app/svc
RUN chmod +x /app/svc
ENV PORT=8080
diff --git a/rust/cloud-storage/Dockerfile.search_processing_service.prebuilt b/rust/cloud-storage/Dockerfile.search_processing_service.prebuilt
new file mode 100644
index 0000000000..98d37bacbb
--- /dev/null
+++ b/rust/cloud-storage/Dockerfile.search_processing_service.prebuilt
@@ -0,0 +1,23 @@
+FROM debian:trixie-slim AS runner
+ARG SERVICE_NAME=search_processing_service
+WORKDIR /app
+
+RUN : \
+ && apt-get update \
+ && apt-get install -y --no-install-recommends \
+ ca-certificates \
+ openssl \
+ dumb-init \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/*
+
+COPY ./prebuilt/nix-store/ /nix/store/
+COPY ./prebuilt/${SERVICE_NAME} /app/svc
+RUN mkdir -p /app/pdfium-lib/linux
+COPY ./search_processing_service/pdfium-lib/linux/libpdfium.so /app/pdfium-lib/linux/libpdfium.so
+
+RUN chmod +x /app/svc
+
+ENV PORT=8080
+EXPOSE ${PORT}
+ENTRYPOINT ["dumb-init", "./svc"]