This repository has been archived by the owner on Aug 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Containerfile
78 lines (70 loc) · 2.72 KB
/
Containerfile
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
# Overly simplified single stage build process: we take all binary dependencies
# using dnf and use pip to install the rest.
# this arg must be declared before FROM, also do not include registry part as
# it seems to confuse podman and make it avoid using locally build base image.
ARG EE_BASE_IMAGE=creator-base:latest
FROM $EE_BASE_IMAGE
# this arg must be declared after FROM
ARG CONTAINER_NAME
ENV CONTAINER_NAME $CONTAINER_NAME
# https://github.com/opencontainers/image-spec/blob/main/annotations.md
LABEL org.opencontainers.image.source https://github.com/ansible/creator-ee
LABEL org.opencontainers.image.authors "Ansible DevTools"
LABEL org.opencontainers.image.vendor "Red Hat"
LABEL org.opencontainers.image.licenses "GPL-3.0"
LABEL ansible-execution-environment=true
USER root
WORKDIR /tmp
COPY _build/requirements.txt requirements.txt
COPY _build/requirements.yml requirements.yml
COPY _build/devtools-publish /usr/local/bin/devtools-publish
COPY _build/shells /etc/shells
COPY _build/.bashrc /home/runner/.bashrc
RUN \
microdnf install --assumeyes ncurses && \
microdnf clean all && \
pip3 install --progress-bar=off \
-r requirements.txt && \
mkdir -p ~/.ansible/roles /usr/share/ansible/roles /etc/ansible/roles && \
rm -rf $(pip3 cache dir) && \
# Avoid "fatal: detected dubious ownership in repository at" with newer git versions
# See https://github.com/actions/runner-images/issues/6775
git config --system --add safe.directory / && \
# Create bashrc file with colored prompt using container name
printf "export CONTAINER_NAME=$CONTAINER_NAME\n" >> /home/runner/.bashrc
# In OpenShift, container will run as a random uid number and gid 0. Make sure things
# are writeable by the root group.
RUN for dir in \
/home/runner \
/home/runner/.ansible \
/home/runner/.ansible/tmp \
/runner \
/home/runner \
/runner/env \
/runner/inventory \
/runner/project \
/runner/artifacts ; \
do mkdir -m 0775 -p $dir ; chmod -R g+rwx $dir ; chgrp -R root $dir ; done && \
for file in \
/home/runner/.ansible/galaxy_token \
/etc/passwd \
/etc/group ; \
do touch $file ; chmod g+rw $file ; chgrp root $file ; done
COPY collections/ /usr/share/ansible/collections
# add some helpful CLI commands to check we do not remove them inadvertently and output some helpful version information at build time.
RUN set -ex \
&& ansible --version \
&& ansible-lint --version \
&& ansible-runner --version \
&& molecule --version \
&& molecule drivers \
&& podman --version \
&& python3 --version \
&& git --version \
&& ansible-galaxy role list \
&& ansible-galaxy collection list \
&& rpm -qa \
&& uname -a
ADD _build/entrypoint.sh /bin/entrypoint
RUN chmod +x /bin/entrypoint
ENTRYPOINT ["entrypoint"]