Skip to content

Instantly share code, notes, and snippets.

@Shaked
Last active October 28, 2021 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shaked/fc56c79e83b418cd085dca20c8f2f188 to your computer and use it in GitHub Desktop.
Save Shaked/fc56c79e83b418cd085dca20c8f2f188 to your computer and use it in GitHub Desktop.
Kubernetes continuous integration using BuildKit, buildx and docker regisrty
apiVersion: v1
kind: ConfigMap
data:
buildkitd.toml: |
debug = true
root = "/var/lib/buildkit"
# see https://github.com/docker/buildx/issues/516#issuecomment-771236525
[registry."{{ .Values.localRegistryMirror }}"]
http = true
insecure = true
[registry."{{ .Values.acrRegistryMirror }}"]
http = true
insecure = true
[registry."{{ .Values.gcrRegistryMirror }}"]
http = true
insecure = true
[registry."{{ .Values.localRegistryUrl }}"]
mirrors = ["{{ .Values.localRegistryMirror }}"]
[registry."{{ .Values.acrRegistryUrl }}"]
mirrors = ["{{ .Values.acrRegistryMirror }}"]
[registry."{{ .Values.gcrRegistryUrl }}"]
mirrors = ["{{ .Values.gcrRegistryMirror }}"]
kind: ConfigMap
metadata:
name: buildkitd-cm
if [ $ENABLE_BUILDX_K8S_BUILDER ]; then
docker buildx create \
--driver kubernetes \
--driver-opt replicas=1,namespace=$BUILDX_K8S_BUILDER_NAMESPACE \
--name $BUILDX_K8S_BUILDER_NAME \
--node $BUILDX_K8S_BUILDER_NODE \
--platform $BUILDX_K8S_BUILDER_PLATFORMS \
--use 2>&1
fi
#!/bin/bash
# Cleanup - make sure to allow "Continue on error" under Control Options in Azure DevOps
podman rm -f mysql
podman rm -f images-repo-test
podman network rm -f int
# Build image for tests
$(buildxExec) -t $(ciTestImage) . \
-f Dockerfile-test \
--build-arg INDEX_URL=$(artifactUrl) \
--build-arg SITE_PACKAGES=$(sitePackages) \
--push
# Run MySQL
IMAGE=$(ciTestImage)
podman network create int
podman run -v /mnt/citests/:/mnt/pod \
--network int \
--env MYSQL_DATABASE="mock_context_db" \
--env MYSQL_USER="user" \
--env MYSQL_PASSWORD="pass" \
--env MYSQL_ALLOW_EMPTY_PASSWORD=""yes"" \
--name mysql -d mysql:5.7
# Validate MySQL health
podman exec -it mysql /bin/bash -c 'while ! mysqladmin ping \
--silent; do sleep 1; done'
# Run tests
podman run \
--network int \
-p "5000:5000" \
--name images-repo-test \
-v ./test/integration/repo:/etc/images-repo \
-v /mnt/citests:/var/repo/test-reports $IMAGE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment