Files
ai/riscv64.Dockerfile
zeekayandHanzo Dev fa67e450e4 build: pin the Go builders to 1.26.5 and let the toolchain download
The official golang images set GOTOOLCHAIN=local, so a go.mod `go` directive
newer than the base image fails the build at the first go command:

    go: go.mod requires go >= 1.26.5 (running go 1.26.4; GOTOOLCHAIN=local)

Two orthogonal changes. Pinning the base to the exact patch go.mod names makes
the build hermetic — the versions match, so no toolchain is downloaded.
GOTOOLCHAIN=auto is the resilience half: when go.mod next moves ahead of the
pin, the toolchain is fetched and checksum-verified against sum.golang.org
instead of failing the build outright.

All three Dockerfiles carried a builder older than the module. riscv64 moves
from 1.23.11-alpine3.21 to 1.26.5-alpine: riscv64/golang publishes no
1.26.5-alpine3.21 or -alpine3.22 tag (both 404), only the unsuffixed variant.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-01 16:45:08 -07:00

72 lines
2.2 KiB
Docker

FROM --platform=$BUILDPLATFORM riscv64/ubuntu:latest AS FRONT
RUN apt-get update && apt-get install -y nodejs npm
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /web
COPY ./web .
ENV NODE_OPTIONS="--max-old-space-size=4144"
RUN pnpm install --frozen-lockfile && pnpm build
FROM --platform=$BUILDPLATFORM riscv64/golang:1.26.5-alpine AS BACK
# go.mod pins the toolchain. The golang base image sets GOTOOLCHAIN=local,
# which turns a `go` directive newer than the image into a hard build
# failure instead of a download.
ENV GOTOOLCHAIN=auto
WORKDIR /go/src/cloud
COPY . .
RUN chmod +x ./build.sh
RUN sh ./build.sh
FROM riscv64/alpine:latest AS STANDARD
LABEL MAINTAINER="https://hanzo.ai/"
ARG USER=cloud
ARG TARGETOS
ARG TARGETARCH
ENV BUILDX_ARCH="${TARGETOS:-linux}_${TARGETARCH:-amd64}"
RUN sed -i 's/https/http/' /etc/apk/repositories
RUN apk add --update sudo
RUN apk add curl
RUN apk add ca-certificates && update-ca-certificates
RUN adduser -D $USER -u 1000 \
&& echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER \
&& chmod 0440 /etc/sudoers.d/$USER \
&& mkdir logs \
&& chown -R $USER:$USER logs
USER 1000
WORKDIR /
COPY --from=BACK --chown=$USER:$USER /go/src/cloud/server_${BUILDX_ARCH} ./server
COPY --from=BACK --chown=$USER:$USER /go/src/cloud/data ./data
COPY --from=BACK --chown=$USER:$USER /go/src/cloud/conf/app.conf ./conf/app.conf
COPY --from=FRONT --chown=$USER:$USER /web/build ./web/build
ENTRYPOINT ["/server"]
FROM riscv64/ubuntu:latest AS db
RUN apt update \
&& apt install -y \
mariadb-server \
mariadb-client \
&& rm -rf /var/lib/apt/lists/*
FROM db AS ALLINONE
LABEL MAINTAINER="https://hanzo.ai/"
ARG TARGETOS
ARG TARGETARCH
ENV BUILDX_ARCH="${TARGETOS:-linux}_${TARGETARCH:-riscv64}"
RUN apt update
RUN apt install -y ca-certificates && update-ca-certificates
WORKDIR /
COPY --from=BACK /go/src/cloud/server_${BUILDX_ARCH} ./server
COPY --from=BACK /go/src/cloud/data ./data
COPY --from=BACK /go/src/cloud/docker-entrypoint.sh /docker-entrypoint.sh
COPY --from=BACK /go/src/cloud/conf/app.conf ./conf/app.conf
COPY --from=FRONT /web/build ./web/build
ENTRYPOINT ["/bin/bash"]
CMD ["/docker-entrypoint.sh"]