-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
base: main
Are you sure you want to change the base?
Simplify registry build #20622
Changes from 1 commit
64956e3
c0c2265
584df97
28a35ba
8578deb
e611f70
13121ec
0628ea5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this change needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
COPY --from=build /go/src/github.com/docker/distribution/bin/registry / |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,32 @@ | ||
#!/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 | ||
|
||
VERSION="$1" | ||
|
||
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 https://github.com/distribution/distribution.git $TEMP | ||
git clone -b $VERSION --depth 1 https://github.com/distribution/distribution.git $TEMP | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is it necessary to specify the depth here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
|
||
# add patch redis | ||
cd $TEMP | ||
git apply $cur/redis.patch | ||
cd $cur | ||
git apply ~-/redis.patch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it support all the linux OS versions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean the builder script cannot be executed in the location of $(DOCKERFILEPATH_REG)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
The builder script can be executed in the location of
$(DOCKERFILEPATH_REG)
, but it also can be executed in any other location, so it need not to cd to$(DOCKERFILEPATH_REG)
.