mirror of
/repos/baseimage-docker.git
synced 2026-02-26 17:32:03 +01:00
Made services installation optional during build
You can user `ENV` directive in Dockerfile to disable the installation for some services or change `image/buildconfig`. The flags are : DISABLE_SSHD DISABLE_CRON DISABLE_SYSLOG
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
export LC_ALL=C
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
minimal_apt_get_install='apt-get install -y --no-install-recommends'
|
||||
|
||||
# Default services
|
||||
# Set 1 to the service you want to disable
|
||||
export DISABLE_SYSLOG=${DISABLE_SYSLOG:-0}
|
||||
export DISABLE_SSH=${DISABLE_SSH:-0}
|
||||
export DISABLE_CRON=${DISABLE_CRON:-0}
|
||||
|
||||
17
image/services/cron/cron.sh
Executable file
17
image/services/cron/cron.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
source /bd_build/buildconfig
|
||||
set -x
|
||||
|
||||
$minimal_apt_get_install cron
|
||||
mkdir /etc/service/cron
|
||||
chmod 600 /etc/crontab
|
||||
cp /bd_build/services/cron/cron.runit /etc/service/cron/run
|
||||
|
||||
## Remove useless cron entries.
|
||||
# Checks for lost+found and scans for mtab.
|
||||
rm -f /etc/cron.daily/standard
|
||||
rm -f /etc/cron.daily/upstart
|
||||
rm -f /etc/cron.daily/dpkg
|
||||
rm -f /etc/cron.daily/password
|
||||
rm -f /etc/cron.weekly/fstrim
|
||||
25
image/services/sshd/sshd.sh
Executable file
25
image/services/sshd/sshd.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
source /bd_build/buildconfig
|
||||
set -x
|
||||
|
||||
SSHD_BUILD_PATH=/bd_build/services/sshd
|
||||
|
||||
## Install the SSH server.
|
||||
$minimal_apt_get_install openssh-server
|
||||
mkdir /var/run/sshd
|
||||
mkdir /etc/service/sshd
|
||||
touch /etc/service/sshd/down
|
||||
cp $SSHD_BUILD_PATH/sshd.runit /etc/service/sshd/run
|
||||
cp $SSHD_BUILD_PATH/sshd_config /etc/ssh/sshd_config
|
||||
cp $SSHD_BUILD_PATH/00_regen_ssh_host_keys.sh /etc/my_init.d/
|
||||
|
||||
## Install default SSH key for root and app.
|
||||
mkdir -p /root/.ssh
|
||||
chmod 700 /root/.ssh
|
||||
chown root:root /root/.ssh
|
||||
cp $SSHD_BUILD_PATH/keys/insecure_key.pub /etc/insecure_key.pub
|
||||
cp $SSHD_BUILD_PATH/keys/insecure_key /etc/insecure_key
|
||||
chmod 644 /etc/insecure_key*
|
||||
chown root:root /etc/insecure_key*
|
||||
cp $SSHD_BUILD_PATH/enable_insecure_key /usr/sbin/
|
||||
24
image/services/syslog-ng/syslog-ng.sh
Executable file
24
image/services/syslog-ng/syslog-ng.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
source /bd_build/buildconfig
|
||||
set -x
|
||||
|
||||
SYSLOG_NG_BUILD_PATH=/bd_build/services/syslog-ng
|
||||
|
||||
## Install a syslog daemon.
|
||||
$minimal_apt_get_install syslog-ng-core
|
||||
mkdir /etc/service/syslog-ng
|
||||
cp $SYSLOG_NG_BUILD_PATH/syslog-ng.runit /etc/service/syslog-ng/run
|
||||
mkdir -p /var/lib/syslog-ng
|
||||
cp $SYSLOG_NG_BUILD_PATH/syslog_ng_default /etc/default/syslog-ng
|
||||
touch /var/log/syslog
|
||||
chmod u=rw,g=r,o= /var/log/syslog
|
||||
cp $SYSLOG_NG_BUILD_PATH/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
|
||||
|
||||
## Install syslog to "docker logs" forwarder.
|
||||
mkdir /etc/service/syslog-forwarder
|
||||
cp $SYSLOG_NG_BUILD_PATH/syslog-forwarder.runit /etc/service/syslog-forwarder/run
|
||||
|
||||
## Install logrotate.
|
||||
$minimal_apt_get_install logrotate
|
||||
cp $SYSLOG_NG_BUILD_PATH/logrotate_syslogng /etc/logrotate.d/syslog-ng
|
||||
@@ -19,54 +19,11 @@ ln -s /etc/container_environment.sh /etc/profile.d/
|
||||
## Install runit.
|
||||
$minimal_apt_get_install runit
|
||||
|
||||
## Install a syslog daemon.
|
||||
$minimal_apt_get_install syslog-ng-core
|
||||
mkdir /etc/service/syslog-ng
|
||||
cp /bd_build/runit/syslog-ng /etc/service/syslog-ng/run
|
||||
mkdir -p /var/lib/syslog-ng
|
||||
cp /bd_build/config/syslog_ng_default /etc/default/syslog-ng
|
||||
touch /var/log/syslog
|
||||
chmod u=rw,g=r,o= /var/log/syslog
|
||||
cp /bd_build/config/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
|
||||
|
||||
## Install syslog to "docker logs" forwarder.
|
||||
mkdir /etc/service/syslog-forwarder
|
||||
cp /bd_build/runit/syslog-forwarder /etc/service/syslog-forwarder/run
|
||||
|
||||
## Install logrotate.
|
||||
$minimal_apt_get_install logrotate
|
||||
cp /bd_build/config/logrotate_syslogng /etc/logrotate.d/syslog-ng
|
||||
## Install a syslog daemon and logrotate.
|
||||
[ "$DISABLE_SYSLOG" -eq 0 ] && /bd_build/services/syslog-ng/syslog-ng.sh
|
||||
|
||||
## Install the SSH server.
|
||||
$minimal_apt_get_install openssh-server
|
||||
mkdir /var/run/sshd
|
||||
mkdir /etc/service/sshd
|
||||
touch /etc/service/sshd/down
|
||||
cp /bd_build/runit/sshd /etc/service/sshd/run
|
||||
cp /bd_build/config/sshd_config /etc/ssh/sshd_config
|
||||
cp /bd_build/00_regen_ssh_host_keys.sh /etc/my_init.d/
|
||||
|
||||
## Install default SSH key for root and app.
|
||||
mkdir -p /root/.ssh
|
||||
chmod 700 /root/.ssh
|
||||
chown root:root /root/.ssh
|
||||
cp /bd_build/insecure_key.pub /etc/insecure_key.pub
|
||||
cp /bd_build/insecure_key /etc/insecure_key
|
||||
chmod 644 /etc/insecure_key*
|
||||
chown root:root /etc/insecure_key*
|
||||
cp /bd_build/bin/enable_insecure_key /usr/sbin/
|
||||
[ "$DISABLE_SSH" -eq 0 ] && /bd_build/services/sshd/sshd.sh
|
||||
|
||||
## Install cron daemon.
|
||||
$minimal_apt_get_install cron
|
||||
mkdir /etc/service/cron
|
||||
chmod 600 /etc/crontab
|
||||
cp /bd_build/runit/cron /etc/service/cron/run
|
||||
|
||||
## Remove useless cron entries.
|
||||
# Checks for lost+found and scans for mtab.
|
||||
rm -f /etc/cron.daily/standard
|
||||
rm -f /etc/cron.daily/upstart
|
||||
rm -f /etc/cron.daily/dpkg
|
||||
rm -f /etc/cron.daily/password
|
||||
rm -f /etc/cron.weekly/fstrim
|
||||
|
||||
[ "$DISABLE_CRON" -eq 0 ] && /bd_build/services/cron/cron.sh
|
||||
|
||||
Reference in New Issue
Block a user