From 544cc98971b8835aace669324a8bb3e885ef9436 Mon Sep 17 00:00:00 2001 From: Wang Yan Date: Mon, 11 Nov 2019 18:56:36 +0800 Subject: [PATCH 1/2] add base images when to build harbor assets * add base images when to build harbor assets Signed-off-by: wang yan --- Makefile | 11 ++++++- make/photon/Makefile | 31 +++++++++++++++---- make/photon/chartserver/Dockerfile | 7 +---- make/photon/chartserver/base.Dockerfile | 6 ++++ make/photon/clair-adapter/Dockerfile | 8 +---- make/photon/clair-adapter/base.Dockerfile | 7 +++++ make/photon/clair/Dockerfile | 6 +--- make/photon/clair/base.Dockerfile | 6 ++++ make/photon/core/Dockerfile | 7 +---- make/photon/core/base.Dockerfile | 6 ++++ make/photon/db/Dockerfile | 18 +---------- make/photon/db/base.Dockerfile | 17 ++++++++++ make/photon/jobservice/Dockerfile | 6 +--- make/photon/jobservice/base.Dockerfile | 5 +++ make/photon/log/Dockerfile | 7 +---- make/photon/log/base.Dockerfile | 6 ++++ make/photon/nginx/Dockerfile | 8 +---- make/photon/nginx/base.Dockerfile | 7 +++++ .../Dockerfile} | 8 ++--- make/photon/notary-server/base.Dockerfile | 6 ++++ .../Dockerfile} | 6 +--- make/photon/notary-signer/base.Dockerfile | 6 ++++ make/photon/portal/Dockerfile | 10 +----- make/photon/portal/base.Dockerfile | 8 +++++ make/photon/prepare/Dockerfile | 6 +--- make/photon/prepare/base.Dockerfile | 5 +++ make/photon/redis/Dockerfile | 4 +-- make/photon/redis/base.Dockerfile | 3 ++ make/photon/registry/Dockerfile | 10 +----- make/photon/registry/base.Dockerfile | 6 ++++ make/photon/registryctl/Dockerfile | 9 +----- make/photon/registryctl/base.Dockerfile | 8 +++++ 32 files changed, 153 insertions(+), 111 deletions(-) create mode 100644 make/photon/chartserver/base.Dockerfile create mode 100644 make/photon/clair-adapter/base.Dockerfile create mode 100644 make/photon/clair/base.Dockerfile create mode 100644 make/photon/core/base.Dockerfile create mode 100644 make/photon/db/base.Dockerfile create mode 100644 make/photon/jobservice/base.Dockerfile create mode 100644 make/photon/log/base.Dockerfile create mode 100644 make/photon/nginx/base.Dockerfile rename make/photon/{notary/server.Dockerfile => notary-server/Dockerfile} (74%) create mode 100644 make/photon/notary-server/base.Dockerfile rename make/photon/{notary/signer.Dockerfile => notary-signer/Dockerfile} (75%) create mode 100644 make/photon/notary-signer/base.Dockerfile create mode 100644 make/photon/portal/base.Dockerfile create mode 100644 make/photon/prepare/base.Dockerfile create mode 100644 make/photon/redis/base.Dockerfile create mode 100644 make/photon/registry/base.Dockerfile create mode 100644 make/photon/registryctl/base.Dockerfile diff --git a/Makefile b/Makefile index c01aeeec2..b6e285e46 100644 --- a/Makefile +++ b/Makefile @@ -88,6 +88,8 @@ CHARTFLAG=false # version prepare # for docker image tag VERSIONTAG=dev +# for base docker image tag +BASEIMAGETAG=dev # for harbor package name PKGVERSIONTAG=dev @@ -321,7 +323,14 @@ build: -e CLAIRVERSION=$(CLAIRVERSION) -e CLAIRADAPTERVERSION=$(CLAIRADAPTERVERSION) -e VERSIONTAG=$(VERSIONTAG) \ -e BUILDBIN=$(BUILDBIN) -e REDISVERSION=$(REDISVERSION) -e MIGRATORVERSION=$(MIGRATORVERSION) \ -e CHARTMUSEUMVERSION=$(CHARTMUSEUMVERSION) -e DOCKERIMAGENAME_CHART_SERVER=$(DOCKERIMAGENAME_CHART_SERVER) \ - -e NPM_REGISTRY=$(NPM_REGISTRY) + -e NPM_REGISTRY=$(NPM_REGISTRY) -e BASEIMAGETAG=${BASEIMAGETAG} + +build_base_docker: + for name in chartserver clair chair-adapter core db jobservice log nginx notary-server notary-signer portal prepare redis registry registryctl; do \ + echo $$name ; \ + $(DOCKERBUILD) -f $(MAKEFILEPATH_PHOTON)/$$name/base.Dockerfile -t goharbor/harbor-$$name-base:$(BASEIMAGETAG) . ; \ + $(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) goharbor/harbor-$$name-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) ; \ + done install: compile build prepare start diff --git a/make/photon/Makefile b/make/photon/Makefile index 73be3c706..145f12b10 100644 --- a/make/photon/Makefile +++ b/make/photon/Makefile @@ -17,7 +17,7 @@ WGET=$(shell which wget) # docker parameters DOCKERCMD=$(shell which docker) -DOCKERBUILD=$(DOCKERCMD) build --pull +DOCKERBUILD=$(DOCKERCMD) build DOCKERRMIMAGE=$(DOCKERCMD) rmi DOCKERIMASES=$(DOCKERCMD) images @@ -81,9 +81,11 @@ DOCKERFILENAME_REGISTRYCTL=Dockerfile DOCKERIMAGENAME_REGISTRYCTL=goharbor/harbor-registryctl DOCKERFILEPATH_NOTARY=$(DOCKERFILEPATH)/notary -DOCKERFILENAME_NOTARYSIGNER=signer.Dockerfile +DOCKERFILEPATH_NOTARYSERVER=$(DOCKERFILEPATH)/notary-server +DOCKERFILENAME_NOTARYSIGNER=Dockerfile DOCKERIMAGENAME_NOTARYSIGNER=goharbor/notary-signer-photon -DOCKERFILENAME_NOTARYSERVER=server.Dockerfile +DOCKERFILEPATH_NOTARYSIGNER=$(DOCKERFILEPATH)/notary-signer +DOCKERFILENAME_NOTARYSERVER=Dockerfile DOCKERIMAGENAME_NOTARYSERVER=goharbor/notary-server-photon DOCKERFILEPATH_REDIS=$(DOCKERFILEPATH)/redis @@ -189,8 +191,8 @@ _build_notary: cd $(DOCKERFILEPATH_NOTARY) && $(DOCKERFILEPATH_NOTARY)/builder $(NOTARYVERSION) $(NOTARYMIGRATEVERSION) && cd - ; \ fi ; \ echo "building notary container for photon..."; \ - chmod 655 $(DOCKERFILEPATH_NOTARY)/binary/notary-signer && $(DOCKERBUILD) -f $(DOCKERFILEPATH_NOTARY)/$(DOCKERFILENAME_NOTARYSIGNER) -t $(DOCKERIMAGENAME_NOTARYSIGNER):$(NOTARYVERSION)-$(VERSIONTAG) . ; \ - chmod 655 $(DOCKERFILEPATH_NOTARY)/binary/notary-server && $(DOCKERBUILD) -f $(DOCKERFILEPATH_NOTARY)/$(DOCKERFILENAME_NOTARYSERVER) -t $(DOCKERIMAGENAME_NOTARYSERVER):$(NOTARYVERSION)-$(VERSIONTAG) . ; \ + chmod 655 $(DOCKERFILEPATH_NOTARY)/binary/notary-signer && $(DOCKERBUILD) -f $(DOCKERFILEPATH_NOTARYSIGNER)/$(DOCKERFILENAME_NOTARYSIGNER) -t $(DOCKERIMAGENAME_NOTARYSIGNER):$(NOTARYVERSION)-$(VERSIONTAG) . ; \ + chmod 655 $(DOCKERFILEPATH_NOTARY)/binary/notary-server && $(DOCKERBUILD) -f $(DOCKERFILEPATH_NOTARYSERVER)/$(DOCKERFILENAME_NOTARYSERVER) -t $(DOCKERIMAGENAME_NOTARYSERVER):$(NOTARYVERSION)-$(VERSIONTAG) . ; \ rm -rf $(DOCKERFILEPATH_NOTARY)/binary; \ echo "Done."; \ fi @@ -224,6 +226,23 @@ _build_migrator: echo "Done."; \ fi +set_base_image_version: + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/chartserver/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/clair/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/clair-adapter/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/core/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/db/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/jobservice/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/log/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/nginx/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/notary-server/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/notary-signer/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/portal/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/prepare/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/redis/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/registry/Dockerfile + @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/registryctl/Dockerfile + define _extract_archive $(WGET) --timeout 30 --no-check-certificate -O- $1 | tar xvz -C $2 endef @@ -232,7 +251,7 @@ define _get_binary $(WGET) --timeout 30 --no-check-certificate $1 -O $2 endef -build: _build_prepare _build_db _build_portal _build_core _build_jobservice _build_log _build_nginx _build_registry _build_registryctl _build_notary _build_clair _build_clair_adapter _build_redis _build_migrator _build_chart_server +build: set_base_image_version _build_prepare _build_db _build_portal _build_core _build_jobservice _build_log _build_nginx _build_registry _build_registryctl _build_notary _build_clair _build_clair_adapter _build_redis _build_migrator _build_chart_server cleanimage: @echo "cleaning image for photon..." diff --git a/make/photon/chartserver/Dockerfile b/make/photon/chartserver/Dockerfile index cff20a753..a8f2c6eb7 100644 --- a/make/photon/chartserver/Dockerfile +++ b/make/photon/chartserver/Dockerfile @@ -1,9 +1,4 @@ -FROM photon:2.0 - -RUN tdnf install -y shadow sudo >>/dev/null\ - && tdnf clean all \ - && groupadd -r -g 10000 chart \ - && useradd --no-log-init -m -g 10000 -u 10000 chart +FROM goharbor/harbor-chartserver-base:${harbor_base_image_version} COPY ./make/photon/chartserver/binary/chartm /home/chart/ COPY ./make/photon/chartserver/docker-entrypoint.sh /home/chart/ diff --git a/make/photon/chartserver/base.Dockerfile b/make/photon/chartserver/base.Dockerfile new file mode 100644 index 000000000..ecf7b9034 --- /dev/null +++ b/make/photon/chartserver/base.Dockerfile @@ -0,0 +1,6 @@ +FROM photon:2.0 + +RUN tdnf install -y shadow sudo >>/dev/null\ + && tdnf clean all \ + && groupadd -r -g 10000 chart \ + && useradd --no-log-init -m -g 10000 -u 10000 chart diff --git a/make/photon/clair-adapter/Dockerfile b/make/photon/clair-adapter/Dockerfile index c3f1a1ded..7e11eb4d1 100644 --- a/make/photon/clair-adapter/Dockerfile +++ b/make/photon/clair-adapter/Dockerfile @@ -1,10 +1,4 @@ -FROM photon:2.0 - -RUN tdnf install -y sudo >>/dev/null\ - && tdnf clean all \ - && mkdir /clair-adapter/ \ - && groupadd -r -g 10000 clair-adapter \ - && useradd --no-log-init -m -r -g 10000 -u 10000 clair-adapter +FROM goharbor/harbor-clair-adapter-base:${harbor_base_image_version} COPY ./make/photon/clair-adapter/binary/harbor-scanner-clair /clair-adapter/clair-adapter diff --git a/make/photon/clair-adapter/base.Dockerfile b/make/photon/clair-adapter/base.Dockerfile new file mode 100644 index 000000000..80b257f60 --- /dev/null +++ b/make/photon/clair-adapter/base.Dockerfile @@ -0,0 +1,7 @@ +FROM photon:2.0 + +RUN tdnf install -y sudo >>/dev/null\ + && tdnf clean all \ + && mkdir /clair-adapter/ \ + && groupadd -r -g 10000 clair-adapter \ + && useradd --no-log-init -m -r -g 10000 -u 10000 clair-adapter \ No newline at end of file diff --git a/make/photon/clair/Dockerfile b/make/photon/clair/Dockerfile index de172c9e8..672c67928 100644 --- a/make/photon/clair/Dockerfile +++ b/make/photon/clair/Dockerfile @@ -1,9 +1,5 @@ -FROM photon:2.0 +FROM goharbor/harbor-clair-base:${harbor_base_image_version} -RUN tdnf install -y git shadow sudo rpm xz python-xml >>/dev/null\ - && tdnf clean all \ - && groupadd -r -g 10000 clair \ - && useradd --no-log-init -m -g 10000 -u 10000 clair COPY ./make/photon/clair/binary/clair /home/clair/ COPY ./make/photon/clair/docker-entrypoint.sh /home/clair/ COPY ./make/photon/clair/dumb-init /home/clair/ diff --git a/make/photon/clair/base.Dockerfile b/make/photon/clair/base.Dockerfile new file mode 100644 index 000000000..8f9737450 --- /dev/null +++ b/make/photon/clair/base.Dockerfile @@ -0,0 +1,6 @@ +FROM photon:2.0 + +RUN tdnf install -y git shadow sudo rpm xz python-xml >>/dev/null\ + && tdnf clean all \ + && groupadd -r -g 10000 clair \ + && useradd --no-log-init -m -g 10000 -u 10000 clair \ No newline at end of file diff --git a/make/photon/core/Dockerfile b/make/photon/core/Dockerfile index 80add1701..38bc58d78 100644 --- a/make/photon/core/Dockerfile +++ b/make/photon/core/Dockerfile @@ -1,9 +1,4 @@ -FROM photon:2.0 - -RUN tdnf install sudo tzdata -y >> /dev/null \ - && tdnf clean all \ - && groupadd -r -g 10000 harbor && useradd --no-log-init -r -g 10000 -u 10000 harbor \ - && mkdir /harbor/ +FROM goharbor/harbor-core-base:${harbor_base_image_version} HEALTHCHECK CMD curl --fail -s http://127.0.0.1:8080/api/ping || exit 1 COPY ./make/photon/core/harbor_core /harbor/ diff --git a/make/photon/core/base.Dockerfile b/make/photon/core/base.Dockerfile new file mode 100644 index 000000000..db9991d27 --- /dev/null +++ b/make/photon/core/base.Dockerfile @@ -0,0 +1,6 @@ +FROM photon:2.0 + +RUN tdnf install sudo tzdata -y >> /dev/null \ + && tdnf clean all \ + && groupadd -r -g 10000 harbor && useradd --no-log-init -r -g 10000 -u 10000 harbor \ + && mkdir /harbor/ diff --git a/make/photon/db/Dockerfile b/make/photon/db/Dockerfile index e9d765393..3bf48e05f 100644 --- a/make/photon/db/Dockerfile +++ b/make/photon/db/Dockerfile @@ -1,20 +1,4 @@ -FROM photon:2.0 - -ENV PGDATA /var/lib/postgresql/data - -RUN tdnf install -y shadow gzip postgresql >> /dev/null\ - && groupadd -r postgres --gid=999 \ - && useradd -m -r -g postgres --uid=999 postgres \ - && mkdir -p /docker-entrypoint-initdb.d \ - && mkdir -p /run/postgresql \ - && chown -R postgres:postgres /run/postgresql \ - && chmod 2777 /run/postgresql \ - && mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA" \ - && sed -i "s|#listen_addresses = 'localhost'.*|listen_addresses = '*'|g" /usr/share/postgresql/postgresql.conf.sample \ - && sed -i "s|#unix_socket_directories = '/tmp'.*|unix_socket_directories = '/run/postgresql'|g" /usr/share/postgresql/postgresql.conf.sample \ - && tdnf clean all - -RUN tdnf erase -y toybox && tdnf install -y util-linux net-tools +FROM goharbor/harbor-db-base:${harbor_base_image_version} VOLUME /var/lib/postgresql/data diff --git a/make/photon/db/base.Dockerfile b/make/photon/db/base.Dockerfile new file mode 100644 index 000000000..3f8e6fdb6 --- /dev/null +++ b/make/photon/db/base.Dockerfile @@ -0,0 +1,17 @@ +FROM photon:2.0 + +ENV PGDATA /var/lib/postgresql/data + +RUN tdnf install -y shadow gzip postgresql >> /dev/null\ + && groupadd -r postgres --gid=999 \ + && useradd -m -r -g postgres --uid=999 postgres \ + && mkdir -p /docker-entrypoint-initdb.d \ + && mkdir -p /run/postgresql \ + && chown -R postgres:postgres /run/postgresql \ + && chmod 2777 /run/postgresql \ + && mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA" \ + && sed -i "s|#listen_addresses = 'localhost'.*|listen_addresses = '*'|g" /usr/share/postgresql/postgresql.conf.sample \ + && sed -i "s|#unix_socket_directories = '/tmp'.*|unix_socket_directories = '/run/postgresql'|g" /usr/share/postgresql/postgresql.conf.sample \ + && tdnf clean all + +RUN tdnf erase -y toybox && tdnf install -y util-linux net-tools diff --git a/make/photon/jobservice/Dockerfile b/make/photon/jobservice/Dockerfile index 1ee9277dd..ea18416d4 100644 --- a/make/photon/jobservice/Dockerfile +++ b/make/photon/jobservice/Dockerfile @@ -1,8 +1,4 @@ -FROM photon:2.0 - -RUN tdnf install sudo tzdata -y >> /dev/null \ - && tdnf clean all \ - && groupadd -r -g 10000 harbor && useradd --no-log-init -r -g 10000 -u 10000 harbor +FROM goharbor/harbor-jobservice-base:${harbor_base_image_version} COPY ./make/photon/jobservice/harbor_jobservice /harbor/ diff --git a/make/photon/jobservice/base.Dockerfile b/make/photon/jobservice/base.Dockerfile new file mode 100644 index 000000000..1ad223d45 --- /dev/null +++ b/make/photon/jobservice/base.Dockerfile @@ -0,0 +1,5 @@ +FROM photon:2.0 + +RUN tdnf install sudo tzdata -y >> /dev/null \ + && tdnf clean all \ + && groupadd -r -g 10000 harbor && useradd --no-log-init -r -g 10000 -u 10000 harbor diff --git a/make/photon/log/Dockerfile b/make/photon/log/Dockerfile index 6eb00bed1..f48558eab 100644 --- a/make/photon/log/Dockerfile +++ b/make/photon/log/Dockerfile @@ -1,9 +1,4 @@ -FROM photon:2.0 - -RUN tdnf install -y cronie rsyslog logrotate shadow tar gzip sudo >> /dev/null\ - && mkdir /var/spool/rsyslog \ - && groupadd -r -g 10000 syslog && useradd --no-log-init -r -g 10000 -u 10000 syslog \ - && tdnf clean all +FROM goharbor/harbor-log-base:${harbor_base_image_version} COPY ./make/photon/log/rsyslog.conf /etc/rsyslog.conf diff --git a/make/photon/log/base.Dockerfile b/make/photon/log/base.Dockerfile new file mode 100644 index 000000000..b72448130 --- /dev/null +++ b/make/photon/log/base.Dockerfile @@ -0,0 +1,6 @@ +FROM photon:2.0 + +RUN tdnf install -y cronie rsyslog logrotate shadow tar gzip sudo >> /dev/null\ + && mkdir /var/spool/rsyslog \ + && groupadd -r -g 10000 syslog && useradd --no-log-init -r -g 10000 -u 10000 syslog \ + && tdnf clean all diff --git a/make/photon/nginx/Dockerfile b/make/photon/nginx/Dockerfile index 902107205..7409e6ebf 100644 --- a/make/photon/nginx/Dockerfile +++ b/make/photon/nginx/Dockerfile @@ -1,10 +1,4 @@ -FROM photon:2.0 - -RUN tdnf install sudo nginx -y >> /dev/null\ - && tdnf clean all \ - && groupadd -r -g 10000 nginx && useradd --no-log-init -r -g 10000 -u 10000 nginx \ - && ln -sf /dev/stdout /var/log/nginx/access.log \ - && ln -sf /dev/stderr /var/log/nginx/error.log +FROM goharbor/harbor-nginx-base:${harbor_base_image_version} VOLUME /var/cache/nginx /var/log/nginx /run diff --git a/make/photon/nginx/base.Dockerfile b/make/photon/nginx/base.Dockerfile new file mode 100644 index 000000000..8982dc00e --- /dev/null +++ b/make/photon/nginx/base.Dockerfile @@ -0,0 +1,7 @@ +FROM photon:2.0 + +RUN tdnf install sudo nginx -y >> /dev/null\ + && tdnf clean all \ + && groupadd -r -g 10000 nginx && useradd --no-log-init -r -g 10000 -u 10000 nginx \ + && ln -sf /dev/stdout /var/log/nginx/access.log \ + && ln -sf /dev/stderr /var/log/nginx/error.log diff --git a/make/photon/notary/server.Dockerfile b/make/photon/notary-server/Dockerfile similarity index 74% rename from make/photon/notary/server.Dockerfile rename to make/photon/notary-server/Dockerfile index 4b0172439..aec9d6302 100644 --- a/make/photon/notary/server.Dockerfile +++ b/make/photon/notary-server/Dockerfile @@ -1,9 +1,5 @@ -FROM photon:2.0 - -RUN tdnf install -y shadow sudo \ - && tdnf clean all \ - && groupadd -r -g 10000 notary \ - && useradd --no-log-init -r -g 10000 -u 10000 notary +FROM goharbor/harbor-notary-server-base:${harbor_base_image_version} + COPY ./make/photon/notary/migrate-patch /bin/migrate-patch COPY ./make/photon/notary/binary/notary-server /bin/notary-server COPY ./make/photon/notary/binary/migrate /bin/migrate diff --git a/make/photon/notary-server/base.Dockerfile b/make/photon/notary-server/base.Dockerfile new file mode 100644 index 000000000..da4b03cbe --- /dev/null +++ b/make/photon/notary-server/base.Dockerfile @@ -0,0 +1,6 @@ +FROM photon:2.0 + +RUN tdnf install -y shadow sudo \ + && tdnf clean all \ + && groupadd -r -g 10000 notary \ + && useradd --no-log-init -r -g 10000 -u 10000 notary diff --git a/make/photon/notary/signer.Dockerfile b/make/photon/notary-signer/Dockerfile similarity index 75% rename from make/photon/notary/signer.Dockerfile rename to make/photon/notary-signer/Dockerfile index 95e98bfd8..5f80460af 100644 --- a/make/photon/notary/signer.Dockerfile +++ b/make/photon/notary-signer/Dockerfile @@ -1,9 +1,5 @@ -FROM photon:2.0 +FROM goharbor/harbor-notary-signer-base:${harbor_base_image_version} -RUN tdnf install -y shadow sudo \ - && tdnf clean all \ - && groupadd -r -g 10000 notary \ - && useradd --no-log-init -r -g 10000 -u 10000 notary COPY ./make/photon/notary/migrate-patch /bin/migrate-patch COPY ./make/photon/notary/binary/notary-signer /bin/notary-signer COPY ./make/photon/notary/binary/migrate /bin/migrate diff --git a/make/photon/notary-signer/base.Dockerfile b/make/photon/notary-signer/base.Dockerfile new file mode 100644 index 000000000..da4b03cbe --- /dev/null +++ b/make/photon/notary-signer/base.Dockerfile @@ -0,0 +1,6 @@ +FROM photon:2.0 + +RUN tdnf install -y shadow sudo \ + && tdnf clean all \ + && groupadd -r -g 10000 notary \ + && useradd --no-log-init -r -g 10000 -u 10000 notary diff --git a/make/photon/portal/Dockerfile b/make/photon/portal/Dockerfile index e7bc0279f..cc2f0dee9 100644 --- a/make/photon/portal/Dockerfile +++ b/make/photon/portal/Dockerfile @@ -22,8 +22,7 @@ RUN ls -la \ && npm run link_lib \ && node --max_old_space_size=2048 'node_modules/@angular/cli/bin/ng' build --prod - -FROM photon:2.0 +FROM goharbor/harbor-portal-base:${harbor_base_image_version} COPY --from=nodeportal /build_dir/dist /usr/share/nginx/html COPY --from=nodeportal /build_dir/swagger.yaml /usr/share/nginx/html @@ -32,13 +31,6 @@ COPY --from=nodeportal /build_dir/LICENSE /usr/share/nginx/html COPY make/photon/portal/nginx.conf /etc/nginx/nginx.conf -RUN tdnf install -y nginx sudo >> /dev/null \ - && ln -sf /dev/stdout /var/log/nginx/access.log \ - && ln -sf /dev/stderr /var/log/nginx/error.log \ - && groupadd -r -g 10000 nginx && useradd --no-log-init -r -g 10000 -u 10000 nginx \ - && chown -R nginx:nginx /etc/nginx \ - && tdnf clean all - EXPOSE 8080 VOLUME /var/cache/nginx /var/log/nginx /run diff --git a/make/photon/portal/base.Dockerfile b/make/photon/portal/base.Dockerfile new file mode 100644 index 000000000..28d4a036f --- /dev/null +++ b/make/photon/portal/base.Dockerfile @@ -0,0 +1,8 @@ +FROM photon:2.0 + +RUN tdnf install -y nginx sudo >> /dev/null \ + && ln -sf /dev/stdout /var/log/nginx/access.log \ + && ln -sf /dev/stderr /var/log/nginx/error.log \ + && groupadd -r -g 10000 nginx && useradd --no-log-init -r -g 10000 -u 10000 nginx \ + && chown -R nginx:nginx /etc/nginx \ + && tdnf clean all \ No newline at end of file diff --git a/make/photon/prepare/Dockerfile b/make/photon/prepare/Dockerfile index 58e8430c4..1afec275a 100644 --- a/make/photon/prepare/Dockerfile +++ b/make/photon/prepare/Dockerfile @@ -1,4 +1,4 @@ -FROM photon:2.0 +FROM goharbor/harbor-prepare-base:${harbor_base_image_version} ENV LANG en_US.UTF-8 @@ -6,10 +6,6 @@ WORKDIR /usr/src/app RUN mkdir -p /harbor_make -RUN tdnf install -y python3 \ - && tdnf install -y python3-pip -RUN pip3 install pipenv==2018.11.26 - COPY make/photon/prepare /usr/src/app RUN set -ex && pipenv install --deploy --system diff --git a/make/photon/prepare/base.Dockerfile b/make/photon/prepare/base.Dockerfile new file mode 100644 index 000000000..7ebe37c73 --- /dev/null +++ b/make/photon/prepare/base.Dockerfile @@ -0,0 +1,5 @@ +FROM photon:2.0 + +RUN tdnf install -y python3 \ + && tdnf install -y python3-pip +RUN pip3 install pipenv==2018.11.26 \ No newline at end of file diff --git a/make/photon/redis/Dockerfile b/make/photon/redis/Dockerfile index a90873b4b..e8e607a74 100644 --- a/make/photon/redis/Dockerfile +++ b/make/photon/redis/Dockerfile @@ -1,6 +1,4 @@ -FROM photon:2.0 - -RUN tdnf install -y redis sudo +FROM goharbor/harbor-redis-base:${harbor_base_image_version} VOLUME /var/lib/redis WORKDIR /var/lib/redis diff --git a/make/photon/redis/base.Dockerfile b/make/photon/redis/base.Dockerfile new file mode 100644 index 000000000..c670d7482 --- /dev/null +++ b/make/photon/redis/base.Dockerfile @@ -0,0 +1,3 @@ +FROM photon:2.0 + +RUN tdnf install -y redis sudo diff --git a/make/photon/registry/Dockerfile b/make/photon/registry/Dockerfile index be95e1867..c39df6a73 100644 --- a/make/photon/registry/Dockerfile +++ b/make/photon/registry/Dockerfile @@ -1,12 +1,4 @@ -FROM photon:2.0 - -LABEL maintainer="wangyan@vmware.com" - -# The original script in the docker offical registry image. -RUN tdnf install sudo -y >> /dev/null\ - && tdnf clean all \ - && mkdir -p /etc/registry \ - && groupadd -r -g 10000 harbor && useradd --no-log-init -m -g 10000 -u 10000 harbor +FROM goharbor/harbor-registry-base:${harbor_base_image_version} COPY ./make/photon/common/install_cert.sh /home/harbor COPY ./make/photon/registry/entrypoint.sh /home/harbor diff --git a/make/photon/registry/base.Dockerfile b/make/photon/registry/base.Dockerfile new file mode 100644 index 000000000..0e618e1b8 --- /dev/null +++ b/make/photon/registry/base.Dockerfile @@ -0,0 +1,6 @@ +FROM photon:2.0 + +RUN tdnf install sudo -y >> /dev/null\ + && tdnf clean all \ + && mkdir -p /etc/registry \ + && groupadd -r -g 10000 harbor && useradd --no-log-init -m -g 10000 -u 10000 harbor \ No newline at end of file diff --git a/make/photon/registryctl/Dockerfile b/make/photon/registryctl/Dockerfile index 90ad28b23..a1584ef50 100644 --- a/make/photon/registryctl/Dockerfile +++ b/make/photon/registryctl/Dockerfile @@ -1,11 +1,4 @@ -FROM photon:2.0 - -Label maintainer="wangyan@vmware.com" - -RUN tdnf install sudo -y >> /dev/null \ - && tdnf clean all \ - && groupadd -r -g 10000 harbor && useradd --no-log-init -m -g 10000 -u 10000 harbor \ - && mkdir -p /etc/registry +FROM goharbor/harbor-registryctl-base:${harbor_base_image_version} COPY ./make/photon/common/install_cert.sh /home/harbor COPY ./make/photon/registry/binary/registry /usr/bin diff --git a/make/photon/registryctl/base.Dockerfile b/make/photon/registryctl/base.Dockerfile new file mode 100644 index 000000000..0b0ad6b3b --- /dev/null +++ b/make/photon/registryctl/base.Dockerfile @@ -0,0 +1,8 @@ +FROM photon:2.0 + +Label maintainer="wangyan@vmware.com" + +RUN tdnf install sudo -y >> /dev/null \ + && tdnf clean all \ + && groupadd -r -g 10000 harbor && useradd --no-log-init -m -g 10000 -u 10000 harbor \ + && mkdir -p /etc/registry From 47793e77e34d973f9c98b2f72abd8106dceeea23 Mon Sep 17 00:00:00 2001 From: wang yan Date: Tue, 12 Nov 2019 11:20:54 +0800 Subject: [PATCH 2/2] update base file name ane pass base version to build file Signed-off-by: wang yan --- Makefile | 4 +- make/photon/Makefile | 51 +++++++------------ make/photon/chartserver/Dockerfile | 3 +- .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/clair-adapter/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/clair/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/core/Dockerfile | 1 + .../core/{base.Dockerfile => Dockerfile.base} | 0 make/photon/db/Dockerfile | 1 + .../db/{base.Dockerfile => Dockerfile.base} | 0 make/photon/jobservice/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/log/Dockerfile | 1 + .../log/{base.Dockerfile => Dockerfile.base} | 0 make/photon/nginx/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/notary-server/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/notary-signer/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/portal/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/prepare/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/redis/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/registry/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 0 make/photon/registryctl/Dockerfile | 1 + .../{base.Dockerfile => Dockerfile.base} | 2 - tests/travis/ut_install.sh | 2 +- 33 files changed, 36 insertions(+), 40 deletions(-) rename make/photon/chartserver/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/clair-adapter/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/clair/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/core/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/db/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/jobservice/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/log/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/nginx/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/notary-server/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/notary-signer/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/portal/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/prepare/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/redis/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/registry/{base.Dockerfile => Dockerfile.base} (100%) rename make/photon/registryctl/{base.Dockerfile => Dockerfile.base} (83%) diff --git a/Makefile b/Makefile index b6e285e46..5bfea4d5f 100644 --- a/Makefile +++ b/Makefile @@ -326,9 +326,9 @@ build: -e NPM_REGISTRY=$(NPM_REGISTRY) -e BASEIMAGETAG=${BASEIMAGETAG} build_base_docker: - for name in chartserver clair chair-adapter core db jobservice log nginx notary-server notary-signer portal prepare redis registry registryctl; do \ + @for name in chartserver clair clair-adapter core db jobservice log nginx notary-server notary-signer portal prepare redis registry registryctl; do \ echo $$name ; \ - $(DOCKERBUILD) -f $(MAKEFILEPATH_PHOTON)/$$name/base.Dockerfile -t goharbor/harbor-$$name-base:$(BASEIMAGETAG) . ; \ + $(DOCKERBUILD) --pull -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -t goharbor/harbor-$$name-base:$(BASEIMAGETAG) . ; \ $(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) goharbor/harbor-$$name-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) ; \ done diff --git a/make/photon/Makefile b/make/photon/Makefile index 145f12b10..593123758 100644 --- a/make/photon/Makefile +++ b/make/photon/Makefile @@ -105,32 +105,32 @@ CHART_SERVER_BIN_NAME=chartm _build_prepare: @echo "building prepare container for photon..." - @$(DOCKERBUILD) -f $(DOCKERFILEPATH_PREPARE)/$(DOCKERFILENAME_PREPARE) -t $(DOCKERIMAGENAME_PREPARE):$(VERSIONTAG) . + @$(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_PREPARE)/$(DOCKERFILENAME_PREPARE) -t $(DOCKERIMAGENAME_PREPARE):$(VERSIONTAG) . @echo "Done." _build_db: @echo "building db container for photon..." - @$(DOCKERBUILD) -f $(DOCKERFILEPATH_DB)/$(DOCKERFILENAME_DB) -t $(DOCKERIMAGENAME_DB):$(VERSIONTAG) . + @$(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_DB)/$(DOCKERFILENAME_DB) -t $(DOCKERIMAGENAME_DB):$(VERSIONTAG) . @echo "Done." _build_portal: @echo "building portal container for photon..." - $(DOCKERBUILD) --build-arg npm_registry=$(NPM_REGISTRY) -f $(DOCKERFILEPATH_PORTAL)/$(DOCKERFILENAME_PORTAL) -t $(DOCKERIMAGENAME_PORTAL):$(VERSIONTAG) . + $(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) --build-arg npm_registry=$(NPM_REGISTRY) -f $(DOCKERFILEPATH_PORTAL)/$(DOCKERFILENAME_PORTAL) -t $(DOCKERIMAGENAME_PORTAL):$(VERSIONTAG) . @echo "Done." _build_core: @echo "building core container for photon..." - @$(DOCKERBUILD) -f $(DOCKERFILEPATH_CORE)/$(DOCKERFILENAME_CORE) -t $(DOCKERIMAGENAME_CORE):$(VERSIONTAG) . + @$(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_CORE)/$(DOCKERFILENAME_CORE) -t $(DOCKERIMAGENAME_CORE):$(VERSIONTAG) . @echo "Done." _build_jobservice: @echo "building jobservice container for photon..." - @$(DOCKERBUILD) -f $(DOCKERFILEPATH_JOBSERVICE)/$(DOCKERFILENAME_JOBSERVICE) -t $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG) . + @$(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_JOBSERVICE)/$(DOCKERFILENAME_JOBSERVICE) -t $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG) . @echo "Done." _build_log: @echo "building log container for photon..." - $(DOCKERBUILD) -f $(DOCKERFILEPATH_LOG)/$(DOCKERFILENAME_LOG) -t $(DOCKERIMAGENAME_LOG):$(VERSIONTAG) . + $(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_LOG)/$(DOCKERFILENAME_LOG) -t $(DOCKERIMAGENAME_LOG):$(VERSIONTAG) . @echo "Done." _build_clair: @@ -142,7 +142,7 @@ _build_clair: cd $(DOCKERFILEPATH_CLAIR) && $(DOCKERFILEPATH_CLAIR)/builder $(CLAIRVERSION) && cd - ; \ fi ; \ echo "building clair container for photon..." ; \ - $(DOCKERBUILD) -f $(DOCKERFILEPATH_CLAIR)/$(DOCKERFILENAME_CLAIR) -t $(DOCKERIMAGENAME_CLAIR):$(CLAIRVERSION)-$(VERSIONTAG) . ; \ + $(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_CLAIR)/$(DOCKERFILENAME_CLAIR) -t $(DOCKERIMAGENAME_CLAIR):$(CLAIRVERSION)-$(VERSIONTAG) . ; \ rm -rf $(DOCKERFILEPATH_CLAIR)/binary; \ echo "Done." ; \ fi @@ -157,7 +157,7 @@ _build_clair_adapter: cd $(DOCKERFILEPATH_CLAIR_ADAPTER) && $(DOCKERFILEPATH_CLAIR_ADAPTER)/builder $(CLAIRADAPTERVERSION) && cd - ; \ fi ; \ echo "building clair adapter container for photon..." ; \ - $(DOCKERBUILD) -f $(DOCKERFILEPATH_CLAIR_ADAPTER)/$(DOCKERFILENAME_CLAIR_ADAPTER) -t $(DOCKERIMAGENAME_CLAIR_ADAPTER):$(CLAIRADAPTERVERSION)-$(VERSIONTAG) . ; \ + $(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_CLAIR_ADAPTER)/$(DOCKERFILENAME_CLAIR_ADAPTER) -t $(DOCKERIMAGENAME_CLAIR_ADAPTER):$(CLAIRADAPTERVERSION)-$(VERSIONTAG) . ; \ rm -rf $(DOCKERFILEPATH_CLAIR_ADAPTER)/binary; \ echo "Done." ; \ fi @@ -171,14 +171,14 @@ _build_chart_server: cd $(DOCKERFILEPATH_CHART_SERVER) && $(DOCKERFILEPATH_CHART_SERVER)/builder $(GOBUILDIMAGE) $(CHART_SERVER_CODE_BASE) $(CHARTMUSEUMVERSION) $(CHART_SERVER_MAIN_PATH) $(CHART_SERVER_BIN_NAME) && cd - ; \ fi ; \ echo "building chartmuseum container for photon..." ; \ - $(DOCKERBUILD) -f $(DOCKERFILEPATH_CHART_SERVER)/$(DOCKERFILENAME_CHART_SERVER) -t $(DOCKERIMAGENAME_CHART_SERVER):$(CHARTMUSEUMVERSION)-$(VERSIONTAG) . ; \ + $(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_CHART_SERVER)/$(DOCKERFILENAME_CHART_SERVER) -t $(DOCKERIMAGENAME_CHART_SERVER):$(CHARTMUSEUMVERSION)-$(VERSIONTAG) . ; \ rm -rf $(DOCKERFILEPATH_CHART_SERVER)/binary; \ echo "Done." ; \ fi _build_nginx: @echo "building nginx container for photon..." - @$(DOCKERBUILD) -f $(DOCKERFILEPATH_NGINX)/$(DOCKERFILENAME_NGINX) -t $(DOCKERIMAGENAME_NGINX):$(NGINXVERSION) . + @$(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_NGINX)/$(DOCKERFILENAME_NGINX) -t $(DOCKERIMAGENAME_NGINX):$(NGINXVERSION) . @echo "Done." _build_notary: @@ -191,8 +191,8 @@ _build_notary: cd $(DOCKERFILEPATH_NOTARY) && $(DOCKERFILEPATH_NOTARY)/builder $(NOTARYVERSION) $(NOTARYMIGRATEVERSION) && cd - ; \ fi ; \ echo "building notary container for photon..."; \ - chmod 655 $(DOCKERFILEPATH_NOTARY)/binary/notary-signer && $(DOCKERBUILD) -f $(DOCKERFILEPATH_NOTARYSIGNER)/$(DOCKERFILENAME_NOTARYSIGNER) -t $(DOCKERIMAGENAME_NOTARYSIGNER):$(NOTARYVERSION)-$(VERSIONTAG) . ; \ - chmod 655 $(DOCKERFILEPATH_NOTARY)/binary/notary-server && $(DOCKERBUILD) -f $(DOCKERFILEPATH_NOTARYSERVER)/$(DOCKERFILENAME_NOTARYSERVER) -t $(DOCKERIMAGENAME_NOTARYSERVER):$(NOTARYVERSION)-$(VERSIONTAG) . ; \ + chmod 655 $(DOCKERFILEPATH_NOTARY)/binary/notary-signer && $(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_NOTARYSIGNER)/$(DOCKERFILENAME_NOTARYSIGNER) -t $(DOCKERIMAGENAME_NOTARYSIGNER):$(NOTARYVERSION)-$(VERSIONTAG) . ; \ + chmod 655 $(DOCKERFILEPATH_NOTARY)/binary/notary-server && $(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_NOTARYSERVER)/$(DOCKERFILENAME_NOTARYSERVER) -t $(DOCKERIMAGENAME_NOTARYSERVER):$(NOTARYVERSION)-$(VERSIONTAG) . ; \ rm -rf $(DOCKERFILEPATH_NOTARY)/binary; \ echo "Done."; \ fi @@ -205,44 +205,27 @@ _build_registry: cd $(DOCKERFILEPATH_REG) && $(DOCKERFILEPATH_REG)/builder $(REGISTRY_SRC_TAG) && cd - ; \ fi @echo "building registry container for photon..." - @chmod 655 $(DOCKERFILEPATH_REG)/binary/registry && $(DOCKERBUILD) -f $(DOCKERFILEPATH_REG)/$(DOCKERFILENAME_REG) -t $(DOCKERIMAGENAME_REG):$(REGISTRYVERSION)-$(VERSIONTAG) . + @chmod 655 $(DOCKERFILEPATH_REG)/binary/registry && $(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_REG)/$(DOCKERFILENAME_REG) -t $(DOCKERIMAGENAME_REG):$(REGISTRYVERSION)-$(VERSIONTAG) . @echo "Done." _build_registryctl: @echo "building registry controller for photon..." - @$(DOCKERBUILD) -f $(DOCKERFILEPATH_REGISTRYCTL)/$(DOCKERFILENAME_REGISTRYCTL) -t $(DOCKERIMAGENAME_REGISTRYCTL):$(VERSIONTAG) . + @$(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_REGISTRYCTL)/$(DOCKERFILENAME_REGISTRYCTL) -t $(DOCKERIMAGENAME_REGISTRYCTL):$(VERSIONTAG) . @rm -rf $(DOCKERFILEPATH_REG)/binary @echo "Done." _build_redis: @echo "building redis container for photon..." - @$(DOCKERBUILD) -f $(DOCKERFILEPATH_REDIS)/$(DOCKERFILENAME_REDIS) -t $(DOCKERIMAGENAME_REDIS):$(REDISVERSION) . + @$(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_REDIS)/$(DOCKERFILENAME_REDIS) -t $(DOCKERIMAGENAME_REDIS):$(REDISVERSION) . @echo "Done." _build_migrator: @if [ "$(MIGRATORFLAG)" = "true" ] ; then \ echo "building db migrator container for photon..."; \ - cd $(DOCKERFILEPATH_MIGRATOR) && $(DOCKERBUILD) -f $(DOCKERFILEPATH_MIGRATOR)/$(DOCKERFILENAME_MIGRATOR) -t $(DOCKERIMAGENAME_MIGRATOR):$(MIGRATORVERSION) . ; \ + cd $(DOCKERFILEPATH_MIGRATOR) && $(DOCKERBUILD) --build-arg harbor_base_image_version=$(BASEIMAGETAG) -f $(DOCKERFILEPATH_MIGRATOR)/$(DOCKERFILENAME_MIGRATOR) -t $(DOCKERIMAGENAME_MIGRATOR):$(MIGRATORVERSION) . ; \ echo "Done."; \ fi -set_base_image_version: - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/chartserver/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/clair/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/clair-adapter/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/core/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/db/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/jobservice/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/log/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/nginx/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/notary-server/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/notary-signer/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/portal/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/prepare/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/redis/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/registry/Dockerfile - @$(SEDCMD) -i -e 's/\$${harbor_base_image_version}/$(BASEIMAGETAG)/' $(DOCKERFILEPATH)/registryctl/Dockerfile - define _extract_archive $(WGET) --timeout 30 --no-check-certificate -O- $1 | tar xvz -C $2 endef @@ -251,7 +234,7 @@ define _get_binary $(WGET) --timeout 30 --no-check-certificate $1 -O $2 endef -build: set_base_image_version _build_prepare _build_db _build_portal _build_core _build_jobservice _build_log _build_nginx _build_registry _build_registryctl _build_notary _build_clair _build_clair_adapter _build_redis _build_migrator _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_clair _build_clair_adapter _build_redis _build_migrator _build_chart_server cleanimage: @echo "cleaning image for photon..." diff --git a/make/photon/chartserver/Dockerfile b/make/photon/chartserver/Dockerfile index a8f2c6eb7..df7577dc9 100644 --- a/make/photon/chartserver/Dockerfile +++ b/make/photon/chartserver/Dockerfile @@ -1,4 +1,5 @@ -FROM goharbor/harbor-chartserver-base:${harbor_base_image_version} +ARG harbor_base_image_version +FROM goharbor/harbor-chartserver-base:$harbor_base_image_version COPY ./make/photon/chartserver/binary/chartm /home/chart/ COPY ./make/photon/chartserver/docker-entrypoint.sh /home/chart/ diff --git a/make/photon/chartserver/base.Dockerfile b/make/photon/chartserver/Dockerfile.base similarity index 100% rename from make/photon/chartserver/base.Dockerfile rename to make/photon/chartserver/Dockerfile.base diff --git a/make/photon/clair-adapter/Dockerfile b/make/photon/clair-adapter/Dockerfile index 7e11eb4d1..3d6df4f7d 100644 --- a/make/photon/clair-adapter/Dockerfile +++ b/make/photon/clair-adapter/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-clair-adapter-base:${harbor_base_image_version} COPY ./make/photon/clair-adapter/binary/harbor-scanner-clair /clair-adapter/clair-adapter diff --git a/make/photon/clair-adapter/base.Dockerfile b/make/photon/clair-adapter/Dockerfile.base similarity index 100% rename from make/photon/clair-adapter/base.Dockerfile rename to make/photon/clair-adapter/Dockerfile.base diff --git a/make/photon/clair/Dockerfile b/make/photon/clair/Dockerfile index 672c67928..5b7e2183a 100644 --- a/make/photon/clair/Dockerfile +++ b/make/photon/clair/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-clair-base:${harbor_base_image_version} COPY ./make/photon/clair/binary/clair /home/clair/ diff --git a/make/photon/clair/base.Dockerfile b/make/photon/clair/Dockerfile.base similarity index 100% rename from make/photon/clair/base.Dockerfile rename to make/photon/clair/Dockerfile.base diff --git a/make/photon/core/Dockerfile b/make/photon/core/Dockerfile index 38bc58d78..f0778c574 100644 --- a/make/photon/core/Dockerfile +++ b/make/photon/core/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-core-base:${harbor_base_image_version} HEALTHCHECK CMD curl --fail -s http://127.0.0.1:8080/api/ping || exit 1 diff --git a/make/photon/core/base.Dockerfile b/make/photon/core/Dockerfile.base similarity index 100% rename from make/photon/core/base.Dockerfile rename to make/photon/core/Dockerfile.base diff --git a/make/photon/db/Dockerfile b/make/photon/db/Dockerfile index 3bf48e05f..a28729e33 100644 --- a/make/photon/db/Dockerfile +++ b/make/photon/db/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-db-base:${harbor_base_image_version} VOLUME /var/lib/postgresql/data diff --git a/make/photon/db/base.Dockerfile b/make/photon/db/Dockerfile.base similarity index 100% rename from make/photon/db/base.Dockerfile rename to make/photon/db/Dockerfile.base diff --git a/make/photon/jobservice/Dockerfile b/make/photon/jobservice/Dockerfile index ea18416d4..eabfdc5ef 100644 --- a/make/photon/jobservice/Dockerfile +++ b/make/photon/jobservice/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-jobservice-base:${harbor_base_image_version} COPY ./make/photon/jobservice/harbor_jobservice /harbor/ diff --git a/make/photon/jobservice/base.Dockerfile b/make/photon/jobservice/Dockerfile.base similarity index 100% rename from make/photon/jobservice/base.Dockerfile rename to make/photon/jobservice/Dockerfile.base diff --git a/make/photon/log/Dockerfile b/make/photon/log/Dockerfile index f48558eab..3080c7ff5 100644 --- a/make/photon/log/Dockerfile +++ b/make/photon/log/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-log-base:${harbor_base_image_version} COPY ./make/photon/log/rsyslog.conf /etc/rsyslog.conf diff --git a/make/photon/log/base.Dockerfile b/make/photon/log/Dockerfile.base similarity index 100% rename from make/photon/log/base.Dockerfile rename to make/photon/log/Dockerfile.base diff --git a/make/photon/nginx/Dockerfile b/make/photon/nginx/Dockerfile index 7409e6ebf..86a344f28 100644 --- a/make/photon/nginx/Dockerfile +++ b/make/photon/nginx/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-nginx-base:${harbor_base_image_version} VOLUME /var/cache/nginx /var/log/nginx /run diff --git a/make/photon/nginx/base.Dockerfile b/make/photon/nginx/Dockerfile.base similarity index 100% rename from make/photon/nginx/base.Dockerfile rename to make/photon/nginx/Dockerfile.base diff --git a/make/photon/notary-server/Dockerfile b/make/photon/notary-server/Dockerfile index aec9d6302..a9888e6bd 100644 --- a/make/photon/notary-server/Dockerfile +++ b/make/photon/notary-server/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-notary-server-base:${harbor_base_image_version} COPY ./make/photon/notary/migrate-patch /bin/migrate-patch diff --git a/make/photon/notary-server/base.Dockerfile b/make/photon/notary-server/Dockerfile.base similarity index 100% rename from make/photon/notary-server/base.Dockerfile rename to make/photon/notary-server/Dockerfile.base diff --git a/make/photon/notary-signer/Dockerfile b/make/photon/notary-signer/Dockerfile index 5f80460af..56dfc6705 100644 --- a/make/photon/notary-signer/Dockerfile +++ b/make/photon/notary-signer/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-notary-signer-base:${harbor_base_image_version} COPY ./make/photon/notary/migrate-patch /bin/migrate-patch diff --git a/make/photon/notary-signer/base.Dockerfile b/make/photon/notary-signer/Dockerfile.base similarity index 100% rename from make/photon/notary-signer/base.Dockerfile rename to make/photon/notary-signer/Dockerfile.base diff --git a/make/photon/portal/Dockerfile b/make/photon/portal/Dockerfile index cc2f0dee9..5c343da25 100644 --- a/make/photon/portal/Dockerfile +++ b/make/photon/portal/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM node:10.15.0 as nodeportal WORKDIR /build_dir diff --git a/make/photon/portal/base.Dockerfile b/make/photon/portal/Dockerfile.base similarity index 100% rename from make/photon/portal/base.Dockerfile rename to make/photon/portal/Dockerfile.base diff --git a/make/photon/prepare/Dockerfile b/make/photon/prepare/Dockerfile index 1afec275a..f542ae357 100644 --- a/make/photon/prepare/Dockerfile +++ b/make/photon/prepare/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-prepare-base:${harbor_base_image_version} ENV LANG en_US.UTF-8 diff --git a/make/photon/prepare/base.Dockerfile b/make/photon/prepare/Dockerfile.base similarity index 100% rename from make/photon/prepare/base.Dockerfile rename to make/photon/prepare/Dockerfile.base diff --git a/make/photon/redis/Dockerfile b/make/photon/redis/Dockerfile index e8e607a74..c5202f609 100644 --- a/make/photon/redis/Dockerfile +++ b/make/photon/redis/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-redis-base:${harbor_base_image_version} VOLUME /var/lib/redis diff --git a/make/photon/redis/base.Dockerfile b/make/photon/redis/Dockerfile.base similarity index 100% rename from make/photon/redis/base.Dockerfile rename to make/photon/redis/Dockerfile.base diff --git a/make/photon/registry/Dockerfile b/make/photon/registry/Dockerfile index c39df6a73..94ef3af60 100644 --- a/make/photon/registry/Dockerfile +++ b/make/photon/registry/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-registry-base:${harbor_base_image_version} COPY ./make/photon/common/install_cert.sh /home/harbor diff --git a/make/photon/registry/base.Dockerfile b/make/photon/registry/Dockerfile.base similarity index 100% rename from make/photon/registry/base.Dockerfile rename to make/photon/registry/Dockerfile.base diff --git a/make/photon/registryctl/Dockerfile b/make/photon/registryctl/Dockerfile index a1584ef50..42cd2bec6 100644 --- a/make/photon/registryctl/Dockerfile +++ b/make/photon/registryctl/Dockerfile @@ -1,3 +1,4 @@ +ARG harbor_base_image_version FROM goharbor/harbor-registryctl-base:${harbor_base_image_version} COPY ./make/photon/common/install_cert.sh /home/harbor diff --git a/make/photon/registryctl/base.Dockerfile b/make/photon/registryctl/Dockerfile.base similarity index 83% rename from make/photon/registryctl/base.Dockerfile rename to make/photon/registryctl/Dockerfile.base index 0b0ad6b3b..c53686341 100644 --- a/make/photon/registryctl/base.Dockerfile +++ b/make/photon/registryctl/Dockerfile.base @@ -1,7 +1,5 @@ FROM photon:2.0 -Label maintainer="wangyan@vmware.com" - RUN tdnf install sudo -y >> /dev/null \ && tdnf clean all \ && groupadd -r -g 10000 harbor && useradd --no-log-init -m -g 10000 -u 10000 harbor \ diff --git a/tests/travis/ut_install.sh b/tests/travis/ut_install.sh index eb6bc1e8b..78627df86 100644 --- a/tests/travis/ut_install.sh +++ b/tests/travis/ut_install.sh @@ -19,7 +19,7 @@ sleep 2 sudo -E env "PATH=$PATH" make go_check sudo ./tests/hostcfg.sh sudo ./tests/generateCerts.sh -sudo make -f make/photon/Makefile _build_db _build_registry _build_prepare -e VERSIONTAG=dev -e REGISTRYVERSION=${REG_VERSION} +sudo make -f make/photon/Makefile _build_db _build_registry _build_prepare -e VERSIONTAG=dev -e REGISTRYVERSION=${REG_VERSION} -e BASEIMAGETAG=dev sudo MAKEPATH=$(pwd)/make ./make/prepare sudo mkdir -p "/data/redis" sudo mkdir -p /etc/core/ca/ && sudo mv ./tests/ca.crt /etc/core/ca/