Skip to content

Instantly share code, notes, and snippets.

@jtprogru
Created December 23, 2022 15:40
Show Gist options
  • Save jtprogru/854d912d5eddd30f638f95571cc081c5 to your computer and use it in GitHub Desktop.
Save jtprogru/854d912d5eddd30f638f95571cc081c5 to your computer and use it in GitHub Desktop.
Basic Dockerfile for running Ansible
FROM python:3.10-slim AS compile-image
ENV PY_COLORS=1
ENV ANSIBLE_FORCE_COLOR=true
RUN apt-get update
RUN apt-get install -y --no-install-recommends build-essential gcc curl unzip
RUN curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip \
&& unzip awscliv2.zip \
&& ./aws/install --bin-dir /aws-cli-bin/
COPY requirements.txt .
RUN pip install -U pip --no-warn-script-location --user \
&& pip install --no-warn-script-location --user -r requirements.txt \
&& find /root/.local/lib/python3.10/ -type d -name __pycache__ -exec rm -rf {} \+
FROM python:3.10-slim AS build-image
COPY --from=compile-image /root/.local /root/.local
COPY --from=compile-image /usr/local/aws-cli/ /usr/local/aws-cli/
COPY --from=compile-image /aws-cli-bin/ /usr/local/bin/
RUN apt-get update && apt-get install -y --no-install-recommends openssh-client less groff && rm -rf /var/lib/apt/lists/*
ENV PATH=/root/.local/bin:$PATH
CMD ["/bin/bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment