commit f124c47d34504a0d6930fc2119e848a78381d089 Author: James Brumond Date: Sun Sep 18 18:47:53 2022 -0700 copy files over to example repo diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..bb677e6 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,47 @@ +--- +kind: pipeline +type: kubernetes +name: build + +trigger: + event: [ push ] + branch: [ master ] + +steps: +- name: build + # See: https://plugins.drone.io/plugins/docker + image: plugins/docker + settings: + registry: https://docker.internal.example.com + username: drone + password: + from_secret: docker-internal-password + repo: docker.internal.example.com/docker + cache_from: docker.internal.example.com/docker:ci + build_args: ARCH=arm64 + tags: + - "ci" + +--- +kind: pipeline +type: kubernetes +name: publish + +trigger: + event: [ promote ] + target: [ publish ] + +steps: +- name: build-and-publish + # See: https://plugins.drone.io/plugins/docker + image: plugins/docker + settings: + registry: https://docker.internal.example.com + username: drone + password: + from_secret: docker-internal-password + repo: docker.internal.example.com/docker + cache_from: docker.internal.example.com/docker:ci + build_args: ARCH=arm64 + tags: + - "latest" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e274139 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ + +FROM alpine:3.14 + +ENV DOCKER_HOST=unix:///var/run/docker.sock + +RUN apk --no-cache add --update docker openrc bash +RUN rc-update add docker boot + +COPY docker-setup /bin/ +RUN chmod +x /bin/docker-setup + +COPY docker-remote-tag /bin/ +RUN chmod +x /bin/docker-remote-tag + +CMD [ "/bin/docker-setup" ] +ENTRYPOINT [ "/bin/bash", "-l", "-c" ] diff --git a/docker-remote-tag b/docker-remote-tag new file mode 100644 index 0000000..ef94218 --- /dev/null +++ b/docker-remote-tag @@ -0,0 +1,17 @@ +#!/bin/bash + +# Tags an already existing image version in a remote registry without needing to pull/push the whole image +# +# Usage: +# /bin/docker-remote-tag +# + +REPOSITORY="$1" +TAG_OLD="$2" +TAG_NEW="$3" + +CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" + +MANIFEST=$(curl -H "Accept: ${CONTENT_TYPE}" "${DOCKER_REGISTRY}/v2/${REPOSITORY}/manifests/${TAG_OLD}") + +curl -X PUT -H "Content-Type: ${CONTENT_TYPE}" -d "${MANIFEST}" "${DOCKER_REGISTRY}/v2/${REPOSITORY}/manifests/${TAG_NEW}" diff --git a/docker-setup b/docker-setup new file mode 100644 index 0000000..d2be947 --- /dev/null +++ b/docker-setup @@ -0,0 +1,3 @@ +#!/bin/bash + +docker login --username "${DOCKER_USER}" --password "${DOCKER_PASS}" "${DOCKER_REGISTRY}" diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..fe6bce8 --- /dev/null +++ b/readme.md @@ -0,0 +1,32 @@ + +## `docker` image + +An `alpine` image with `docker` installed + +See https://blog.jbrumond.me/post/raspberry-pi-cluster-part-4:-gitea-and-drone for more info + + + +### Drone CI Usage + +```yaml +steps: +- name: deploy + image: docker.internal.example.com/docker + volumes: + - name: dockersock + path: /var/run/ + environment: + DOCKER_REGISTRY: https://docker.internal.example.com + DOCKER_USER: drone + DOCKER_PASS: + from_secret: docker-internal-password + commands: + - /bin/docker-setup + - docker tag ... + - docker push ... +volumes: +- name: dockersock + host: + path: /var/run/ +```