-
Notifications
You must be signed in to change notification settings - Fork 100
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
Clean more files after dnf installing #844
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ ARG GIT_AUTH | |
RUN mkdir build && \ | ||
if [[ -n "$GIT_AUTH" ]]; then GIT_HOST=${GIT_AUTH}@${GIT_HOST}; fi && curl -L https://${GIT_HOST}/${BUILD_ORG}/${CORE_REPO_NAME}-appliance-build/tarball/${BUILD_REF} | tar vxz -C build --strip 1 | ||
|
||
################################################################################ | ||
|
||
FROM registry.access.redhat.com/ubi8/ubi | ||
MAINTAINER ManageIQ https://manageiq.org | ||
|
||
|
@@ -33,8 +35,13 @@ LABEL name="manageiq-base" \ | |
RUN chmod -R g+w /etc/pki/ca-trust && \ | ||
chmod -R g+w /usr/share/pki/ca-trust-legacy | ||
|
||
# Install dumb-init to be used as the entrypoint | ||
RUN curl -L -o /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_${ARCH} && \ | ||
chmod +x /usr/bin/dumb-init | ||
|
||
COPY rpms/* /tmp/rpms/ | ||
COPY container-assets/create_local_yum_repo.sh / | ||
COPY container-assets/clean_dnf_rpm /usr/local/bin/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm open to renaming this script. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming is hard 😄 |
||
|
||
RUN curl -L https://releases.ansible.com/ansible-runner/ansible-runner.el8.repo > /etc/yum.repos.d/ansible-runner.repo | ||
|
||
|
@@ -56,30 +63,25 @@ RUN dnf -y --disableplugin=subscription-manager --setopt=tsflags=nodocs install | |
dnf config-manager --setopt=ubi-8-*.exclude=dracut*,net-snmp*,perl-*,redhat-release* --save && \ | ||
if [[ "$LOCAL_RPM" = "true" ]]; then /create_local_yum_repo.sh; fi && \ | ||
dnf -y --setopt=tsflags=nodocs install \ | ||
${RPM_PREFIX}-pods \ | ||
python3-devel \ | ||
&& \ | ||
dnf clean all && \ | ||
rm -rf /var/cache/dnf && \ | ||
${RPM_PREFIX}-pods \ | ||
python3-devel && \ | ||
clean_dnf_rpm && \ | ||
chgrp -R 0 $APP_ROOT && \ | ||
chmod -R g=u $APP_ROOT | ||
|
||
# Add in the container_env file now that the APP_ROOT is created from the RPM | ||
ADD container-assets/container_env ${APP_ROOT} | ||
|
||
# Install python packages the same way the appliance does | ||
COPY --from=appliance_build build/kickstarts/partials/post/python_modules.ks.erb /tmp/python_modules | ||
RUN bash /tmp/python_modules && \ | ||
rm -f /tmp/python_modules && \ | ||
rm -rf /root/.cache/pip && \ | ||
dnf clean all && \ | ||
rm -rf /var/cache/dnf | ||
|
||
ADD container-assets/container_env ${APP_ROOT} | ||
|
||
RUN curl -L -o /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_${ARCH} && \ | ||
chmod +x /usr/bin/dumb-init | ||
clean_dnf_rpm | ||
|
||
# Build the RPM manifest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we were keeping this as close as possible to the end in case any other steps were added with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was actually considering moving the dumb-init and ADD calls up the file. If you're ok with that for this PR I can do that, and then this is at the "end" of the file again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even so, the only calls afterwards are an ADD, and the curl of dumb-init, so this is technically at the "end" of any dnf commands There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with moving them up, they're only used at runtime, not build time so the order doesn't matter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not for this PR, but dumb-init is up to v1.2.5 now, so we should probably update. Also, should we rely on pulling it from Github at every build or do you think we should keep a copy somewhere else (package it in an RPM)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes I saw that - will have a follow-up PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bdunne Updated. I moved up both commands |
||
RUN source /etc/default/evm && \ | ||
/usr/bin/generate_rpm_manifest.sh && \ | ||
dnf clean all && \ | ||
rm -rf /var/cache/dnf | ||
clean_dnf_rpm | ||
|
||
ENTRYPOINT ["/usr/bin/dumb-init", "--single-child", "--"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not for this PR, but I wonder if we should put this script in one of our RPMs and run it on the appliance to reduce image size there too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh that's an interesting idea - agreed that we can do that in a follow up |
||
|
||
# Cleanup dnf | ||
dnf clean all | ||
rm -rf /var/cache/dnf | ||
rm -rf /var/lib/dnf/history* | ||
rm -rf /var/log/dnf*.log | ||
rm -rf /var/log/hawkey.log | ||
|
||
# Cleanup rpm | ||
rm -rf /var/lib/rpm/__db.* |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,3 @@ MAINTAINER ManageIQ https://manageiq.org | |
|
||
LABEL name="manageiq-ui-worker" \ | ||
summary="ManageIQ user interface worker image" | ||
|
||
RUN source /etc/default/evm && \ | ||
/usr/bin/generate_rpm_manifest.sh && \ | ||
dnf clean all && \ | ||
rm -rf /var/cache/dnf | ||
|
||
RUN rm -rf /tmp/rpms /create_local_yum_repo.sh /etc/yum.repos.d/local_rpm.repo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure why this was done here. Removing these doesn't change anything with respect to the file size, and one can get at them from one of the parent images. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤷🏻♂️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we used to install something here, but it was moved up in the layers. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,23 +9,24 @@ ARG RPM_PREFIX=manageiq | |
LABEL name="manageiq-webserver-worker" \ | ||
summary="ManageIQ web server worker image" | ||
|
||
RUN dnf -y --setopt=tsflags=nodocs install ${RPM_PREFIX}-ui && \ | ||
dnf clean all && \ | ||
rm -rf /var/cache/dnf | ||
|
||
COPY container-assets/service-worker-entrypoint /usr/local/bin | ||
|
||
RUN rm -f /etc/httpd/conf.d/* && \ | ||
sed -i '/^Listen 80/d' /etc/httpd/conf/httpd.conf | ||
|
||
# Configure httpd to run without root privileges | ||
RUN chgrp root /var/run/httpd && chmod g+rwx /var/run/httpd && \ | ||
chgrp root /var/log/httpd && chmod g+rwx /var/log/httpd | ||
|
||
RUN dnf -y --setopt=tsflags=nodocs install \ | ||
${RPM_PREFIX}-ui && \ | ||
clean_dnf_rpm && \ | ||
# Remove httpd default settings | ||
rm -f /etc/httpd/conf.d/* && \ | ||
sed -i '/^Listen 80/d' /etc/httpd/conf/httpd.conf && \ | ||
# Configure httpd to run without root privileges | ||
chgrp root /var/run/httpd && \ | ||
chmod g+rwx /var/run/httpd && \ | ||
chgrp root /var/log/httpd && \ | ||
chmod g+rwx /var/log/httpd | ||
|
||
# Build the RPM manifest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason to merge the other There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't save any space to merge the manifest one, though admittedly it would drop the need to duplicate the clean_dnf_rpm call. I'd like to leave it for now. |
||
RUN source /etc/default/evm && \ | ||
/usr/bin/generate_rpm_manifest.sh && \ | ||
dnf clean all && \ | ||
rm -rf /var/cache/dnf | ||
clean_dnf_rpm | ||
|
||
EXPOSE 3000 | ||
EXPOSE 4000 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it easier to see various multi-stage builds - I can remove from this PR if you want, but I figured it was fine.