Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

2.1 KB
Raw Blame
FROM node:22-alpine AS build

ENV CI=true

RUN npm --fetch-retries=3 install -g corepack && corepack enable

COPY --from=golang:1.25.4-alpine /usr/local/go/ /usr/local/go/

ENV PATH="/usr/local/go/bin:${PATH}"

RUN --mount=type=bind,source=scripts/build,target=/build-scripts sh /build-scripts/install-apk.sh git

WORKDIR /boxlite/apps

# Yarn caching layer
COPY apps/package.json apps/yarn.lock apps/.yarnrc.yml ./
RUN YARN_HTTP_RETRY=3 yarn install --immutable

# Nx config
COPY apps/nx.json ./

# Go dependency layer (cached unless go.mod/go.sum change)
COPY apps/go.work apps/go.work.sum ./
COPY apps/image-service/go.mod apps/image-service/go.sum image-service/
COPY apps/libs/common-go/go.mod apps/libs/common-go/go.sum libs/common-go/
COPY apps/libs/api-client-go/go.mod apps/libs/api-client-go/go.sum libs/api-client-go/
RUN head -1 go.work > go.work.tmp && printf '\nuse (\n\t./image-service\n\t./libs/common-go\n\t./libs/api-client-go\n)\n' >> go.work.tmp && mv go.work.tmp go.work

ENV NX_DAEMON=false
ENV GOWORK=/boxlite/apps/go.work

RUN --mount=type=bind,source=scripts/build,target=/build-scripts \
    for module in image-service libs/common-go libs/api-client-go; do \
      sh /build-scripts/retry-fetch.sh go -C "$module" mod download || exit $?; \
    done

# Go source
COPY apps/image-service/ image-service/
COPY apps/libs/common-go/ libs/common-go/
COPY apps/libs/api-client-go/ libs/api-client-go/

ARG VERSION=0.0.1
RUN --mount=type=cache,target=/root/.cache/go-build \
  VERSION=$VERSION yarn nx build image-service --configuration=production --nxBail=true

FROM alpine:3.22 AS registry-proxy

RUN --mount=type=bind,source=scripts/build,target=/build-scripts sh /build-scripts/install-apk.sh curl

WORKDIR /usr/local/bin

COPY --from=build /boxlite/apps/dist/apps/registry-proxy boxlite-registry-proxy

RUN chmod +x boxlite-registry-proxy

# Nothing here needs root: the default port is above 1024 and nothing is
# written to disk, so a process that holds runner keys runs without it.
USER 65532:65532

HEALTHCHECK CMD [ "curl", "-f", "http://localhost:4100/health" ]

ENTRYPOINT ["boxlite-registry-proxy"]