FROM --platform=$BUILDPLATFORM docker-0.unsee.tech/golang:alpine AS builder WORKDIR /app ENV GOPROXY=https://goproxy.cn \ GO111MODULE=on \ CGO_ENABLED=0 \ GOCACHE=/root/.cache/go-build \ GOMODCACHE=/go/pkg/mod COPY ../common /app/common COPY . /app/storage # 指定构建参数 ARG TARGETOS ARG TARGETARCH # 编译 WORKDIR /app/storage RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ mage linux all # agent FROM --platform=$TARGETPLATFORM docker-0.unsee.tech/alpine:latest AS agentimage WORKDIR /app COPY --from=builder /app/storage/build/agent . RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories RUN apk add --no-cache tzdata ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN chmod +x agent/agent ENTRYPOINT ["./agent/agent"] # coordinator FROM --platform=$TARGETPLATFORM docker-0.unsee.tech/alpine:latest AS coorimage WORKDIR /app COPY --from=builder /app/storage/build/coordinator . RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories RUN apk add --no-cache tzdata ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN chmod +x coordinator/coordinator ENTRYPOINT ["./coordinator/coordinator"] # scanner FROM --platform=$TARGETPLATFORM docker-0.unsee.tech/alpine:latest AS scannerimage WORKDIR /app COPY --from=builder /app/storage/build/scanner . RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories RUN apk add --no-cache tzdata ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN chmod +x scanner/scanner ENTRYPOINT ["./scanner/scanner"] # client FROM --platform=$TARGETPLATFORM docker-0.unsee.tech/alpine:latest AS clientimage WORKDIR /app COPY --from=builder /app/storage/build/client . RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories RUN apk add --no-cache tzdata ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN chmod +x client/client ENTRYPOINT ["./client/client","serve","http"]