diff --git a/Makefile b/Makefile index 0276fb9c0..e85593758 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 clair-adapter core db jobservice log nginx notary-server notary-signer portal prepare redis registry registryctl; do \ + echo $$name ; \ + $(DOCKERBUILD) --pull -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -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..593123758 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 @@ -103,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: @@ -140,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 @@ -155,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 @@ -169,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: @@ -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) --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 @@ -203,24 +205,24 @@ _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 diff --git a/make/photon/chartserver/Dockerfile b/make/photon/chartserver/Dockerfile index cff20a753..df7577dc9 100644 --- a/make/photon/chartserver/Dockerfile +++ b/make/photon/chartserver/Dockerfile @@ -1,9 +1,5 @@ -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 +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/Dockerfile.base b/make/photon/chartserver/Dockerfile.base new file mode 100644 index 000000000..ecf7b9034 --- /dev/null +++ b/make/photon/chartserver/Dockerfile.base @@ -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..3d6df4f7d 100644 --- a/make/photon/clair-adapter/Dockerfile +++ b/make/photon/clair-adapter/Dockerfile @@ -1,10 +1,5 @@ -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 +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/Dockerfile.base b/make/photon/clair-adapter/Dockerfile.base new file mode 100644 index 000000000..80b257f60 --- /dev/null +++ b/make/photon/clair-adapter/Dockerfile.base @@ -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..5b7e2183a 100644 --- a/make/photon/clair/Dockerfile +++ b/make/photon/clair/Dockerfile @@ -1,9 +1,6 @@ -FROM photon:2.0 +ARG harbor_base_image_version +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/Dockerfile.base b/make/photon/clair/Dockerfile.base new file mode 100644 index 000000000..8f9737450 --- /dev/null +++ b/make/photon/clair/Dockerfile.base @@ -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..f0778c574 100644 --- a/make/photon/core/Dockerfile +++ b/make/photon/core/Dockerfile @@ -1,9 +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 \ - && mkdir /harbor/ +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 COPY ./make/photon/core/harbor_core /harbor/ diff --git a/make/photon/core/Dockerfile.base b/make/photon/core/Dockerfile.base new file mode 100644 index 000000000..db9991d27 --- /dev/null +++ b/make/photon/core/Dockerfile.base @@ -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..a28729e33 100644 --- a/make/photon/db/Dockerfile +++ b/make/photon/db/Dockerfile @@ -1,20 +1,5 @@ -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 +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/Dockerfile.base b/make/photon/db/Dockerfile.base new file mode 100644 index 000000000..3f8e6fdb6 --- /dev/null +++ b/make/photon/db/Dockerfile.base @@ -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..eabfdc5ef 100644 --- a/make/photon/jobservice/Dockerfile +++ b/make/photon/jobservice/Dockerfile @@ -1,8 +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 +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/Dockerfile.base b/make/photon/jobservice/Dockerfile.base new file mode 100644 index 000000000..1ad223d45 --- /dev/null +++ b/make/photon/jobservice/Dockerfile.base @@ -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..3080c7ff5 100644 --- a/make/photon/log/Dockerfile +++ b/make/photon/log/Dockerfile @@ -1,9 +1,5 @@ -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 +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/Dockerfile.base b/make/photon/log/Dockerfile.base new file mode 100644 index 000000000..b72448130 --- /dev/null +++ b/make/photon/log/Dockerfile.base @@ -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..86a344f28 100644 --- a/make/photon/nginx/Dockerfile +++ b/make/photon/nginx/Dockerfile @@ -1,10 +1,5 @@ -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 +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/Dockerfile.base b/make/photon/nginx/Dockerfile.base new file mode 100644 index 000000000..8982dc00e --- /dev/null +++ b/make/photon/nginx/Dockerfile.base @@ -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..a9888e6bd 100644 --- a/make/photon/notary/server.Dockerfile +++ b/make/photon/notary-server/Dockerfile @@ -1,9 +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 +ARG harbor_base_image_version +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/Dockerfile.base b/make/photon/notary-server/Dockerfile.base new file mode 100644 index 000000000..da4b03cbe --- /dev/null +++ b/make/photon/notary-server/Dockerfile.base @@ -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..56dfc6705 100644 --- a/make/photon/notary/signer.Dockerfile +++ b/make/photon/notary-signer/Dockerfile @@ -1,9 +1,6 @@ -FROM photon:2.0 +ARG harbor_base_image_version +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/Dockerfile.base b/make/photon/notary-signer/Dockerfile.base new file mode 100644 index 000000000..da4b03cbe --- /dev/null +++ b/make/photon/notary-signer/Dockerfile.base @@ -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..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 @@ -22,8 +23,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 +32,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/Dockerfile.base b/make/photon/portal/Dockerfile.base new file mode 100644 index 000000000..28d4a036f --- /dev/null +++ b/make/photon/portal/Dockerfile.base @@ -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..f542ae357 100644 --- a/make/photon/prepare/Dockerfile +++ b/make/photon/prepare/Dockerfile @@ -1,4 +1,5 @@ -FROM photon:2.0 +ARG harbor_base_image_version +FROM goharbor/harbor-prepare-base:${harbor_base_image_version} ENV LANG en_US.UTF-8 @@ -6,10 +7,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/Dockerfile.base b/make/photon/prepare/Dockerfile.base new file mode 100644 index 000000000..7ebe37c73 --- /dev/null +++ b/make/photon/prepare/Dockerfile.base @@ -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..c5202f609 100644 --- a/make/photon/redis/Dockerfile +++ b/make/photon/redis/Dockerfile @@ -1,6 +1,5 @@ -FROM photon:2.0 - -RUN tdnf install -y redis sudo +ARG harbor_base_image_version +FROM goharbor/harbor-redis-base:${harbor_base_image_version} VOLUME /var/lib/redis WORKDIR /var/lib/redis diff --git a/make/photon/redis/Dockerfile.base b/make/photon/redis/Dockerfile.base new file mode 100644 index 000000000..c670d7482 --- /dev/null +++ b/make/photon/redis/Dockerfile.base @@ -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..94ef3af60 100644 --- a/make/photon/registry/Dockerfile +++ b/make/photon/registry/Dockerfile @@ -1,12 +1,5 @@ -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 +ARG harbor_base_image_version +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/Dockerfile.base b/make/photon/registry/Dockerfile.base new file mode 100644 index 000000000..0e618e1b8 --- /dev/null +++ b/make/photon/registry/Dockerfile.base @@ -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..42cd2bec6 100644 --- a/make/photon/registryctl/Dockerfile +++ b/make/photon/registryctl/Dockerfile @@ -1,11 +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 \ - && mkdir -p /etc/registry +ARG harbor_base_image_version +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/Dockerfile.base b/make/photon/registryctl/Dockerfile.base new file mode 100644 index 000000000..c53686341 --- /dev/null +++ b/make/photon/registryctl/Dockerfile.base @@ -0,0 +1,6 @@ +FROM photon:2.0 + +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 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/