From 502596a8dace40cd2c8c175070491bf12e0fe7b0 Mon Sep 17 00:00:00 2001 From: David Coppit Date: Sun, 14 May 2017 23:23:17 -0400 Subject: [PATCH] Switch to phusion's init and service run system --- mapids.sh => 50_remap_ids.sh | 13 ++++---- Dockerfile | 65 ++++++++++++++++++++---------------- dpkg-excludes | 16 +++++++++ start.sh => monitor.sh | 0 4 files changed, 59 insertions(+), 35 deletions(-) rename mapids.sh => 50_remap_ids.sh (93%) create mode 100644 dpkg-excludes rename start.sh => monitor.sh (100%) diff --git a/mapids.sh b/50_remap_ids.sh similarity index 93% rename from mapids.sh rename to 50_remap_ids.sh index 9a3c6fb..8ed6c9d 100755 --- a/mapids.sh +++ b/50_remap_ids.sh @@ -8,11 +8,7 @@ function ts { #----------------------------------------------------------------------------------------------------------------------- -function process_args { - # These are meant to be globals. - UMAP=$1 - GMAP=$2 - +function check_env_vars { for NAME_UID_GID in $UMAP do if [[ ! "$NAME_UID_GID" =~ ^[A-Za-z0-9._][-A-Za-z0-9._]*:[0-9]{1,}:[0-9]{1,}$ ]] @@ -74,7 +70,12 @@ function update_groups { #----------------------------------------------------------------------------------------------------------------------- -process_args "$@" +# Uses UMAP and GMAP +check_env_vars "$@" update_users "$UMAP" update_groups "$GMAP" + +chmod a+r /files/sample.conf +chmod a+x /files/monitor.py +chmod +x /files/runas.sh diff --git a/Dockerfile b/Dockerfile index c883c02..654f6bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,47 +2,54 @@ FROM phusion/baseimage:0.9.19 MAINTAINER David Coppit + +# Use baseimage-docker's init system +CMD ["/sbin/my_init"] + ENV DEBIAN_FRONTEND noninteractive +ADD dpkg-excludes /etc/dpkg/dpkg.cfg.d/excludes + +RUN \ + +set -x && \ + +# Create dir to keep things tidy. Make sure it's readable by $UID +mkdir /files && \ +chmod a+rwX /files && \ # Speed up APT -RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup \ - && echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache +echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup && \ +echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache && \ -RUN set -x \ - && apt-get update \ - && apt-get install -y python3-watchdog wget \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +apt-get update && \ +apt-get install -qy python3-watchdog wget && \ + +# clean up +apt-get clean && \ +rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ +/usr/share/man /usr/share/groff /usr/share/info \ +/usr/share/lintian /usr/share/linda /var/cache/man && \ +(( find /usr/share/doc -depth -type f ! -name copyright|xargs rm || true )) && \ +(( find /usr/share/doc -empty|xargs rmdir || true )) VOLUME ["/config", \ "/dir1", "/dir2", "/dir3", "/dir4", "/dir5", "/dir6", "/dir7", "/dir8", "/dir9", "/dir10", \ "/dir11", "/dir12", "/dir13", "/dir14", "/dir15", "/dir16", "/dir17", "/dir18", "/dir19", "/dir20"] -ENV UMAP "" -ENV GMAP "" - -# Create dir to keep things tidy. Make sure it's readable by $UID -RUN mkdir /files -RUN chmod a+rwX /files - -# Add default config file. Make sure it's readable by $UID -ADD sample.conf /files/sample.conf -RUN chmod a+r /files/sample.conf - -# Add scripts. Make sure start.sh and monitor.py are executable by $UID -ADD start.sh /files/ -RUN chmod a+x /files/start.sh -ADD monitor.py /files/ -RUN chmod a+x /files/monitor.py -ADD runas.sh /files/ -RUN chmod +x /files/runas.sh -ADD mapids.sh /files/ -RUN chmod +x /files/mapids.sh - # Set the locale, to help Python and the user's applications deal with files that have non-ASCII characters RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8 -CMD /files/mapids.sh "$UMAP" "$GMAP" && /files/start.sh +ENV UMAP "" +ENV GMAP "" + +# Add local files +COPY sample.conf monitor.py runas.sh /files/ + +ADD 50_remap_ids.sh /etc/my_init.d/ + +RUN mkdir /etc/service/monitor +ADD monitor.sh /etc/service/monitor/run +RUN chmod +x /etc/service/monitor/run diff --git a/dpkg-excludes b/dpkg-excludes new file mode 100644 index 0000000..b028b9d --- /dev/null +++ b/dpkg-excludes @@ -0,0 +1,16 @@ +path-exclude /usr/share/doc/* +# we need to keep copyright files for legal reasons +path-include /usr/share/doc/*/copyright +path-exclude /usr/share/man/* +path-exclude /usr/share/groff/* +path-exclude /usr/share/info/* +# lintian stuff is small, but really unnecessary +path-exclude /usr/share/lintian/* +path-exclude /usr/share/linda/* +# Drop locales except English +path-exclude=/usr/share/locale/* +path-include=/usr/share/locale/en/* +path-include=/usr/share/locale/locale.alias + + + diff --git a/start.sh b/monitor.sh similarity index 100% rename from start.sh rename to monitor.sh