Add ansible dockerfile

Plus the drone.yml file
This commit is contained in:
drymer 2018-07-21 23:08:02 +02:00
parent 097155f71b
commit 6287612281
Signed by: drymer
GPG Key ID: A307D64D5DDFDAAD
5 changed files with 74 additions and 0 deletions

12
.drone.yml Normal file
View File

@ -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

16
ansible/Dockerfile_2.4 Normal file
View File

@ -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."]

16
ansible/Dockerfile_2.5 Normal file
View File

@ -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."]

9
ansible/README.md Normal file
View File

@ -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 "$@"
}
```

21
buildAndPush.sh Executable file
View File

@ -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