This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile
95 lines (82 loc) · 4.11 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
FROM python:3.9.13-slim
# install tools permanently
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
make \
wget \
curl \
less \
git \
zsh \
vim \
sudo \
sshpass \
git-extras \
openssh-client \
&& rm -rf /var/lib/apt/lists/* \
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
&& apt-get clean
# install docker in docker and docker-compose
RUN curl -fsSL https://get.docker.com | sh \
&& curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose
# add AVD user
RUN useradd -md /home/avd -s /bin/zsh -u 1000 avd \
&& echo 'avd ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
# add docker and sudo to avd group
&& usermod -aG docker avd \
&& usermod -aG sudo avd
USER avd
ENV HOME=/home/avd
ENV PATH=$PATH:/home/avd/.local/bin
WORKDIR /home/avd
# install zsh
RUN wget --quiet https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true \
&& echo 'PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"' >> ${HOME}/.zshrc \
&& echo 'PROMPT+=" %{$fg[blue]%}(%{$fg[red]%}A%{$fg[green]%}V%{$fg[blue]%}D 🐳%{$fg[blue]%})%{$reset_color%}"' >> ${HOME}/.zshrc \
&& echo 'PROMPT+=" %{$fg[cyan]%}%c%{$reset_color%}"' >> ${HOME}/.zshrc \
&& echo "PROMPT+=' \$(git_prompt_info)'" >> ${HOME}/.zshrc \
&& echo 'plugins=(ansible common-aliases safe-paste git jsontools history git-extras)' >> ${HOME}/.zshrc \
# redirect to &>/dev/null is required to silence `agent pid XXXX` message from ssh-agent
&& echo 'eval `ssh-agent -s` &>/dev/null' >> ${HOME}/.zshrc \
&& echo 'export TERM=xterm-256color' >> $HOME/.zshrc \
&& echo "export LC_ALL=C.UTF-8" >> $HOME/.zshrc \
&& echo "export LANG=C.UTF-8" >> $HOME/.zshrc \
&& echo 'export PATH=$PATH:/home/avd/.local/bin' >> $HOME/.zshrc
# ^ ^ ^
# | | | The section above usually remains unchanged between releases
# | | | The section below will be updated for every release
# V V V
# add entrypoint script
COPY ./entrypoint.sh /bin/entrypoint.sh
RUN sudo chmod +x /bin/entrypoint.sh
# use ENTRYPOINT instead of CMD to ensure that entryscript is always executed
ENTRYPOINT [ "/bin/entrypoint.sh" ]
# add AVD gitconfig to be used if container is not called as VScode devcontainer
COPY ./gitconfig /home/avd/gitconfig-avd-base-template
# change this for every release
ARG _AVD_VERSION
ARG _CVP_VERSION
ARG _RELEASE_DATE
# labels to be changed for every release
LABEL maintainer="Arista Ansible Team <[email protected]>"
LABEL com.example.version="avd${_AVD_VERSION}_cvp${_CVP_VERSION}"
LABEL vendor1="Arista"
LABEL com.example.release-date=${_RELEASE_DATE}
LABEL com.example.version.is-production="False"
LABEL org.opencontainers.image.description="Ansible AVD all-in-one container, AVD version ${_AVD_VERSION}, CVP version ${_CVP_VERSION}"
# install ansible.cvp, ansible.avd collections and their requirements
# ansible.avd pip requirements are superior, ansible.cvp requirements will be ignored
RUN wget --quiet https://raw.githubusercontent.com/aristanetworks/ansible-avd/v${_AVD_VERSION}/ansible_collections/arista/avd/requirements.txt \
&& wget --quiet https://raw.githubusercontent.com/aristanetworks/ansible-avd/v${_AVD_VERSION}/ansible_collections/arista/avd/requirements-dev.txt \
&& pip3 install "ansible-core>=2.13.1,<2.14.0" \
&& pip3 install --user --no-cache-dir -r requirements.txt \
&& pip3 install --user --no-cache-dir -r requirements-dev.txt \
# install ansible.cvp first to control version explicitely without installing dependencies
&& ansible-galaxy collection install arista.cvp:==${_CVP_VERSION} --no-deps \
# install ansible.avd and it's dependencies, ansible.cvp will not be installed as it already exists
&& ansible-galaxy collection install arista.avd:==${_AVD_VERSION} \
# install community.general to support callback plugins in ansible.cfg, etc.
&& ansible-galaxy collection install community.general
# if not running as VScode devcontainer, start in projects
WORKDIR /home/avd/projects