From 929520e63d9e51ca7e7e51a71d56f476653fef99 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Sat, 5 Oct 2019 10:08:03 +0200 Subject: Optimize dockerile --- Dockerfile | 27 ++++++++++++--------------- Makefile | 7 +++++++ docker-entrypoint.sh | 12 ------------ files/docker-entrypoint.sh | 12 ++++++++++++ files/usr/bin/sx | 30 ++++++++++++++++++++++++++++++ sx.sh | 30 ------------------------------ 6 files changed, 61 insertions(+), 57 deletions(-) delete mode 100755 docker-entrypoint.sh create mode 100755 files/docker-entrypoint.sh create mode 100755 files/usr/bin/sx delete mode 100644 sx.sh diff --git a/Dockerfile b/Dockerfile index 8824b53..28ac530 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,14 +2,16 @@ FROM centos:centos7 MAINTAINER Suren A. Chilingaryan ENV container centos-tools - -RUN [ -e /etc/yum.conf ] && sed -i '/tsflags=nodocs/d' /etc/yum.conf || true -# Reinstall all packages to get man pages for them -RUN yum -y reinstall "*" && yum clean all +COPY files/ / +RUN \ +# Reinstall all packages to get man pages for them + [ -e /etc/yum.conf ] && sed -i '/tsflags=nodocs/d' /etc/yum.conf || true; \ + yum -y reinstall "*" && yum clean all && \ + \ # Swap out the systemd-container package and install all useful packages -RUN yum-config-manager -y --add-repo http://ufo.kit.edu/ands/repos/centos74/ && \ + yum-config-manager -y --add-repo http://ufo.kit.edu/ands/repos/centos74/ && \ yum -y install \ yum-utils glibc-utils bash-completion less file sed findutils net-tools man-db which bc tar \ openssh-clients lftp curl samba-client \ @@ -18,16 +20,11 @@ RUN yum-config-manager -y --add-repo http://ufo.kit.edu/ands/repos/centos74/ && mc \ kubernetes-client && \ yum -y --nogpgcheck install NetPIPE \ - && yum clean all - -COPY sx.sh /bin/sx -RUN chmod 775 /bin/sx + && yum clean all && \ + \ + chmod 775 /bin/sx && \ + chmod g=u /etc/passwd -# For ugly applications which want to resolve user name -RUN chmod g=u /etc/passwd - -COPY docker-entrypoint.sh / ENTRYPOINT ["/docker-entrypoint.sh"] - -CMD [ "/bin/sx" ] +CMD [ "/usr/bin/sx" ] diff --git a/Makefile b/Makefile index 34badf0..2381328 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,13 @@ rebuild: Dockerfile push: build docker push chsa/centos-tools:latest +login: + docker login -u `oc whoami` -p `oc whoami -t` docker-registry-default.kaas.kit.edu + +kaas: build login + docker tag chsa/centos-tools:latest docker-registry-default.kaas.kit.edu/kaas/kaas-manager:latest + docker push docker-registry-default.kaas.kit.edu/kaas/kaas-manager:latest + start: build if [ `docker ps | grep chsa/centos-tools | wc -l` -eq 0 ]; then \ if [ `docker ps -a | grep centos-tools | wc -l` -gt 0 ]; then \ diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100755 index f4d9f20..0000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash - -set -e - -if ! whoami &> /dev/null; then - if [ -w /etc/passwd ]; then - echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd - fi -fi - -echo "Running: $@" -exec "$@" diff --git a/files/docker-entrypoint.sh b/files/docker-entrypoint.sh new file mode 100755 index 0000000..f4d9f20 --- /dev/null +++ b/files/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +set -e + +if ! whoami &> /dev/null; then + if [ -w /etc/passwd ]; then + echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd + fi +fi + +echo "Running: $@" +exec "$@" diff --git a/files/usr/bin/sx b/files/usr/bin/sx new file mode 100755 index 0000000..beac660 --- /dev/null +++ b/files/usr/bin/sx @@ -0,0 +1,30 @@ +#!/bin/bash +export TERM=xterm +pid=0 + +function display_container_header { + echo "+=====================================================" + echo "| Container : $HOSTNAME" + echo "| OS : $(