Merge pull request #14503 from ninjadq/base_image_4_exporter

Base image for exporter
This commit is contained in:
Daniel Jiang 2021-03-26 00:20:19 +08:00 committed by GitHub
commit e23b7eab21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 14 deletions

View File

@ -374,12 +374,7 @@ compile_standalone_db_migrator:
@$(DOCKERCMD) run --rm -v $(BUILDPATH):$(GOBUILDPATHINCONTAINER) -w $(GOBUILDPATH_STANDALONE_DB_MIGRATOR) $(GOBUILDIMAGE) $(GOIMAGEBUILD_COMMON) -o $(GOBUILDPATHINCONTAINER)/$(GOBUILDMAKEPATH_STANDALONE_DB_MIGRATOR)/$(STANDALONE_DB_MIGRATOR_BINARYNAME) @$(DOCKERCMD) run --rm -v $(BUILDPATH):$(GOBUILDPATHINCONTAINER) -w $(GOBUILDPATH_STANDALONE_DB_MIGRATOR) $(GOBUILDIMAGE) $(GOIMAGEBUILD_COMMON) -o $(GOBUILDPATHINCONTAINER)/$(GOBUILDMAKEPATH_STANDALONE_DB_MIGRATOR)/$(STANDALONE_DB_MIGRATOR_BINARYNAME)
@echo "Done." @echo "Done."
compile_exporter: compile: check_environment versions_prepare compile_core compile_jobservice compile_registryctl compile_notary_migrate_patch
@echo "compiling binary for exporter (golang image)..."
@$(DOCKERCMD) build -f ${GOBUILDMAKEPATH_EXPORTER}/Dockerfile --build-arg build_image=$(GOBUILDIMAGE) -t $(DOCKERIMAGENAME_EXPORTER):$(VERSIONTAG) .
@echo "Done."
compile: check_environment versions_prepare compile_core compile_jobservice compile_registryctl compile_notary_migrate_patch compile_exporter
update_prepare_version: update_prepare_version:
@echo "substitute the prepare version tag in prepare file..." @echo "substitute the prepare version tag in prepare file..."
@ -416,7 +411,7 @@ build_base_docker:
else \ else \
echo "No docker credentials provided, please make sure enough priviledges to access docker hub!" ; \ echo "No docker credentials provided, please make sure enough priviledges to access docker hub!" ; \
fi fi
@for name in chartserver trivy-adapter core db jobservice log nginx notary-server notary-signer portal prepare redis registry registryctl; do \ @for name in chartserver trivy-adapter core db jobservice log nginx notary-server notary-signer portal prepare redis registry registryctl exporter; do \
echo $$name ; \ echo $$name ; \
sleep 30 ; \ sleep 30 ; \
$(DOCKERBUILD) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . && \ $(DOCKERBUILD) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . && \

View File

@ -91,6 +91,9 @@ DOCKERFILEPATH_STANDALONE_DB_MIGRATOR=$(DOCKERFILEPATH)/standalone-db-migrator
DOCKERFILENAME_STANDALONE_DB_MIGRATOR=Dockerfile DOCKERFILENAME_STANDALONE_DB_MIGRATOR=Dockerfile
DOCKERIMAGENAME_STANDALONE_DB_MIGRATOR=goharbor/standalone-db-migrator DOCKERIMAGENAME_STANDALONE_DB_MIGRATOR=goharbor/standalone-db-migrator
DOCKERFILEPATH_EXPORTER=$(DOCKERFILEPATH)/exporter
DOCKERFILENAME_EXPORTER=Dockerfile
DOCKERIMAGENAME_EXPORTER=goharbor/harbor-exporter
# for chart server (chartmuseum) # for chart server (chartmuseum)
DOCKERFILEPATH_CHART_SERVER=$(DOCKERFILEPATH)/chartserver DOCKERFILEPATH_CHART_SERVER=$(DOCKERFILEPATH)/chartserver
@ -213,6 +216,11 @@ _build_standalone_db_migrator:
@$(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) --build-arg harbor_base_namespace=$(BASEIMAGENAMESPACE) -f $(DOCKERFILEPATH_STANDALONE_DB_MIGRATOR)/$(DOCKERFILENAME_STANDALONE_DB_MIGRATOR) -t $(DOCKERIMAGENAME_STANDALONE_DB_MIGRATOR):$(VERSIONTAG) . @$(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) --build-arg harbor_base_namespace=$(BASEIMAGENAMESPACE) -f $(DOCKERFILEPATH_STANDALONE_DB_MIGRATOR)/$(DOCKERFILENAME_STANDALONE_DB_MIGRATOR) -t $(DOCKERIMAGENAME_STANDALONE_DB_MIGRATOR):$(VERSIONTAG) .
@echo "Done." @echo "Done."
_compile_and_build_exporter:
@echo "compiling and building image for exporter..."
@$(DOCKERCMD) build --build-arg harbor_base_image_version=$(BASEIMAGETAG) --build-arg harbor_base_namespace=$(BASEIMAGENAMESPACE) --build-arg build_image=$(GOBUILDIMAGE) -f ${DOCKERFILEPATH_EXPORTER}/${DOCKERFILENAME_EXPORTER} -t $(DOCKERIMAGENAME_EXPORTER):$(VERSIONTAG) .
@echo "Done."
define _extract_archive define _extract_archive
echo "download $1";\ echo "download $1";\
$(CURL) --connect-timeout 30 -f -k -L $1 | tar xvz -C $2 || exit 1 $(CURL) --connect-timeout 30 -f -k -L $1 | tar xvz -C $2 || exit 1
@ -223,7 +231,9 @@ define _get_binary
$(CURL) --connect-timeout 30 -f -k -L $1 -o $2 || exit 1 $(CURL) --connect-timeout 30 -f -k -L $1 -o $2 || exit 1
endef endef
build: _build_prepare _build_db _build_portal _build_core _build_jobservice _build_log _build_nginx _build_registry _build_registryctl _build_notary _build_trivy_adapter _build_redis _build_chart_server
build: _build_prepare _build_db _build_portal _build_core _build_jobservice _build_log _build_nginx _build_registry _build_registryctl _build_notary _build_trivy_adapter _build_redis _build_chart_server _compile_and_build_exporter
cleanimage: cleanimage:
@echo "cleaning image for photon..." @echo "cleaning image for photon..."

View File

@ -1,4 +1,7 @@
ARG build_image ARG build_image
ARG harbor_base_image_version
ARG harbor_base_namespace
FROM ${build_image} AS build FROM ${build_image} AS build
ENV CGO_ENABLED=0 ENV CGO_ENABLED=0
@ -9,12 +12,7 @@ COPY src /harbor/src
WORKDIR /harbor/src/cmd/exporter WORKDIR /harbor/src/cmd/exporter
RUN go build -o /out/harbor_exporter RUN go build -o /out/harbor_exporter
FROM photon:2.0 FROM ${harbor_base_namespace}/harbor-exporter-base:${harbor_base_image_version}
RUN tdnf install -y tzdata shadow >> /dev/null \
&& tdnf clean all \
&& groupadd -r -g 10000 harbor && useradd --no-log-init -r -m -g 10000 -u 10000 harbor \
&& mkdir /harbor/
COPY --from=build /out/harbor_exporter /harbor/harbor_exporter COPY --from=build /out/harbor_exporter /harbor/harbor_exporter
COPY ./make/photon/exporter/entrypoint.sh ./make/photon/common/install_cert.sh /harbor/ COPY ./make/photon/exporter/entrypoint.sh ./make/photon/common/install_cert.sh /harbor/

View File

@ -0,0 +1,6 @@
FROM photon:2.0
RUN tdnf install -y tzdata shadow >> /dev/null \
&& tdnf clean all \
&& groupadd -r -g 10000 harbor && useradd --no-log-init -r -m -g 10000 -u 10000 harbor \
&& mkdir /harbor/