headplane/Dockerfile

65 lines
2.2 KiB
Text
Raw Normal View History

2025-06-22 16:59:21 -04:00
FROM --platform=$BUILDPLATFORM jdxcode/mise:latest AS mise-context
COPY mise.toml .tool-versions ./
ARG MISE_GITHUB_TOKEN
ENV MISE_GITHUB_TOKEN=${MISE_GITHUB_TOKEN:-}
2025-06-20 11:32:27 -04:00
RUN mise install
2025-06-22 16:59:21 -04:00
FROM --platform=$BUILDPLATFORM mise-context AS go-build
2025-06-20 11:32:27 -04:00
WORKDIR /build/
2025-06-20 11:32:27 -04:00
COPY go.mod go.sum ./
RUN go mod download
2025-06-20 11:32:27 -04:00
COPY cmd/ ./cmd/
COPY internal/ ./internal/
2025-06-22 16:59:21 -04:00
ARG TARGETOS
ARG TARGETARCH
ARG IMAGE_TAG
2025-06-22 16:59:21 -04:00
RUN mkdir -p /build/app/ && \
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 IMAGE_TAG=$IMAGE_TAG \
mise run wasm ::: agent ::: fake-shell
2025-06-22 16:59:21 -04:00
2025-06-20 11:32:27 -04:00
RUN chmod +x /build/build/hp_agent
RUN chmod +x /build/build/sh
2024-03-26 10:07:04 -04:00
2025-06-22 16:59:21 -04:00
FROM --platform=$BUILDPLATFORM mise-context AS js-build
2025-06-20 11:32:27 -04:00
WORKDIR /build
2024-05-15 22:26:36 -04:00
COPY patches ./patches
2025-06-20 11:32:27 -04:00
COPY package.json pnpm-lock.yaml ./
2024-03-26 10:07:04 -04:00
RUN pnpm install --frozen-lockfile
COPY . .
2025-06-20 11:32:27 -04:00
RUN mise trust
COPY --from=go-build /build/app/hp_ssh.wasm /build/app/hp_ssh.wasm
COPY --from=go-build /build/app/wasm_exec.js /build/app/wasm_exec.js
2024-03-26 10:07:04 -04:00
RUN pnpm run build
RUN mkdir -p /var/lib/headplane/agent
FROM gcr.io/distroless/nodejs22-debian12:nonroot AS final
2025-06-20 11:32:27 -04:00
COPY --from=js-build --chown=nonroot:nonroot /build/build/ /app/build/
COPY --from=js-build --chown=nonroot:nonroot /build/drizzle /app/drizzle/
COPY --from=js-build --chown=nonroot:nonroot /var/lib/headplane /var/lib/headplane
COPY --from=js-build --chown=nonroot:nonroot /build/node_modules/ /app/node_modules/
COPY --from=go-build --chown=nonroot:nonroot /build/build/hp_agent /usr/libexec/headplane/agent
# Fake shell to inform the user that they should use the debug image
COPY --from=go-build --chown=nonroot:nonroot /build/build/sh /bin/sh
COPY --from=go-build --chown=nonroot:nonroot /build/build/sh /bin/bash
2024-03-26 10:07:04 -04:00
WORKDIR /app
2025-06-20 11:32:27 -04:00
CMD [ "/app/build/server/index.js" ]
FROM node:22-alpine AS debug-shell
RUN apk add --no-cache bash curl git
COPY --from=js-build --chown=nonroot:nonroot /build/build/ /app/build/
COPY --from=js-build --chown=nonroot:nonroot /build/drizzle /app/drizzle/
COPY --from=js-build --chown=nonroot:nonroot /var/lib/headplane /var/lib/headplane
COPY --from=js-build --chown=nonroot:nonroot /build/node_modules/ /app/node_modules/
COPY --from=go-build --chown=nonroot:nonroot /build/build/hp_agent /usr/libexec/headplane/agent
WORKDIR /app
CMD [ "node", "/app/build/server/index.js" ]