Files
lincodex/runner/Dockerfile
T

46 lines
1.7 KiB
Docker

# Production image of the code runner. It runs only on the dedicated runner
# host or VM, never on the core application host; see docs/en/DEPLOY.md.
#
# Base images are build arguments so that a release build can pin each one to
# the digest it resolved; the defaults keep the agreed tags.
ARG GO_IMAGE=golang:1.26.9-alpine
ARG RUNTIME_IMAGE=python:alpine
FROM ${GO_IMAGE} AS build
# Never download another Go toolchain: a go.mod that asks for a newer Go
# fails the build instead of silently replacing 1.26.9.
ENV GOTOOLCHAIN=local
WORKDIR /src/runner
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -trimpath -ldflags="-s -w" -o /out/lincodex-runner ./cmd/runner
FROM ${RUNTIME_IMAGE}
# The runtime is the Python base plus nsjail. Package installers are removed,
# so a jailed program finds no pip, and nothing is installed at run time.
RUN apk upgrade --no-cache \
&& apk add --no-cache nsjail \
&& python -m pip uninstall --yes pip \
&& python -c "import ensurepip, shutil; shutil.rmtree(ensurepip.__path__[0])" \
&& install -d -m 0711 /var/lib/lincodex-runner/work
# The binary lives outside /usr and /lib, which are the only host paths
# mounted into a jail.
COPY --from=build /out/lincodex-runner /opt/lincodex-runner/lincodex-runner
# The supervisor needs root on its dedicated host to create namespaces, map
# the sandbox user, and write its delegated cgroup. Jailed programs run as
# uid 99999 without capabilities, with no_new_privs and a seccomp policy.
USER 0:0
EXPOSE 8443
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["/opt/lincodex-runner/lincodex-runner", "healthcheck"]
ENTRYPOINT ["/opt/lincodex-runner/lincodex-runner"]