Added script files for demo

This commit is contained in:
Marco Varlese 2022-09-05 13:23:56 +02:00
parent ddbb441ca1
commit 57d3c72f68
6 changed files with 260 additions and 4 deletions

View File

@ -1,12 +1,14 @@
# syntax=docker/dockerfile:1.3 # syntax=docker/dockerfile:1.3
ARG GO_VERSION=1.17 ARG BCI_MICRO=registry.suse.com/bci/bci-micro
ARG BCI_GO=registry.suse.com/bci/golang
ARG GO_VERSION=1.18
ARG GORELEASER_XX_VERSION=1.2.5 ARG GORELEASER_XX_VERSION=1.2.5
FROM crazymax/goreleaser-xx:${GORELEASER_XX_VERSION} AS goreleaser-xx FROM crazymax/goreleaser-xx:${GORELEASER_XX_VERSION} AS goreleaser-xx
FROM registry.suse.com/bci/golang:${GO_VERSION} AS base FROM ${BCI_GO}:${GO_VERSION} AS base
COPY --from=goreleaser-xx / / COPY --from=goreleaser-xx / /
RUN zypper --non-interactive install -y file git RUN zypper --non-interactive install -y file git-core
WORKDIR /src WORKDIR /src
FROM base AS build FROM base AS build
@ -40,7 +42,7 @@ COPY --from=build /out/*.sha256 /
FROM scratch AS binary FROM scratch AS binary
COPY --from=build /usr/local/bin/registry* / COPY --from=build /usr/local/bin/registry* /
FROM registry.suse.com/bci/bci-micro FROM ${BCI_MICRO}
COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
COPY --from=build /usr/local/bin/registry /bin/registry COPY --from=build /usr/local/bin/registry /bin/registry
VOLUME ["/var/lib/registry"] VOLUME ["/var/lib/registry"]

51
Dockerfile.bci.1.17 Normal file
View File

@ -0,0 +1,51 @@
# syntax=docker/dockerfile:1.3
ARG BCI_MICRO=registry.suse.com/bci/bci-micro
ARG BCI_GO=registry.suse.com/bci/golang
ARG GO_VERSION=1.17
ARG GORELEASER_XX_VERSION=1.2.5
FROM crazymax/goreleaser-xx:${GORELEASER_XX_VERSION} AS goreleaser-xx
FROM ${BCI_GO}:${GO_VERSION} AS base
COPY --from=goreleaser-xx / /
RUN zypper --non-interactive install -y file git-core
WORKDIR /src
FROM base AS build
ENV GO111MODULE=auto
ENV CGO_ENABLED=0
# GIT_REF is used by goreleaser-xx to handle the proper git ref when available.
# It will fallback to the working tree info if empty and use "git tag --points-at"
# or "git describe" to define the version info.
ARG GIT_REF
ARG TARGETPLATFORM
ARG PKG="github.com/distribution/distribution/v3"
ARG BUILDTAGS="include_oss include_gcs"
RUN --mount=type=bind,target=/src,rw \
--mount=type=cache,target=/root/.cache/go-build \
--mount=target=/go/pkg/mod,type=cache \
goreleaser-xx --debug \
--name="registry" \
--dist="/out" \
--main="./cmd/registry" \
--flags="-v" \
--ldflags="-s -w -X '$PKG/version.Version={{.Version}}' -X '$PKG/version.Revision={{.Commit}}' -X '$PKG/version.Package=$PKG'" \
--tags="$BUILDTAGS" \
--files="LICENSE" \
--files="README.md"
FROM scratch AS artifact
COPY --from=build /out/*.tar.gz /
COPY --from=build /out/*.zip /
COPY --from=build /out/*.sha256 /
FROM scratch AS binary
COPY --from=build /usr/local/bin/registry* /
FROM ${BCI_MICRO}
COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
COPY --from=build /usr/local/bin/registry /bin/registry
VOLUME ["/var/lib/registry"]
EXPOSE 5000
ENTRYPOINT ["registry"]
CMD ["serve", "/etc/docker/registry/config.yml"]

51
Dockerfile.bci.1.18 Normal file
View File

@ -0,0 +1,51 @@
# syntax=docker/dockerfile:1.3
ARG BCI_MICRO=registry.suse.com/bci/bci-micro
ARG BCI_GO=registry.suse.com/bci/golang
ARG GO_VERSION=1.18
ARG GORELEASER_XX_VERSION=1.2.5
FROM crazymax/goreleaser-xx:${GORELEASER_XX_VERSION} AS goreleaser-xx
FROM ${BCI_GO}:${GO_VERSION} AS base
COPY --from=goreleaser-xx / /
RUN zypper --non-interactive install -y file git-core
WORKDIR /src
FROM base AS build
ENV GO111MODULE=auto
ENV CGO_ENABLED=0
# GIT_REF is used by goreleaser-xx to handle the proper git ref when available.
# It will fallback to the working tree info if empty and use "git tag --points-at"
# or "git describe" to define the version info.
ARG GIT_REF
ARG TARGETPLATFORM
ARG PKG="github.com/distribution/distribution/v3"
ARG BUILDTAGS="include_oss include_gcs"
RUN --mount=type=bind,target=/src,rw \
--mount=type=cache,target=/root/.cache/go-build \
--mount=target=/go/pkg/mod,type=cache \
goreleaser-xx --debug \
--name="registry" \
--dist="/out" \
--main="./cmd/registry" \
--flags="-v" \
--ldflags="-s -w -X '$PKG/version.Version={{.Version}}' -X '$PKG/version.Revision={{.Commit}}' -X '$PKG/version.Package=$PKG'" \
--tags="$BUILDTAGS" \
--files="LICENSE" \
--files="README.md"
FROM scratch AS artifact
COPY --from=build /out/*.tar.gz /
COPY --from=build /out/*.zip /
COPY --from=build /out/*.sha256 /
FROM scratch AS binary
COPY --from=build /usr/local/bin/registry* /
FROM ${BCI_MICRO}
COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
COPY --from=build /usr/local/bin/registry /bin/registry
VOLUME ["/var/lib/registry"]
EXPOSE 5000
ENTRYPOINT ["registry"]
CMD ["serve", "/etc/docker/registry/config.yml"]

24
build_demo_1.17.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
File='Dockerfile.bci'
Version='1.17'
Port='5000'
Green='\033[1;32m'
GreenBG='\033[42m'
Nc='\033[0m' # No Color
echo ""
echo -e "${Green}Removing any cached image${Nc}"
echo -e "${GreenBG}docker system prune -a${Nc}"
#docker system prune -a -f
echo ""
echo -e "${Green}Building the distribution project..."
echo -e "${GreenBG}DOCKER_BUILDKIT=1 docker build -t distribution-${Version} -f ${File}.${Version} .${Nc}"
DOCKER_BUILDKIT=1 docker build -t distribution-${Version} -f ${File}.${Version} .
echo ""
echo -e "${Green}Running the registry...${Nc}"
echo -e "${GreenBG}docker run -p ${Port}:5000 distribution-${Version}${Nc}"
docker run -p ${Port}:5000 distribution-${Version}

24
build_demo_1.18.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
File='Dockerfile.bci'
Version='1.18'
Port='5001'
Green='\033[1;32m'
GreenBG='\033[42m'
Nc='\033[0m' # No Color
echo ""
echo -e "${Green}Removing any cached image${Nc}"
echo -e "${GreenBG}docker system prune -a${Nc}"
#docker system prune -a -f
echo ""
echo -e "${Green}Building the distribution project..."
echo -e "${GreenBG}DOCKER_BUILDKIT=1 docker build -t distribution-${Version} -f ${File} .${Nc}"
DOCKER_BUILDKIT=1 docker build -t distribution-${Version} -f ${File}.${Version} .
echo ""
echo -e "${Green}Running the registry...${Nc}"
echo -e "${GreenBG}docker run -p ${Port}:5000 distribution-${Version}${Nc}"
docker run -p ${Port}:5000 distribution-${Version}

104
run_demo.sh Executable file
View File

@ -0,0 +1,104 @@
#!/bin/sh
Port_Server_1='5000'
Port_Server_2='5001'
Green='\033[1;32m'
GreenBG='\033[42m'
Nc='\033[0m' # No Color
wait_for_key_press() {
echo "Press any key to continue"
while [ true ] ; do
read -t 3 -n 1
if [ $? = 0 ] ; then
return ;
fi
done
}
echo -e ""
echo -e "${Green}Pulling the SLE BCI busybox image from the SUSE registry${Nc}"
echo -e "${GreenBG}docker pull registry.suse.com/bci/bci-busybox${Nc}"
docker pull registry.suse.com/bci/bci-busybox
echo -e ""
echo -e ""
echo -e "${Green}Pulling the SLE BCI init image from the SUSE registry${Nc}"
echo -e "${GreenBG}docker pull registry.suse.com/bci/bci-init${Nc}"
docker pull registry.suse.com/bci/bci-init
echo -e ""
wait_for_key_press
echo -e "${Green}Retagging the image so that it can be pushed to our local registry${Nc}"
echo -e "${GreenBG}docker image tag registry.suse.com/bci/bci-busybox localhost:${Port_Server_1}/bci/bci-busybox${Nc}"
docker image tag registry.suse.com/bci/bci-busybox localhost:${Port_Server_1}/bci/bci-busybox
echo -e ""
echo -e "${Green}Retagging the image so that it can be pushed to our local registry${Nc}"
echo -e "${GreenBG}docker image tag registry.suse.com/bci/bci-init localhost:${Port_Server_2}/bci/bci-init${Nc}"
docker image tag registry.suse.com/bci/bci-busybox localhost:${Port_Server_2}/bci/bci-init
echo -e ""
wait_for_key_press
echo -e "${Green}Listing all available images to our docker instance${Nc}"
echo -e "${GreenBG}docker images -a${Nc}"
docker images -a
echo ""
wait_for_key_press
echo -e "${Green}Pushing the SLE BCI busybox image to the local registry${Nc}"
echo -e "${GreenBG}docker image push localhost:${Port_Server_1}/bci/bci-busybox${Nc}"
docker image push localhost:${Port_Server_1}/bci/bci-busybox
echo ""
echo -e "${Green}Pushing the SLE BCI init image to the local registry${Nc}"
echo -e "${GreenBG}docker image push localhost:${Port_Server_2}/bci/bci-init${Nc}"
docker image push localhost:${Port_Server_2}/bci/bci-init
echo ""
wait_for_key_press
echo -e "${Green}Removing the SLE BCI busybox image from the local docker cache${Nc}"
echo -e "${GreenBG}docker image rm localhost:${Port_Server_1}/bci/bci-busybox${Nc}"
docker image rm localhost:${Port_Server_1}/bci/bci-busybox
echo -e "${GreenBG}docker image rm registry.suse.com/bci/bci-busybox${Nc}"
docker image rm registry.suse.com/bci/bci-busybox
echo ""
echo -e "${Green}Removing the SLE BCI init image from the local docker cache${Nc}"
echo -e "${GreenBG}docker image rm localhost:${Port_Server_2}/bci/bci-init${Nc}"
docker image rm localhost:${Port_Server_2}/bci/bci-init
echo -e "${GreenBG}docker image rm registry.suse.com/bci/bci-init${Nc}"
docker image rm registry.suse.com/bci/bci-init
echo ""
wait_for_key_press
echo -e "${Green}Listing all available images to our docker instance${Nc}"
echo -e "${GreenBG}docker images -a${Nc}"
docker images -a
echo ""
wait_for_key_press
echo -e "${Green}Pulling the SLE BCI busybox image from our local registry${Nc}"
echo -e "${GreenBG}docker pull localhost:${Port_Server_1}/bci/bci-busybox${Nc}"
docker pull localhost:${Port_Server_1}/bci/bci-busybox
echo ""
echo -e "${Green}Pulling the SLE BCI init image from our local registry${Nc}"
echo -e "${GreenBG}docker pull localhost:${Port_Server_2}/bci/bci-init${Nc}"
docker pull localhost:${Port_Server_2}/bci/bci-init
echo ""
wait_for_key_press
echo -e "${Green}Listing all available images to our docker instance${Nc}"
echo -e "${GreenBG}docker images -a${Nc}"
docker images -a
echo ""
echo "That's all, folks! :)"