Switch to phusion's init and service run system
This commit is contained in:
@@ -8,11 +8,7 @@ function ts {
|
|||||||
|
|
||||||
#-----------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
function process_args {
|
function check_env_vars {
|
||||||
# These are meant to be globals.
|
|
||||||
UMAP=$1
|
|
||||||
GMAP=$2
|
|
||||||
|
|
||||||
for NAME_UID_GID in $UMAP
|
for NAME_UID_GID in $UMAP
|
||||||
do
|
do
|
||||||
if [[ ! "$NAME_UID_GID" =~ ^[A-Za-z0-9._][-A-Za-z0-9._]*:[0-9]{1,}:[0-9]{1,}$ ]]
|
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_users "$UMAP"
|
||||||
update_groups "$GMAP"
|
update_groups "$GMAP"
|
||||||
|
|
||||||
|
chmod a+r /files/sample.conf
|
||||||
|
chmod a+x /files/monitor.py
|
||||||
|
chmod +x /files/runas.sh
|
||||||
65
Dockerfile
65
Dockerfile
@@ -2,47 +2,54 @@ FROM phusion/baseimage:0.9.19
|
|||||||
|
|
||||||
MAINTAINER David Coppit <david@coppit.org>
|
MAINTAINER David Coppit <david@coppit.org>
|
||||||
|
|
||||||
|
|
||||||
|
# Use baseimage-docker's init system
|
||||||
|
CMD ["/sbin/my_init"]
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
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
|
# Speed up APT
|
||||||
RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup \
|
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 "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache && \
|
||||||
|
|
||||||
RUN set -x \
|
apt-get update && \
|
||||||
&& apt-get update \
|
apt-get install -qy python3-watchdog wget && \
|
||||||
&& apt-get install -y python3-watchdog wget \
|
|
||||||
&& apt-get clean \
|
# clean up
|
||||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
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", \
|
VOLUME ["/config", \
|
||||||
"/dir1", "/dir2", "/dir3", "/dir4", "/dir5", "/dir6", "/dir7", "/dir8", "/dir9", "/dir10", \
|
"/dir1", "/dir2", "/dir3", "/dir4", "/dir5", "/dir6", "/dir7", "/dir8", "/dir9", "/dir10", \
|
||||||
"/dir11", "/dir12", "/dir13", "/dir14", "/dir15", "/dir16", "/dir17", "/dir18", "/dir19", "/dir20"]
|
"/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
|
# 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
|
RUN locale-gen en_US.UTF-8
|
||||||
ENV LANG en_US.UTF-8
|
ENV LANG en_US.UTF-8
|
||||||
ENV LANGUAGE en_US:en
|
ENV LANGUAGE en_US:en
|
||||||
ENV LC_ALL en_US.UTF-8
|
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
|
||||||
|
|||||||
16
dpkg-excludes
Normal file
16
dpkg-excludes
Normal file
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user