3 Star 0 Fork 0

mirrors_intel/fakedev-exporter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
fakedev-exporter.docker 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
Eero Tamminen 提交于 2024-04-19 17:50 . Update to Go 1.21
# 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"]
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_intel/fakedev-exporter.git
git@gitee.com:mirrors_intel/fakedev-exporter.git
mirrors_intel
fakedev-exporter
fakedev-exporter
main

搜索帮助