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

Commit

Permalink
Avoid creation of multiple layers during build (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Sep 25, 2024
1 parent 0bc8687 commit d4fedac
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 46 deletions.
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

0 comments on commit d4fedac

Please sign in to comment.