-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
57 lines (45 loc) · 1.75 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
FROM python:3.12-slim-bookworm AS minimal
ARG DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && \
apt install -y build-essential git
FROM minimal AS dependencies
ENV VIRTUAL_ENV=/opt/venv
ENV ANSIBLE_HOME=/opt/ansible
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY ./requirements/ ./requirements/
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
set -eux; \
pip install -qr requirements/pip-tools.txt; \
pip-sync requirements/base.txt
COPY ./requirements.yml .
RUN ansible-galaxy install -r requirements.yml
FROM python:3.12-slim-bookworm AS final
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && \
apt install -y openssh-client
RUN set -eux; \
groupadd --system --gid 1000 runner; \
useradd --system --gid runner --uid 1000 --home-dir /runner runner; \
mkdir -p /runner; \
chown -R runner:runner /runner;
ENV VIRTUAL_ENV=/opt/venv
ENV ANSIBLE_HOME=/opt/ansible
ENV ANSIBLE_REMOTE_TEMP=/dev/shm
ENV ANSIBLE_LOCAL_TEMP=/dev/shm
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY --from=dependencies $VIRTUAL_ENV $VIRTUAL_ENV
COPY --from=dependencies $ANSIBLE_HOME $ANSIBLE_HOME
USER 1000:1000
WORKDIR /runner/atlas-ansible-utils
COPY ./hosts.ini /etc/ansible/
COPY . .
# For now, we prefer skipping the host key checking
ENV ANSIBLE_HOST_KEY_CHECKING="no"
ENV ATLAS_ANSIBLE_PLAYBOOK="test_os_info.yml"
ENV ATLAS_ANSIBLE_PLAYBOOK_EXTRA_PARAMS=""
ENV ANSIBLE_INVENTORY="/etc/ansible/hosts.ini"
CMD [ "/bin/sh", "-c", "ansible-playbook playbooks/${ATLAS_ANSIBLE_PLAYBOOK} ${ATLAS_ANSIBLE_PLAYBOOK_EXTRA_PARAMS}" ]