Skip to content

Commit

Permalink
Merge pull request #32 from netmanagers/remove-gettys-and-udev
Browse files Browse the repository at this point in the history
feat(getty+udev): remove targets to reduce cpu+mem footprint
  • Loading branch information
javierbertoli authored Mar 30, 2020
2 parents dca36ad + 504b279 commit d7bac6c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ env:
- DN=opensuse/leap DV=15.1 PI=zyp SIM=git SV=master PV=3 EP="python3-pip"
- DN=opensuse/leap DV=15.1 PI=zyp SIM=git SV=3000 PV=3 EP="python3-pip"
- DN=opensuse/leap DV=15.1 PI=zyp SIM=git SV=2019.2 PV=3 EP="python3-pip"
- DN=opensuse/leap DV=15.1 PI=zyp SIM=git SV=2018.3 PV=2 EP="python-pip"
- DN=opensuse/leap DV=15.1 PI=zyp SIM=git SV=2018.3 PV=2 EP="python2-pip"

# UBUNTU
- DN=ubuntu DV=18.04 PI=apt SIM=git SV=master PV=3 EP="python3-apt python3-pip"
Expand All @@ -82,7 +82,7 @@ env:
- DN=ubuntu DV=16.04 PI=apt SIM=stable SV=2018.3 PV=2 EP="python-pip"

before_install:
- sudo apt-get install python3-venv
- sudo apt-get install -y python3-venv
- python3 -m venv venv
- venv/bin/pip install -r requirements.txt

Expand Down
9 changes: 5 additions & 4 deletions Dockerfile.apt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ COPY files/apt-no-recommends /etc/apt/apt.conf.d/99synaptic
RUN apt update \
&& apt install --yes $PKGS

# Remove unnecessary getty and udev targets that result in high CPU usage when using
# multiple containers with Molecule or Kitchen (https://github.com/ansible/molecule/issues/1104)
RUN rm -f /lib/systemd/system/systemd*udev* /lib/systemd/system/getty.target

# Use @vutny's suggestion in https://github.com/saltstack-formulas/postgres-formula/pull/269#issuecomment-492597286
RUN rm -f /etc/default/locale /etc/locale.gen
RUN echo 'locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8' | debconf-set-selections -
Expand All @@ -37,3 +33,8 @@ RUN rm -rf /var/cache/{salt,apt} \
&& rm -rf /var/lib/apt/lists/* \
&& (find / -name "*pyc" ; find / -name "__pycache__"; find /var/log -type f) |grep -v /proc | xargs rm -rf

# Remove unnecessary getty and udev targets that result in high CPU usage when using
# multiple containers with Molecule or Kitchen (https://github.com/ansible/molecule/issues/1104)
RUN rm -rf /lib/systemd/system/systemd*udev* /lib/systemd/system/getty.target
# Also obscure any `getty` binaries (https://github.com/moby/moby/issues/4040#issuecomment-339022455)
RUN cp /bin/true /sbin/agetty
5 changes: 5 additions & 0 deletions Dockerfile.dnf
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ RUN curl -L https://raw.githubusercontent.com/saltstack/salt-bootstrap/develop/b
RUN rm -rf /var/cache/{salt,pacman} \
&& (find / -name "*pyc" ; find / -name "__pycache__") |grep -v /proc | xargs rm -rf

# Remove unnecessary getty and udev targets that result in high CPU usage when using
# multiple containers with Molecule or Kitchen (https://github.com/ansible/molecule/issues/1104)
RUN rm -rf /usr/lib/systemd/system/systemd*udev* /usr/lib/systemd/system/getty.target
# Also obscure any `getty` binaries (https://github.com/moby/moby/issues/4040#issuecomment-339022455)
RUN cp /bin/true /sbin/agetty
5 changes: 5 additions & 0 deletions Dockerfile.pac
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ RUN curl -L https://raw.githubusercontent.com/saltstack/salt-bootstrap/develop/b
RUN rm -rf /var/cache/{salt,pacman} \
&& (find / -name "*pyc" ; find / -name "__pycache__") |grep -v /proc | xargs rm -rf

# Remove unnecessary getty and udev targets that result in high CPU usage when using
# multiple containers with Molecule or Kitchen (https://github.com/ansible/molecule/issues/1104)
RUN rm -rf /usr/lib/systemd/system/systemd*udev* /usr/lib/systemd/system/getty.target
# Also obscure any `getty` binaries (https://github.com/moby/moby/issues/4040#issuecomment-339022455)
RUN cp /bin/true /sbin/agetty
6 changes: 6 additions & 0 deletions Dockerfile.yum
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ RUN if [ "${DISTRO_NAME}" = "amazonlinux" -a "${DISTRO_VERSION}" = "1" ]; \
RUN rm -rf /var/cache/{salt,yum} \
&& (find / -name "*pyc" ; find / -name "__pycache__") |grep -v /proc | xargs rm -rf

# Remove unnecessary getty and udev targets that result in high CPU usage when using
# multiple containers with Molecule or Kitchen (https://github.com/ansible/molecule/issues/1104)
RUN rm -rf /usr/lib/systemd/system/systemd*udev* /usr/lib/systemd/system/getty.target || true
# Also obscure any `getty` binaries (https://github.com/moby/moby/issues/4040#issuecomment-339022455)
RUN cp /bin/true /sbin/agetty
RUN if [ -e /sbin/mingetty ]; then cp /bin/true /sbin/mingetty; fi
6 changes: 6 additions & 0 deletions Dockerfile.zyp
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ RUN curl -L https://raw.githubusercontent.com/saltstack/salt-bootstrap/develop/b
RUN rm -rf /var/cache/{salt,zyp} \
&& (find / -name "*pyc" ; find / -name "__pycache__") |grep -v /proc | xargs rm -rf

# Remove unnecessary getty and udev targets that result in high CPU usage when using
# multiple containers with Molecule or Kitchen (https://github.com/ansible/molecule/issues/1104)
RUN rm -rf /usr/lib/systemd/system/systemd*udev* /usr/lib/systemd/system/getty.target
# Also obscure any `getty` binaries (https://github.com/moby/moby/issues/4040#issuecomment-339022455)
RUN cp /bin/true /usr/sbin/agetty
RUN cp /bin/true /usr/sbin/smart_agetty

0 comments on commit d7bac6c

Please sign in to comment.