33FROM python:alpine AS builder
44
55# Add configuration files
6- COPY requirements/apk.build.list requirements/pip.list /requirements/ansible.yaml /requirements/
6+ COPY requirements/apk.build.list /requirements/ansible.yaml /requirements/
77
88# Overridable args to pass to galaxy role/collection install
99ARG ANSIBLE_GALAXY_CLI_ROLE_OPTS=
@@ -12,7 +12,6 @@ ARG ANSIBLE_GALAXY_CLI_COLLECTION_OPTS=
1212# Install system build dependencies
1313RUN apk add --no-cache $(cat /requirements/apk.build.list) && \
1414 python -m venv /opt/ansible_venv/ && PATH=/opt/ansible_venv/bin:${PATH} \
15- pip install --no-cache-dir --requirement requirements/pip.list && \
1615 ansible-galaxy role install ${ANSIBLE_GALAXY_CLI_ROLE_OPTS} \
1716 --role-file /requirements/ansible.yaml \
1817 --roles-path "/usr/share/ansible/roles" && \
@@ -22,7 +21,7 @@ RUN apk add --no-cache $(cat /requirements/apk.build.list) && \
2221 chmod -R a=rX /usr/share/ansible
2322
2423# ######################################## RUNNER #########################################
25-
24+
2625FROM python:alpine
2726
2827LABEL org.opencontainers.image.description="A really small Ansible Execution Environment that is easily customizable and maintainable withoud using the bloated ansible-builder ;)"
@@ -31,23 +30,23 @@ LABEL org.opencontainers.image.description="A really small Ansible Execution Env
3130WORKDIR /runner/
3231
3332# Add runtime dependencies lists
34- COPY requirements/apk.list /requirements/
35- # Copy install pip modules and Ansible roles and collections
36- COPY --from=builder /opt/ansible_venv/ /opt/ansible_venv/
33+ COPY requirements/apk.list requirements/pip.list /requirements/
34+ # Copy Ansible roles and collections
3735COPY --from=builder /usr/share/ansible /usr/share/ansible
3836
3937# Add non-root user
4038ARG USER=ansible && \
4139 GROUP=ansible && \
4240 UID=1000 && \
4341 GID=1000
42+ # Make the user, install packages, pip modules and make the python interpeter system default
4443RUN addgroup ${GROUP} --gid ${GID} && \
4544 adduser ${USER} --uid ${UID} \
4645 --ingroup "${GROUP}" \
4746 --disabled-password && \
4847 chown ${USER}:${GROUP} /runner/ /home/"${USER}" / && \
4948 apk add --no-cache $(cat /requirements/apk.list) && \
50- pip install --no-cache-dir ansible-core && \
49+ pip install --no-cache-dir --requirement requirements/pip.list && \
5150 ln -s /usr/local/bin/python3 /usr/bin/python3
5251
5352# Set user and Ansible required args/paths
0 commit comments