Skip to content

Commit

Permalink
upgrade community.docker
Browse files Browse the repository at this point in the history
ansible-galaxy collection install community.docker
  • Loading branch information
HillLiu committed Feb 19, 2024
1 parent ace3722 commit 6111026
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
38 changes: 29 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@ version: 2.1
commands:
install-docker-buildx:
description: Install Docker Buildx
parameters:
docker-tag:
type: string
buildx-version:
type: string
default: v0.12.0
steps:
- run:
name: Install package
command: sudo apt-get update && sudo apt-get install -qq -y --no-install-recommends binfmt-support qemu-user-static
- run:
name: Init VM
command: |
docker context create CIContext
docker run --rm --privileged tonistiigi/binfmt --install arm64
- run:
name: Install Docker Buildx
command: |
mkdir -vp ~/.docker/cli-plugins/
curl --silent -L "https://github.com/docker/buildx/releases/download/v0.10.4/buildx-v0.10.4.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
curl --silent -L "https://github.com/docker/buildx/releases/download/<< parameters.buildx-version >>/buildx-<< parameters.buildx-version >>.linux-arm64" > ~/.docker/cli-plugins/docker-buildx
chmod a+x ~/.docker/cli-plugins/docker-buildx
docker buildx version
sudo apt-get update && sudo apt-get install -y binfmt-support qemu-user-static
docker run --rm --privileged tonistiigi/binfmt --install arm64
docker context create buildcontext
docker buildx create buildcontext --use
docker buildx create --name joyful-<< parameters.docker-tag >>- --append CIContext --use
executors:
docker-publisher:
Expand All @@ -29,7 +39,6 @@ jobs:
steps:
- checkout
- setup_remote_docker:
version: 20.10.18
docker_layer_caching: true
- run:
name: "Test with terratest"
Expand All @@ -46,11 +55,13 @@ jobs:
steps:
- checkout
- setup_remote_docker:
version: 20.10.18
docker_layer_caching: true
- run:
name: Log time
command: date
- run:
name: Get Rate Limit
command: ./compile.sh rate
- run:
name: Gen Docker file
command: |
Expand All @@ -68,7 +79,8 @@ jobs:
cat ${BUILD_FOLDER}/$file
echo ""
done
- install-docker-buildx
- install-docker-buildx:
docker-tag: << parameters.docker-tag >>
- run:
name: login
command: ./compile.sh login
Expand All @@ -90,9 +102,17 @@ jobs:
LATEST_TAG="-t $IMAGE_NAME:latest"
fi
echo "Build ARGS: ${BUILD_ARG}"
docker pull $IMAGE_NAME:${BUILD_VERSION} || true
docker buildx inspect --bootstrap
echo "# ------ Start to Login ------ #"
./compile.sh login
./compile.sh rate
echo "# ------ End to Login ------ #"
docker buildx build ${BUILD_ARG} -f ${BUILD_FOLDER}/Dockerfile \
--cache-to=type=inline,mode=all \
--cache-from $IMAGE_NAME:${BUILD_VERSION} \
--push \
--progress=plain \
--platform linux/amd64,linux/arm64/v8 \
-t $IMAGE_NAME:${BUILD_VERSION} ${LATEST_TAG} \
./${BUILD_FOLDER}
Expand Down
11 changes: 11 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ updateDockerHubDesc() {
echo $RESULT
}

getRateLimit() {
# https://docs.docker.com/docker-hub/download-rate-limit/
token=$(curl -s --user "${DOCKER_LOGIN}:${DOCKER_PASSWORD}" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl -s -I \
-H "Authorization: Bearer $token" \
"https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" | grep "ratelimit-"
}

push() {
login
PUSH_VERSION=${1:-$VERSION}
Expand Down Expand Up @@ -147,6 +155,9 @@ case "$1" in
updateDockerHubDesc)
updateDockerHubDesc
;;
rate)
getRateLimit
;;
p)
push $2 $3
;;
Expand Down
3 changes: 3 additions & 0 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

```
docker run --rm -u $(id -u):$(id -g) -it -v $(pwd):/app hillliu/ansible ansible-playbook --version
ansible-galaxy collection list
ansible --version
```

## Explore more Doc from command
Expand Down
3 changes: 3 additions & 0 deletions install-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ pip3 install -U \
molecule \
'molecule[docker]' || exit 2

# Install new ansible module
ansible-galaxy collection install community.docker

apk del -f .build-deps && rm -rf /var/cache/apk/* || exit 1

exit 0

0 comments on commit 6111026

Please sign in to comment.