diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..f5f5e08 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,12 @@ +pipeline: + docker-build-push: + image: docker + commands: + - apk add -U git + - /bin/sh buildAndPush.sh + volumes: + - /var/run/docker.sock:/var/run/docker.sock + when: + event: push + secrets: [docker_user, docker_password] +branch: master diff --git a/ansible/Dockerfile_2.4 b/ansible/Dockerfile_2.4 new file mode 100644 index 0000000..b236b03 --- /dev/null +++ b/ansible/Dockerfile_2.4 @@ -0,0 +1,16 @@ +FROM alpine:3.7 as builder +RUN apk add -U +RUN mkdir -p /var/cache/apk && ln -s /var/cache/apk /etc/apk/cache && apk add \ + --update py2-pip gcc musl-dev python-dev libffi-dev openssl-dev make +RUN pip install wheel && pip wheel --wheel-dir=/root/wheel ansible==2.4 docker-py + +FROM alpine:3.7 as production +COPY --from=builder /root/wheel /root/wheel +COPY --from=builder /root/.cache /root/.cache +COPY --from=builder /etc/apk/cache /etc/apk/cache +RUN apk add python py2-pip docker +RUN pip install --no-index --find-links=/root/wheel ansible docker-py +RUN rm -rf /root/.cache /etc/apk/cache/* /root/wheel/ + +WORKDIR /ansible +CMD ["echo", "Execute some ansible command. Remember to mount all in the /ansible dir."] diff --git a/ansible/Dockerfile_2.5 b/ansible/Dockerfile_2.5 new file mode 100644 index 0000000..46d494f --- /dev/null +++ b/ansible/Dockerfile_2.5 @@ -0,0 +1,16 @@ +FROM alpine:3.7 as builder +RUN apk add -U +RUN mkdir -p /var/cache/apk && ln -s /var/cache/apk /etc/apk/cache && apk add \ + --update py2-pip gcc musl-dev python-dev libffi-dev openssl-dev make +RUN pip install wheel && pip wheel --wheel-dir=/root/wheel ansible==2.5 docker-py + +FROM alpine:3.7 as production +COPY --from=builder /root/wheel /root/wheel +COPY --from=builder /root/.cache /root/.cache +COPY --from=builder /etc/apk/cache /etc/apk/cache +RUN apk add python py2-pip docker +RUN pip install --no-index --find-links=/root/wheel ansible docker-py +RUN rm -rf /root/.cache /etc/apk/cache/* /root/wheel/ + +WORKDIR /ansible +CMD ["echo", "Execute some ansible command. Remember to mount all in the /ansible dir."] diff --git a/ansible/README.md b/ansible/README.md new file mode 100644 index 0000000..7493faf --- /dev/null +++ b/ansible/README.md @@ -0,0 +1,9 @@ +# Ansible + +This image will expect to find your reveal files at `/ansible`. You may want to use this function: + +``` bash +function ansible(){ + docker run -ti -v `pwd`:/ansible registry.daemons.it/ansible "$@" +} +``` diff --git a/buildAndPush.sh b/buildAndPush.sh new file mode 100755 index 0000000..f00871d --- /dev/null +++ b/buildAndPush.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +files="$(git diff HEAD~ --name-only -- '*Dockerfile*')" +write_registry="r.daemons.it" + +for file in $files +do + dockerfile="$(echo $file | sed 's/.*\///')" + docker_name="$(echo $file | sed 's/\/.*//')" + tag="$(echo $dockerfile | sed 's/.*_//')" + + # Asume that when using multiple stages, the good one is the one called + # production + docker build --target production -t $write_registry/$docker_name:$tag -t \ + $write_registry/$docker_name:latest -f $file . + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USER --password-stdin r.daemons.it + docker push $write_registry/$docker_name:$tag + docker push $write_registry/$docker_name:latest +done + +