Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permanently enable installed collections #108

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 11 additions & 0 deletions 2.7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ RUN yum install -y centos-release-scl && \
rpm -e --nodeps centos-logos && \
yum clean all -y

# -- generated by https://github.com/rhcarvalho/envdiff, do not edit manually --
# The ENV instruction below is equivalent to:
# scl enable python27
ENV MANPATH=/opt/rh/python27/root/usr/share/man: \
X_SCLS=python27 \
LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64 \
PATH=/opt/rh/python27/root/usr/bin:$PATH \
XDG_DATA_DIRS=/opt/rh/python27/root/usr/share \
PKG_CONFIG_PATH=/opt/rh/python27/root/usr/lib64/pkgconfig
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to "fine-tune" certain list variables to include a recursive reference to its previous value, even if it was previously undefined. Those wouldn't be possible to auto-detect.

For example:

-MANPATH=/opt/rh/python27/root/usr/share/man:
+MANPATH=/opt/rh/python27/root/usr/share/man:$MANPATH
# oddly, scl enable does leave a trailing ':' there!

-LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64
+LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64:$LD_LIBRARY_PATH

-XDG_DATA_DIRS=/opt/rh/python27/root/usr/share
+XDG_DATA_DIRS=/opt/rh/python27/root/usr/share:$XDG_DATA_DIRS

-PKG_CONFIG_PATH=/opt/rh/python27/root/usr/lib64/pkgconfig
+PKG_CONFIG_PATH=/opt/rh/python27/root/usr/lib64/pkgconfig:$PKG_CONFIG_PATH

The reason to do that is if we ever try to set a value for one of those variables before this opaque ENV instruction, or, harder to find out, a parent layer does set that variable, we'd be inadvertently overwriting the previous value.

To minimize human intervention, we can have a whitelist of variables that we want to give this special treatment, and have envdiff do the work for us.

@bparees @hhorak WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i think we should definitely do that.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For RPMs security team pointed out that enable scriptlet needs to avoid exporting path with empty path segment (usually a trailing ':'). It's done by appending envar only if it is already defined, e.g. export LD_LIBRARY_PATH=/opt/rh/ruby200/root/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

IMO we should do the same in the case of docker images too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lukaszachy. That sounds like a good idea. I'll see if Docker supports the syntax, I'm not sure about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice nice! It works 🎉 🎊

I did it for PATH:

$ grep \$\{PATH Dockerfile
    PATH=/opt/rh/rh-python34/root/usr/bin${PATH:+:${PATH}} \
$ docker build -t python-34-smart-path .
...
$ docker inspect --type=image python-34-smart-path | grep \"PATH=
            "PATH=/opt/rh/rh-python34/root/usr/bin:/opt/app-root/src/.local/bin/:/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "PATH=/opt/rh/rh-python34/root/usr/bin:/opt/app-root/src/.local/bin/:/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",

# ------------------------ end of generated instruction ------------------------

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
COPY ./s2i/bin/ $STI_SCRIPTS_PATH

Expand Down
11 changes: 11 additions & 0 deletions 2.7/Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ RUN yum-config-manager --enable rhel-server-rhscl-7-rpms && \
rpm -e --nodeps redhat-logos && \
yum clean all -y

# -- generated by https://github.com/rhcarvalho/envdiff, do not edit manually --
# The ENV instruction below is equivalent to:
# scl enable python27
ENV MANPATH=/opt/rh/python27/root/usr/share/man: \
X_SCLS=python27 \
LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64 \
PATH=/opt/rh/python27/root/usr/bin:$PATH \
XDG_DATA_DIRS=/opt/rh/python27/root/usr/share \
PKG_CONFIG_PATH=/opt/rh/python27/root/usr/lib64/pkgconfig
# ------------------------ end of generated instruction ------------------------

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
COPY ./s2i/bin/ $STI_SCRIPTS_PATH

Expand Down
11 changes: 11 additions & 0 deletions 3.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ RUN yum install -y centos-release-scl && \
rpm -e --nodeps centos-logos && \
yum clean all -y

# -- generated by https://github.com/rhcarvalho/envdiff, do not edit manually --
# The ENV instruction below is equivalent to:
# scl enable python33
ENV MANPATH=/opt/rh/python33/root/usr/share/man: \
X_SCLS=python33 \
LD_LIBRARY_PATH=/opt/rh/python33/root/usr/lib64 \
PATH=/opt/rh/python33/root/usr/bin:$PATH \
XDG_DATA_DIRS=/opt/rh/python33/root/usr/share \
PKG_CONFIG_PATH=/opt/rh/python33/root/usr/lib64/pkgconfig
# ------------------------ end of generated instruction ------------------------

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
COPY ./s2i/bin/ $STI_SCRIPTS_PATH

Expand Down
11 changes: 11 additions & 0 deletions 3.3/Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ RUN yum-config-manager --enable rhel-server-rhscl-7-rpms && \
rpm -e --nodeps redhat-logos && \
yum clean all -y

# -- generated by https://github.com/rhcarvalho/envdiff, do not edit manually --
# The ENV instruction below is equivalent to:
# scl enable python33
ENV MANPATH=/opt/rh/python33/root/usr/share/man: \
X_SCLS=python33 \
LD_LIBRARY_PATH=/opt/rh/python33/root/usr/lib64 \
PATH=/opt/rh/python33/root/usr/bin:$PATH \
XDG_DATA_DIRS=/opt/rh/python33/root/usr/share \
PKG_CONFIG_PATH=/opt/rh/python33/root/usr/lib64/pkgconfig
# ------------------------ end of generated instruction ------------------------

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
COPY ./s2i/bin/ $STI_SCRIPTS_PATH

Expand Down
11 changes: 11 additions & 0 deletions 3.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ RUN yum install -y centos-release-scl && \
rpm -e --nodeps centos-logos && \
yum clean all -y

# -- generated by https://github.com/rhcarvalho/envdiff, do not edit manually --
# The ENV instruction below is equivalent to:
# scl enable rh-python34
ENV MANPATH=/opt/rh/rh-python34/root/usr/share/man: \
X_SCLS=rh-python34 \
LD_LIBRARY_PATH=/opt/rh/rh-python34/root/usr/lib64 \
PATH=/opt/rh/rh-python34/root/usr/bin:$PATH \
XDG_DATA_DIRS=/opt/rh/rh-python34/root/usr/share \
PKG_CONFIG_PATH=/opt/rh/rh-python34/root/usr/lib64/pkgconfig
# ------------------------ end of generated instruction ------------------------

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
COPY ./s2i/bin/ $STI_SCRIPTS_PATH

Expand Down
11 changes: 11 additions & 0 deletions 3.4/Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ RUN yum-config-manager --enable rhel-server-rhscl-7-rpms && \
rpm -e --nodeps redhat-logos && \
yum clean all -y

# -- generated by https://github.com/rhcarvalho/envdiff, do not edit manually --
# The ENV instruction below is equivalent to:
# scl enable rh-python34
ENV MANPATH=/opt/rh/rh-python34/root/usr/share/man: \
X_SCLS=rh-python34 \
LD_LIBRARY_PATH=/opt/rh/rh-python34/root/usr/lib64 \
PATH=/opt/rh/rh-python34/root/usr/bin:$PATH \
XDG_DATA_DIRS=/opt/rh/rh-python34/root/usr/share \
PKG_CONFIG_PATH=/opt/rh/rh-python34/root/usr/lib64/pkgconfig
# ------------------------ end of generated instruction ------------------------

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
COPY ./s2i/bin/ $STI_SCRIPTS_PATH

Expand Down