代码拉取完成,页面将自动刷新
# Container build for fakedev-exporter + fakedev-workload
#
# test phase may require using "--build-arg=http_proxy=..." for package install
# common variables
ARG USER=65534
ARG BUILD_DIR=/build
ARG GOVERSION=1.21
# *** build stage ***
FROM golang:${GOVERSION} AS builder
ARG BUILD_DIR
# golang image sets both GOPATH & WORKDIR to /go/, but
# "go mod tidy" complains if that's the case, so change it
WORKDIR $BUILD_DIR
# to get correct branch/commit info to binary
COPY .git/ ./.git
COPY Makefile go.* ./
COPY cmd/ ./cmd
# static checker
RUN go vet ./...
RUN make race static && \
strip -s fakedev-exporter fakedev-workload
# *** test stage ***
FROM ubuntu:22.04
# tools used in testing: make, wget, killall, diff
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get -y install --no-install-recommends make wget psmisc diffutils
# import
ARG USER
ARG BUILD_DIR
# make needs to be in same dir with binaries etc
# and that dir needs to be writable by wget
WORKDIR /tmp
RUN chown ${USER} .
# versions of the binaries with Golang test tooling
COPY --from=builder \
${BUILD_DIR}/fakedev-exporter-race \
${BUILD_DIR}/fakedev-workload \
${BUILD_DIR}/invalid-workload \
./
# other files + scripts for testing
COPY deployments/ ./deployments
COPY configs/ ./configs
COPY Makefile test-*.sh ./
USER ${USER}
# fail build if tests fail
RUN make test-race
# *** final stage ***
FROM scratch
# import
ARG USER
ARG BUILD_DIR
# add binary
COPY --from=builder \
${BUILD_DIR}/fakedev-exporter \
${BUILD_DIR}/fakedev-workload \
/
# add config files + license
COPY configs/ /
COPY LICENSE /
USER ${USER}
CMD ["/fakedev-exporter", "-help"]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。