Files
ai/riscv64.Dockerfile
zeekayandHanzo Dev 0c08bd1d94 Go 1.27.1, and the code it can say more simply
Modules declare go 1.27.1 and the build images follow. go fix applied the
modernizers; omitzero is not applied, since it changes what the JSON says.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-17 01:01:10 -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.27.1-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"]