Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Avoid creation of multiple layers during build #8

Merged
merged 1 commit into from
Sep 25, 2024
Merged
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
55 changes: 9 additions & 46 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,17 @@ FROM quay.io/devfile/universal-developer-image:ubi8-latest

ARG PYV=3.11

LABEL org.opencontainers.image.source https://github.com/ansible/ansible-workspace-env-reference-image
LABEL org.opencontainers.image.authors "Ansible DevTools"
LABEL org.opencontainers.image.vendor "Red Hat"
LABEL org.opencontainers.image.licenses "GPL-3.0"
LABEL org.opencontainers.image.description "An OpenShift Dev Spaces container image for Ansible."
LABEL org.opencontainers.image.source=https://github.com/ansible/ansible-workspace-env-reference-image
LABEL org.opencontainers.image.authors="Ansible DevTools"
LABEL org.opencontainers.image.vendor="Red Hat"
LABEL org.opencontainers.image.licenses="GPL-3.0"
LABEL org.opencontainers.image.description="An OpenShift Dev Spaces container image for Ansible."

USER 0

# install ansible-dev-tools specific packages
RUN <<EOF
set -e
dnf -y makecache
dnf -y update
dnf install -y \
tar \
podman \
fuse-overlayfs \
openssh-clients \
zsh \
util-linux-user \
which \
git \
dumb-init \
gcc \
git-core \
libssh-devel \
python3-markupsafe \
ncurses \
python3-bcrypt \
python3-cffi \
python3-pip \
python3-pyyaml \
python3-ruamel-yaml \
python3-wheel \
--exclude container-selinux
dnf clean all
EOF

COPY ./requirements.txt requirements.txt
COPY ./requirements.yml requirements.yml
RUN \
/usr/bin/python${PYV} -m pip install --no-cache-dir -r requirements.txt \
&& ansible-galaxy collection install -r requirements.yml

RUN chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home

# Configure the podman wrapper
COPY --chown=0:0 podman.py /usr/bin/podman.wrapper
RUN chmod +x /usr/bin/podman.wrapper
WORKDIR /context
# install ansible-dev-tools specific packages and dependencies while avoiding
# adding multiple layers to the image.
RUN --mount=type=bind,target=. --mount=type=cache,dst=/var/cache/dnf --mount=type=cache,dst=/root/.cache/pip ./setup.sh

USER 10001
40 changes: 40 additions & 0 deletions context/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash -e
set -eux pipefail

set -e
dnf -y makecache
dnf -y update
dnf install -y \
tar \
podman \
fuse-overlayfs \
openssh-clients \
zsh \
util-linux-user \
which \
git \
dumb-init \
gcc \
git-core \
libssh-devel \
python3-markupsafe \
ncurses \
python3-bcrypt \
python3-cffi \
python3-pip \
python3-pyyaml \
python3-ruamel-yaml \
python3-wheel \
--exclude container-selinux
dnf clean all

/usr/bin/python${PYV} -m pip install --no-cache-dir -r requirements.txt

ansible-galaxy collection install -r requirements.yml

chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home

# Configure the podman wrapper
cp podman.py /usr/bin/podman.wrapper
chown 0:0 /usr/bin/podman.wrapper
chmod +x /usr/bin/podman.wrapper