mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-20 14:13:23 +00:00
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]>
72 lines
2.2 KiB
Docker
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"]
|