add base images when to build harbor assets

* add base images when to build harbor assets

Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
Wang Yan 2019-11-11 18:56:36 +08:00 committed by wang yan
parent a287605646
commit 544cc98971
32 changed files with 153 additions and 111 deletions

View File

@ -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

View File

@ -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..."

View File

@ -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/

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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/

View File

@ -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

View File

@ -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/

View File

@ -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/

View File

@ -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

View File

@ -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

View File

@ -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/

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,3 @@
FROM photon:2.0
RUN tdnf install -y redis sudo

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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