Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify registry build #20622

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion make/photon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ _build_registry:
rm -rf $(DOCKERFILEPATH_REG)/binary && mkdir -p $(DOCKERFILEPATH_REG)/binary && \
$(call _get_binary, $(REGISTRYURL), $(DOCKERFILEPATH_REG)/binary/registry); \
else \
cd $(DOCKERFILEPATH_REG) && $(DOCKERFILEPATH_REG)/builder $(REGISTRY_SRC_TAG) $(DISTRIBUTION_SRC) && cd - ; \
$(DOCKERFILEPATH_REG)/builder $(REGISTRY_SRC_TAG) $(DISTRIBUTION_SRC) ; \
fi
@echo "building registry container for photon..."
@chmod 655 $(DOCKERFILEPATH_REG)/binary/registry && $(DOCKERBUILD_WITH_PULL_PARA) --build-arg harbor_base_image_version=$(BASEIMAGETAG) --build-arg harbor_base_namespace=$(BASEIMAGENAMESPACE) -f $(DOCKERFILEPATH_REG)/$(DOCKERFILENAME_REG) -t $(DOCKERIMAGENAME_REG):$(VERSIONTAG) .
Expand Down
10 changes: 5 additions & 5 deletions make/photon/registry/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ ARG harbor_base_image_version
ARG harbor_base_namespace
FROM ${harbor_base_namespace}/harbor-registry-base:${harbor_base_image_version}

COPY ./make/photon/common/install_cert.sh /home/harbor
COPY ./make/photon/registry/entrypoint.sh /home/harbor
COPY ./make/photon/registry/binary/registry /usr/bin/registry_DO_NOT_USE_GC

RUN chown -R harbor:harbor /etc/pki/tls/certs \
RUN --mount=type=bind,source=make/photon,target=/root \
chown -R harbor:harbor /etc/pki/tls/certs \
&& cp /root/common/install_cert.sh /home/harbor \
&& cp /root/registry/entrypoint.sh /home/harbor \
&& cp /root/registry/binary/registry /usr/bin/registry_DO_NOT_USE_GC \
&& chown harbor:harbor /home/harbor/entrypoint.sh && chmod u+x /home/harbor/entrypoint.sh \
&& chown harbor:harbor /home/harbor/install_cert.sh && chmod u+x /home/harbor/install_cert.sh \
&& chown harbor:harbor /usr/bin/registry_DO_NOT_USE_GC && chmod u+x /usr/bin/registry_DO_NOT_USE_GC
Expand Down
7 changes: 5 additions & 2 deletions make/photon/registry/Dockerfile.binary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.3
FROM golang:1.22.3 AS build

ENV DISTRIBUTION_DIR /go/src/github.com/docker/distribution
ENV BUILDTAGS include_oss include_gcs
Expand All @@ -7,4 +7,7 @@ ENV GO111MODULE auto
WORKDIR $DISTRIBUTION_DIR
COPY . $DISTRIBUTION_DIR

RUN CGO_ENABLED=0 make PREFIX=/go clean binaries
RUN CGO_ENABLED=0 make clean bin/registry

FROM scratch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PREFIX variable is not used anywhere, which leads to confusion.
Therefore, I think it is better to remove it.

COPY --from=build /go/src/github.com/docker/distribution/bin/registry /
24 changes: 6 additions & 18 deletions make/photon/registry/builder
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

set +e
set -e

if [ -z $1 ]; then
error "Please set the 'version' variable"
echo "Please set the 'version' variable"
exit 1
fi

Expand All @@ -15,36 +15,24 @@ fi
VERSION="$1"
DISTRIBUTION_SRC="$2"

set -e

# the temp folder to store binary file...
mkdir -p binary
rm -rf binary/registry || true

cd `dirname $0`
cur=$PWD

# the temp folder to store distribution source code...
TEMP=`mktemp -d ${TMPDIR-/tmp}/distribution.XXXXXX`
git clone -b $VERSION $DISTRIBUTION_SRC $TEMP
git clone -b $VERSION --depth 1 $DISTRIBUTION_SRC $TEMP

# add patch redis
cd $TEMP
git apply $cur/redis.patch
cd $cur
git apply ~-/redis.patch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it support all the linux OS versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.
It is supported by all currently used bash.

cd -

echo 'build the registry binary ...'
cp Dockerfile.binary $TEMP
docker build -f $TEMP/Dockerfile.binary -t registry-golang $TEMP

echo 'copy the registry binary to local...'
ID=$(docker create registry-golang)
docker cp $ID:/go/src/github.com/docker/distribution/bin/registry binary/registry

docker rm -f $ID
docker rmi -f registry-golang
docker build -f Dockerfile.binary -o binary/ $TEMP

echo "Build registry binary success, then to build photon image..."
cd $cur
cp $TEMP/cmd/registry/config-example.yml config.yml
rm -rf $TEMP
Loading