-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
138 lines (109 loc) · 3.04 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
FROM alpine:3.14.8
##
## PowerShell 7.3.0
## Verity the supported Alpine version. As of Dec 2022, only Alpine 3.14 is
## supported for PowerShell 7.3.0.
## https://docs.microsoft.com/en-us/powershell/scripting/install/install-alpine?view=powershell-7.2
##
ENV PWSH_PATH /opt/microsoft/powershell/7
ENV PWSH_VERSION 7.3.0
# Install the PowerShell dependencies
RUN apk add --no-cache \
ca-certificates \
less \
ncurses-terminfo-base \
krb5-libs \
libgcc \
libintl \
libssl1.1 \
libstdc++ \
tzdata \
userspace-rcu \
zlib \
icu-libs \
curl
RUN apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache \
lttng-ust
# Download and install (extract) PowerShell
RUN mkdir -p $PWSH_PATH \
&& curl -L https://github.com/PowerShell/PowerShell/releases/download/v$PWSH_VERSION/powershell-$PWSH_VERSION-linux-alpine-x64.tar.gz -o /tmp/powershell.tar.gz \
&& tar zxf /tmp/powershell.tar.gz -C $PWSH_PATH \
&& rm /tmp/powershell.tar.gz
# Include PowerShell in the path as executable
RUN chmod +x $PWSH_PATH/pwsh
RUN ln -s $PWSH_PATH/pwsh /usr/bin/pwsh
##
## Ansible 6.2.0
## https://github.com/jmal98/ansiblecm/blob/master/Dockerfile
##
# Ansible dependencies based on the jmal98 repo
RUN apk add --no-cache \
bzip2 \
file \
gzip \
libffi \
libffi-dev \
krb5 \
krb5-dev \
krb5-libs \
musl-dev \
openssh \
openssl-dev \
python3-dev=3.9.15-r0 \
py3-cffi \
py3-cryptography=3.3.2-r1 \
py3-setuptools=52.0.0-r3 \
sshpass \
tar
# Dependencies for the build process, removed later
RUN apk add --no-cache --virtual build-dependencies \
gcc \
make
# Bootstrapping for the pip installer
RUN python3 -m ensurepip --upgrade
# Install ansible and all required python modules
RUN pip3 install \
ansible==6.2.0 \
botocore==1.23.1 \
boto==2.49.0 \
PyYAML==5.4.1 \
boto3==1.20.0 \
awscli==1.22.1 \
pywinrm[kerberos]==0.4.2
# Cleanup
RUN apk del build-dependencies \
&& rm -rf /root/.cache
# Ansible working directory
RUN mkdir /ansible
WORKDIR /ansible
VOLUME [ "/ansible" ]
##
## SSH Setup
##
# Add OpenSSH and the dos2unix (convert Windows line endings to linux line
# endings for the ssh key files)
RUN apk add --no-cache \
openssh \
dos2unix
# Volume for the SSH key mount, will be copied to ~/.ssh by the entrypoint
# script, because the permissions must be fixed if mounted on a Windows hosts.
VOLUME [ "/tmp/.ssh" ]
##
## Ansible Customization
##
ENV ANSIBLE_CONFIG /ansible/ansible.cfg
ENV ANSIBLE_LIBRARY /ansible/library
##
## Startup and Shell
##
# Install the bash shell
RUN apk add --no-cache \
bash
# Customize bash prompt
ENV PS1="\[\033[01;32m\]ansible-control-node\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
# Ensure the bash history and ssh known hosts files exists for mounting
RUN touch ~/.bash_history
# Embedd and set the entrypoint script
COPY ./scripts/docker-entrypoint.sh /bin/docker-entrypoint.sh
RUN chmod +x /bin/docker-entrypoint.sh
ENTRYPOINT ["/bin/docker-entrypoint.sh", "bash"]