Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to base off of 'python:2.7.14-alpine3.6' instead of just 'alpine:3.6' #55

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,33 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FROM grpn/ansible-silo-base:2.0.1
FROM grpn/ansible-silo-base:3.0.0

ENV ANSIBLE_VERSION v2.4.2.0-1
ENV ANSIBLE_LINT_VERSION 3.4.20
ENV SILO_IMAGE grpn/ansible-silo

ADD silo /silo/

# Install pip modules from requirements file
ADD pip/requirements /tmp/pip-requirements.txt
RUN pip install -r /tmp/pip-requirements.txt

# Installing Ansible from source
RUN git clone --progress https://github.com/ansible/ansible.git /silo/userspace/ansible 2>&1 &&\
cd /silo/userspace/ansible &&\
git checkout --force ${ANSIBLE_VERSION} 2>&1 &&\
git submodule update --init --recursive 2>&1 &&\
git submodule update --init --recursive 2>&1

# Install pip modules from requirements file
ADD pip/requirements /tmp/pip-requirements.txt
RUN pip install -r /tmp/pip-requirements.txt

# Create directory for storing ssh ControlPath
mkdir -p /home/user/.ssh/tmp &&\
RUN mkdir -p /home/user/.ssh/tmp &&\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe moving the lines around and splitting into separate layers was beneficial during development/experimenting to speed up builds. Is there a need for this to be merged? The number of layers should be as small as possible.


# Give the user a custom shell prompt
echo 'export PS1="[ansible-silo $SILO_VERSION|\w]\\$ "' > /home/user/.bashrc &&\

# Add alias for 'ls -l'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to not have this. Instead we should provide a way for the user to mount a custom profile so any alias, function or what not can be set up as required. Something for another PR I can take care of.

echo "alias ll='ls -l'" >> /home/user/.bashrc &&\

# Set default control path in ssh config
echo "ControlPath /home/user/.ssh/tmp/%h_%p_%r" > /etc/ssh/ssh_config &&\

Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ SILO_IMG := grpn/ansible-silo
SILO_VERSION := $(shell cat VERSION)

BASE_IMG := grpn/ansible-silo-base
BASE_VERSION := 2.0.1
BASE_VERSION := 3.0.0

ansible-silo: validate-version
@docker build --build-arg "v=$(SILO_VERSION)" --tag "${SILO_IMG}:$(SILO_VERSION)" .
@echo ""
@echo "To install '${SILO_IMG}:${SILO_VERSION}' for just your user, run the following command:"
@echo " docker run --interactive --tty --rm --volume \"${HOME}/bin:/silo_install_path\" ${SILO_IMG}:${SILO_VERSION} --install"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${HOME}

Should be

\$${HOME}

so the output would be

docker run --interactive --tty --rm --volume "${HOME}/bin:/silo_install_path" grpn/ansible-silo:3.0.0 --install

This way the user can easily copy and share the command.

@echo ""
@echo "To install '${SILO_IMG}:${SILO_VERSION}' for all users, run the following command:"
@echo " docker run --interactive --tty --rm --volume \"/usr/local/bin:/silo_install_path\" ${SILO_IMG}:${SILO_VERSION} --install"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️


ansible-silo-base:
@docker build --build-arg "v=$(BASE_VERSION)" --file "base.Dockerfile" --tag "${BASE_IMG}:$(BASE_VERSION)" .
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
3.0.0
133 changes: 66 additions & 67 deletions base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FROM alpine:3.6
FROM python:2.7.14-alpine3.6

ENV container docker
ARG v
Expand All @@ -39,85 +39,85 @@ ADD pip/pip.conf /etc/pip.conf
LABEL maintainer="Daniel Schroeder <[email protected]>"

# Add testing repo, as we need this for installing gosu
RUN echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories &&\
RUN echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories

# Install common libraries
RUN apk add --no-cache libssl1.0==1.0.2n-r0\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore original grouping. This makes it really hard to review. Some packages have been removed, some have been added, required version upgrades - but everything has been shuffled so it is really hard to see what actually happened and for what reason.

libatomic==6.3.0-r4\
libgomp==6.3.0-r4\
libffi==3.2.1-r3\
libgcc==6.3.0-r4\
libstdc++==6.3.0-r4\
libxml2==2.9.5-r0\
libgpg-error==1.27-r0\
libgcrypt==1.7.9-r0\
libxslt==1.1.29-r3\

# Install development libaries
libxml2-dev==2.9.5-r0\
libxslt-dev==1.1.29-r3\
libffi-dev==3.2.1-r3\
pkgconf==1.3.7-r0\
musl-dev==1.1.16-r14\
python2==2.7.14-r0\
python2-dev==2.7.14-r0\
openssl-dev==1.0.2n-r0\
zlib-dev==1.2.11-r0\

# Install curl
apk add --no-cache openssl=1.0.2k-r0\
ca-certificates=20161130-r2\
libssh2=1.8.0-r1\
libcurl=7.55.0-r0\
curl=7.55.0-r0\
openssl==1.0.2n-r0\
curl==7.58.0-r0\

# Install bash
ncurses-terminfo-base=6.0-r8\
ncurses-terminfo=6.0-r8\
ncurses-libs=6.0-r8\
readline=6.3.008-r5\
bash=4.3.48-r1\
bash==4.3.48-r1\

# Install git
perl=5.24.1-r2\
expat=2.2.0-r1\
pcre=8.41-r0\
git=2.13.5-r0\
pcre==8.41-r0\
git==2.13.5-r0\

# Install python
libbz2=1.0.6-r5\
libffi=3.2.1-r3\
gdbm=1.12-r0\
sqlite-libs=3.18.0-r0\
py-netifaces=0.10.5-r3\

# Install pip
py2-pip=9.0.1-r1\
py-netifaces==0.10.5-r3\
py2-netifaces==0.10.5-r3\

# Install Ansible dependencies
yaml=0.1.7-r0\
gmp=6.1.2-r0\
yaml==0.1.7-r0\
gmp==6.1.2-r0\

# Install gosu, which enables us to run Ansible as the user who started the container
gosu@testing=1.9-r0\
sudo=1.8.19_p2-r0\
sudo==1.8.19_p2-r0\

# Install ssh
openssh-client=7.5_p1-r1\
openssh-sftp-server=7.5_p1-r1\
openssh=7.5_p1-r1\
sshpass=1.06-r0 &&\

# Install some required python modules which need compiling
apk add --no-cache gcc=6.3.0-r4\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this block as is. Ideally this apk command would create a virtual package, which later in the Dockerfile can be deleted. This is just not implemented as it was not working together with version pinning at the time of writing. See gliderlabs/docker-alpine#205

musl=1.1.16-r13\
musl-dev=1.1.16-r13\
musl-utils=1.1.16-r13\
binutils-libs=2.28-r2\
binutils=2.28-r2\
isl=0.17.1-r0\
libgomp=6.3.0-r4\
libatomic=6.3.0-r4\
pkgconf=1.3.7-r0\
libgcc=6.3.0-r4\
mpfr3=3.1.5-r0\
mpc1=1.0.3-r0\
libstdc++=6.3.0-r4\
zlib-dev=1.2.11-r0\
python2-dev=2.7.13-r1\
openssl-dev=1.0.2k-r0\
libffi-dev=3.2.1-r3\
libxml2-dev=2.9.4-r4\
libxslt-dev=1.1.29-r3 &&\

pip install asn1crypto==0.22.0\
cffi==1.10.0\
cryptography==2.0.2\
openssh-keygen==7.5_p1-r2\
openssh-client==7.5_p1-r2\
openssh-sftp-server==7.5_p1-r2\
openssh==7.5_p1-r2\
sshpass==1.06-r0\

# Install tools for compiling python
gcc==6.3.0-r4\
binutils-libs==2.28-r3\
binutils==2.28-r3\
isl==0.17.1-r0\
mpfr3==3.1.5-r0\
make==4.2.1-r0\
mpc1==1.0.3-r0 &&\

# Add the python libraries
pip install asn1crypto==0.24.0\
bcrypt==3.1.4\
cffi==1.11.4\
cryptography==2.1.4\
enum34==1.1.6\
idna==2.5\
ipaddress==1.0.18\
ncclient==0.5.3\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ncclient Is missing now, which is used by many networking modules. #31

https://github.com/ansible/ansible/search?q=ncclient&unscoped_q=ncclient

paramiko==1.16.0\
idna==2.6\
ipaddress==1.0.19\
lxml==4.1.1\
paramiko==2.4.0\
pyasn1==0.4.2\
pycparser==2.18\
pycrypto==2.6.1\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pycrypto is missing.

six==1.10.0 &&\
pynacl==1.2.1\
napalm==2.3.0\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alnum sorted. napalm should be in list before p.

six==1.11.0 &&\

apk del --no-cache gcc\
python2-dev\
Expand All @@ -127,7 +127,6 @@ RUN echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/
isl\
libgomp\
libatomic\
pkgconf\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correct this package is required, because you have junos-eznc in your bundles pip requirements and installing that requires pkgconf. Is that correct? Wouldn't it make more sense then to install it per the bundles Dockerfile?

libgcc\
mpfr3\
mpc1\
Expand All @@ -137,10 +136,10 @@ RUN echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/
openssl-dev\
libffi-dev\
libxml2-dev\
libxslt-dev &&\
libxslt-dev

# Install docker command and ensure it's always executed w/ sudo
curl -fL -o /tmp/docker.tgz "https://download.docker.com/linux/static/stable/x86_64/docker-17.06.0-ce.tgz" &&\
# Install docker command and ensure it's always executed w/ sudo
RUN curl -fL -o /tmp/docker.tgz "https://download.docker.com/linux/static/stable/x86_64/docker-17.06.0-ce.tgz" &&\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be same layer.

tar -xf /tmp/docker.tgz --exclude docker/docker?* -C /tmp &&\
mv /tmp/docker/docker /usr/local/bin/real-docker &&\
rm -rf /tmp/docker /tmp/docker.tgz &&\
Expand Down
15 changes: 8 additions & 7 deletions pip/requirements
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
docker==2.5.1
docker-compose==1.15
docker-py==1.10.6
docker==2.7.0
docker-compose==1.19.0
docker-pycreds==0.2.2
dockerpty==0.4.1
ecdsa==0.13
httplib2==0.9.2
httplib2==0.10.3
jinja2==2.8
jmespath==0.9.3
markupsafe==0.23
markupsafe==1.0
netaddr==0.7.19
pexpect==4.2.1
pexpect==4.4.0
ptyprocess==0.5.2
pyyaml==3.11
pyyaml==3.12
15 changes: 15 additions & 0 deletions silo/bundle/build
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,24 @@ if [[ -f "playbooks/requirements.yml" ]]; then
cd ..
fi

# If there is a PIP requirements file, install it using pip
if [[ -f "playbooks/requirements.txt" ]]; then
cd playbooks || exit
pip install -r requirements.txt || exit
cd ..
fi

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is installing python modules on the host.

Shouldn't this be added to the Dockerfile of the bundle instead?

# Build as "latest" image
docker build --build-arg "v=${bundle_version}" \
--tag "${bundle_image}:${bundle_version}" . || exit

docker tag "$(docker images --quiet "${bundle_image}:${bundle_version}")" \
"${bundle_image}:latest" || exit

# Show installation instructions
echo ""
echo "To install '${bundle_image}:${bundle_version}' for just your user, run the following command:"
echo " docker run --interactive --tty --rm --volume \"${HOME}/bin:/silo_install_path\" ${bundle_image}:${bundle_version} --install"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${HOME}

Should be

\$${HOME}

echo ""
echo "To install '${bundle_image}:${bundle_version}' for all users, run the following command:"
echo " docker run --interactive --tty --rm --volume \"/usr/local/bin:/silo_install_path\" ${bundle_image}:${bundle_version} --install"