This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
78 lines (68 loc) · 2.81 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
FROM centos:7
LABEL maintainer="Arista Ansible Team <ansible@arista.com>"
ARG ANSIBLE=UNSET
# Install necessary packages
# Install systemd -- See https://hub.docker.com/_/centos/
RUN yum -y update; yum clean all; \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
# Install requirements.
RUN yum makecache fast \
&& yum -y install deltarpm epel-release initscripts \
&& yum -y update \
&& yum -y install \
findutils \
git \
make \
which \
python3 \
python3-pip \
rpm-build \
sudo \
zsh \
wget \
git-extras \
&& yum clean all
# Create the /project directory and add it as a mountpoint
WORKDIR /projects
VOLUME ["/projects"]
# Install python modules required by the repo
RUN wget https://raw.githubusercontent.com/aristanetworks/ansible-avd/devel/development/requirements.txt \
&& pip3 install -r requirements.txt \
&& wget https://raw.githubusercontent.com/aristanetworks/ansible-avd/devel/development/requirements-dev.txt \
&& pip3 install -r requirements-dev.txt \
&& ANSIBLE_VERSION=$(pip3 freeze | grep -e 'ansible==' | awk -F '==' '{print $2}'); \
if [ "$ANSIBLE" == "UNSET" ] || [ "$ANSIBLE_VERSION" == "$ANSIBLE" ]; \
then echo "Correct ansible version"; \
else pip3 install ansible==$ANSIBLE; fi
# Clean up
RUN yum clean all
# Make Python3 default
RUN ln -fs /usr/bin/python3 /usr/bin/python
# Create the user/group that will be used in the container
# Set some defaults that can be overridden in the build command
ARG UNAME=docker
ARG UPASS=docker
ARG UID=1000
ARG GID=1000
# Create the sudo and UNAME groups and add the sudo group to sudoers
RUN echo "%sudo ALL=(ALL:ALL) ALL" >> /etc/sudoers
RUN groupadd -r -g 1002 -o sudo
RUN groupadd -r -g $GID -o $UNAME
# Create the user, add to the sudo group, and set the password to UPASS
RUN useradd -r -m -u $UID -g $GID -G sudo -o -s /bin/bash -p $(perl -e 'print crypt($ENV{"UPASS"}, "salt")') $UNAME
# Switch to the new user for when the container is run
USER $UNAME
# Install Oh My ZSH to provide improved shell
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true
RUN echo 'plugins=(ansible common-aliases safe-paste git jsontools history git-extras)' >> $HOME/.zshrc
# Enable SSH Agent
RUN echo 'eval `ssh-agent -s`' >> $HOME/.zshrc
# Use ZSH as default shell with default oh-my-zsh theme
CMD ["/bin/zsh"]