aboutsummaryrefslogtreecommitdiffhomepage
path: root/mini-alpine3
diff options
context:
space:
mode:
Diffstat (limited to 'mini-alpine3')
-rw-r--r--mini-alpine3/Dockerfile28
-rwxr-xr-xmini-alpine3/ansible-playbook-wrapper49
-rw-r--r--mini-alpine3/apk-list14
-rwxr-xr-xmini-alpine3/install-ansible.sh26
-rw-r--r--mini-alpine3/pip-list11
-rwxr-xr-xmini-alpine3/prepare-pkg-list.sh68
-rwxr-xr-xmini-alpine3/uninstall-ansible.sh26
7 files changed, 222 insertions, 0 deletions
diff --git a/mini-alpine3/Dockerfile b/mini-alpine3/Dockerfile
new file mode 100644
index 0000000..2287deb
--- /dev/null
+++ b/mini-alpine3/Dockerfile
@@ -0,0 +1,28 @@
1# Dockerfile for building Alpine-based image, via Ansible playbooks.
2#
3# @see https://github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md
4#
5# Version 1.0
6#
7
8
9# pull base image
10FROM alpine:3.3
11
12MAINTAINER William Yeh <william.pjyeh@gmail.com>
13
14#ENV APK_LIST apk-list
15#ENV PIP_LIST pip-list
16
17
18COPY . /tmp
19
20ONBUILD COPY . /tmp
21ONBUILD RUN \
22 cd /tmp && \
23 ./prepare-pkg-list.sh && \
24 ./install-ansible.sh && \
25 ./ansible-playbook-wrapper && \
26 ./uninstall-ansible.sh && \
27 cd / && \
28 rm -rf /tmp/*
diff --git a/mini-alpine3/ansible-playbook-wrapper b/mini-alpine3/ansible-playbook-wrapper
new file mode 100755
index 0000000..0ba45e6
--- /dev/null
+++ b/mini-alpine3/ansible-playbook-wrapper
@@ -0,0 +1,49 @@
1#!/bin/sh
2#
3# Simple wrapper for executing ansible-galaxy and ansible-playbook
4# with local connection.
5#
6# USAGE:
7# ansible-playbook-wrapper [other ansible-playbook arguments]
8#
9# ENVIRONMENT VARIABLES:
10#
11# - REQUIREMENTS: requirements filename; default = "requirements.yml"
12# - PLAYBOOK: playbook filename; default = "playbook.yml"
13# - INVENTORY: inventory filename; default = "/etc/ansible/hosts"
14#
15
16
17#
18# install Galaxy roles, if any
19#
20
21if [ -z "$REQUIREMENTS" ]; then
22 REQUIREMENTS=requirements.yml
23fi
24
25if [ -f "$REQUIREMENTS" ]; then
26 ansible-galaxy install -r $REQUIREMENTS
27fi
28
29
30#
31# execute playbook
32#
33
34if [ -z "$PLAYBOOK" ]; then
35 PLAYBOOK=playbook.yml
36fi
37
38
39if [ -z "$INVENTORY" ]; then
40 exec ansible-playbook \
41 $PLAYBOOK \
42 --connection=local \
43 "$@"
44else
45 exec ansible-playbook \
46 -i $INVENTORY $PLAYBOOK \
47 --connection=local \
48 "$@"
49fi
diff --git a/mini-alpine3/apk-list b/mini-alpine3/apk-list
new file mode 100644
index 0000000..eec27a4
--- /dev/null
+++ b/mini-alpine3/apk-list
@@ -0,0 +1,14 @@
1#
2# packages to be installed via APK;
3# lines beginning with "! " (an exclamation mark, followed by a space) will *not* be *uninstalled* afterwards.
4#
5
6
7# ssl
8openssl ca-certificates
9
10# python-runtime
11python py-pip
12
13# build-dependencies
14python-dev libffi-dev openssl-dev build-base
diff --git a/mini-alpine3/install-ansible.sh b/mini-alpine3/install-ansible.sh
new file mode 100755
index 0000000..98dede0
--- /dev/null
+++ b/mini-alpine3/install-ansible.sh
@@ -0,0 +1,26 @@
1#!/bin/sh
2#
3# Simple wrapper for installing ansible
4#
5
6
7echo "===> Adding prerequisites..."
8
9cat ___APK_INSTALL_LIST | \
10 while read ITEM; do
11 apk --update add $ITEM
12 done
13
14cat ___PIP_INSTALL_LIST | \
15 while read ITEM; do
16 pip install --upgrade $ITEM
17 done
18
19
20echo "===> Installing Ansible..."
21pip install ansible
22
23
24echo "===> Adding hosts for convenience..." && \
25mkdir -p /etc/ansible && \
26echo 'localhost' > /etc/ansible/hosts
diff --git a/mini-alpine3/pip-list b/mini-alpine3/pip-list
new file mode 100644
index 0000000..0df21dd
--- /dev/null
+++ b/mini-alpine3/pip-list
@@ -0,0 +1,11 @@
1#
2# packages to be installed via PIP;
3# lines beginning with "! " (an exclamation mark, followed by a space) will *not* be *uninstalled* afterwards.
4#
5
6
7# pip itself
8pip
9
10# for ansible
11cffi
diff --git a/mini-alpine3/prepare-pkg-list.sh b/mini-alpine3/prepare-pkg-list.sh
new file mode 100755
index 0000000..67c720d
--- /dev/null
+++ b/mini-alpine3/prepare-pkg-list.sh
@@ -0,0 +1,68 @@
1#!/bin/sh
2#
3# Prepare the list of packages to be installed/uninstalled.
4#
5# ENVIRONMENT VARIABLES:
6#
7# - APK_LIST: APK package list; default = "apk-list"
8# - PIP_LIST: PIP package list; default = "pip-list"
9#
10
11echo "===> Preparing APK package list..."
12
13if [ -z "$APK_LIST" ]; then
14 APK_LIST=apk-list
15fi
16
17if [ -f "$APK_LIST" ]; then
18
19 awk '/^#/ {next} \
20 { split($0,arrayA); \
21 for (i in arrayA) { \
22 if (arrayA[i] == "!") { continue; } \
23 print arrayA[i] \
24 } \
25 }' \
26 $APK_LIST > ___APK_INSTALL_LIST
27
28 awk '/^(#|!)/ {next} \
29 { split($0,arrayA); for (i in arrayA) print arrayA[i] }' \
30 $APK_LIST |
31 awk '{ L[n++] = $0 } \
32 END { while(n--) \
33 print L[n] }' \
34 > ___APK_UNINSTALL_LIST
35
36fi
37#cat ___APK_INSTALL_LIST
38#cat ___APK_UNINSTALL_LIST
39
40
41echo "===> Preparing PIP package list..."
42
43if [ -z "$PIP_LIST" ]; then
44 PIP_LIST=pip-list
45fi
46
47if [ -f "$PIP_LIST" ]; then
48
49 awk '/^#/ {next} \
50 { split($0,arrayA); \
51 for (i in arrayA) { \
52 if (arrayA[i] == "!") { continue; } \
53 print arrayA[i] \
54 } \
55 }' \
56 $PIP_LIST > ___PIP_INSTALL_LIST
57
58 awk '/^(#|!)/ {next} \
59 { split($0,arrayA); for (i in arrayA) print arrayA[i] }' \
60 $PIP_LIST |
61 awk '{ L[n++] = $0 } \
62 END { while(n--) \
63 print L[n] }' \
64 > ___PIP_UNINSTALL_LIST
65
66fi
67#cat ___PIP_INSTALL_LIST
68#cat ___PIP_UNINSTALL_LIST
diff --git a/mini-alpine3/uninstall-ansible.sh b/mini-alpine3/uninstall-ansible.sh
new file mode 100755
index 0000000..173c51d
--- /dev/null
+++ b/mini-alpine3/uninstall-ansible.sh
@@ -0,0 +1,26 @@
1#!/bin/sh
2#
3# Simple wrapper for uninstall ansible and related stuff.
4#
5
6
7echo "===> Removing Ansible..."
8pip uninstall -y ansible
9
10echo "===> Removing PIP packages..."
11cat ___PIP_UNINSTALL_LIST | \
12 while read ITEM; do
13 pip uninstall -y $ITEM
14 done
15
16echo "===> Removing APK packages..."
17cat ___APK_UNINSTALL_LIST | \
18 while read ITEM; do
19 apk del $ITEM
20 done
21
22
23echo "===> Cleaning up package list..."
24rm -rf /var/lib/python2.7 /usr/lib/python2.7
25rm -rf /etc/ansible /root/.ansible /root/.cache /root/.ash_history
26rm -rf /var/cache/apk