Skip to content

Commit

Permalink
docker: Ninja build generator added to containers, size optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed Apr 12, 2021
1 parent 61bc21d commit 695a589
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 199 deletions.
10 changes: 5 additions & 5 deletions docker/abap-api-tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ FROM node:15
ENV container docker

# dev tools
RUN apt-get update && apt-get install -y vim
RUN printf "\n# dev aliases\nalias ll='ls $LS_OPTIONS -l'\nalias l='ls $LS_OPTIONS -lA'\nalias e=exit\nalias dist='rm -rf dist && cp -r /work/dist . && chmod +x dist/abap.js'\n" >> ~/.bashrc

# node_modules path
RUN printf "\n# node modules\n" >> ~/.bashrc && \
RUN \
apt-get update && apt-get install -y vim rm -rf /var/lib/apt/lists/* && \
printf "\n# dev aliases\nalias ll='ls $LS_OPTIONS -l'\nalias l='ls $LS_OPTIONS -lA'\nalias e=exit\nalias dist='rm -rf dist && cp -r /work/dist . && chmod +x dist/abap.js'\n" >> ~/.bashrc && \
# node_modules path
printf "\n# node modules\n" >> ~/.bashrc && \
printf "export PATH=node_modules/.bin:$PATH\n" >> ~/.bashrc

INCLUDE+ common/sapnwrfcsdk.Dockerfile
Expand Down
57 changes: 30 additions & 27 deletions docker/centos-systemd.Dockerfile → docker/centos-local.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# SPDX-License-Identifier: Apache-2.0

#
# Centos 7 with systemd
# Centos 7 with systemd and SAP NWRFC SDK
#
# docker build --rm --no-cache -t local/c7-systemd -f centos-systemd.Dockerfile .
# docker build --rm --no-cache -t local/c7-systemd -f centos-local.Dockerfile .
#

FROM centos:7
Expand All @@ -22,37 +22,39 @@ ENV container docker
# timezone # https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes
ENV TZ=Europe/Berlin

# admin/work user
ARG adminuser=www-admin
ARG dev_tools="sudo curl wget git unzip vim tree tmux iproute iputils"
ARG dev_libs="uuidd make zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel"


# Add sudo user
RUN yum -y install jq sudo && \
useradd -G wheel --create-home --shell /bin/bash ${adminuser}
RUN echo "%wheel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
USER ${adminuser}
WORKDIR /home/${adminuser}
RUN printf "alias e=exit\nalias ..=cd..\nalias :q=exit\nalias ll='ls -l'\nalias la='ls -la'\nalias distro='cat /etc/*-release'\n" > .bash_aliases && \
printf "\n#aliases\nsource ~/.bash_aliases\n\n# colors\nexport TERM=xterm-256color\n" >> ~/.bashrc

# root
USER root

# utf-8 locale https://serverfault.com/questions/275403/how-do-i-change-my-locale-to-utf-8-in-centos
RUN localedef -c -f UTF-8 -i en_US en_US.UTF-8
RUN \
# admin user
yum -y install sudo && \
useradd -G wheel --create-home --shell /bin/bash ${adminuser} && \
echo "%wheel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers && \
printf "alias e=exit\nalias ..=cd..\nalias :q=exit\nalias ll='ls -l'\nalias la='ls -la'\nalias distro='cat /etc/*-release'\n" > /home/${adminuser}/.bash_aliases && \
chown ${adminuser} /home/${adminuser}/.bash_aliases && chgrp ${adminuser} /home/${adminuser}/.bash_aliases && \
printf "\n#aliases\nsource ~/.bash_aliases\n\n# colors\nexport TERM=xterm-256color\n" >> /home/${adminuser}/.bashrc && \
# utf-8 locale https://serverfault.com/questions/275403/how-do-i-change-my-locale-to-utf-8-in-centos
localedef -c -f UTF-8 -i en_US en_US.UTF-8

ENV LC_ALL=en_US.UTF-8

# required packages
RUN yum -y update && \
yum -y groupinstall "Development tools" && \
yum -y install ${dev_tools} && \
yum -y install ${dev_libs} && \
yum clean all

# devtoolset-8
RUN yum -y install centos-release-scl && \
yum -y install devtoolset-8 && yum clean all && \
scl enable devtoolset-8 -- bash
yum -y install ${dev_tools} ${dev_libs} \
# ninja build: https://centos.pkgs.org/7/okey-x86_64/ninja-build-1.8.2-1.el7.x86_64.rpm.html
http://repo.okay.com.mx/centos/7/x86_64/release/okay-release-1-1.noarch.rpm \
# devtoolset-8
centos-release-scl && \
# devtoolset-8 && Ninja
yum install -y ninja-build devtoolset-8 && yum clean all && \
scl enable devtoolset-8 -- bash && \
printf "\n# devtools-8\nsource /opt/rh/devtoolset-8/enable\n" >> /home/${adminuser}/.bashrc

# https://hub.docker.com/_/centos
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
Expand All @@ -65,15 +67,16 @@ RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;

USER ${adminuser}

# devtools-8 enable
RUN printf "\n# devtools-8\nsource /opt/rh/devtoolset-8/enable\n" >> ~/.bashrc

# nwrfcsdk
INCLUDE+ common/sapnwrfcsdk.Dockerfile

# cleanup
RUN rm -rf /tmp/* && \
systemctl mask systemd-machine-id-commit && systemctl enable multi-user.target && systemctl set-default multi-user.target

# work user
USER ${adminuser}
WORKDIR /home/${adminuser}

VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
9 changes: 1 addition & 8 deletions docker/centos-node.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,9 @@
# docker start -ai centos-node
#

# https://github.com/nodejs/node/blob/master/BUILDING.md#supported-toolchains
FROM local/c7-systemd

LABEL maintainer="[email protected]"
LABEL version="1.0"
LABEL description="NodeJS RFC Connector"

ARG adminuser=www-admin

# nvm
INCLUDE+ common/nodejs.Dockerfile

USER ${adminuser}
CMD ["/bin/bash"]
15 changes: 2 additions & 13 deletions docker/centos-python.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,9 @@
# docker start -ai centos-python
#

# https://github.com/nodejs/node/blob/master/BUILDING.md#supported-toolchains
FROM local/c7-systemd

LABEL maintainer="[email protected]"
LABEL version="2.0"
LABEL description="Python RFC Connector"

ARG adminuser=www-admin

# python
INCLUDE+ common/python.Dockerfile

# cleanup
USER root
RUN rm -rf /tmp/*

USER ${adminuser}
CMD ["/bin/bash"]
CMD ["/bin/bash"]
21 changes: 11 additions & 10 deletions docker/common/nodejs.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@

# node js

# ARG NVM_VERSION=0.38.0
# ARG CMAKE_VERSION=3.19.1
# as admin user

USER ${adminuser}

# cmake
RUN cd /tmp && \
RUN \
#
#cmake
#
cd /tmp && \
CMAKE_VERSION=$(curl -s https://api.github.com/repos/Kitware/CMake/releases/latest | grep '"tag_name"' | sed -E 's/.*"v([^"]+)".*/\1/') && \
wget -q https://github.com/Kitware/CMake/releases/latest/download/cmake-${CMAKE_VERSION}.tar.gz && \
tar -xzvf cmake-${CMAKE_VERSION}.tar.gz && \
cd cmake-${CMAKE_VERSION} && \
./bootstrap && \
make -j4 && sudo make install

# nvm
RUN printf "\n# nvm" >> ~/.bashrc && \
make -j4 && sudo make install && \
#
# nvm
#
printf "\n# nvm" >> ~/.bashrc && \
NVM_VERSION=$(curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep '"tag_name"' | sed -E 's/.*"v([^"]+)".*/\1/') && \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash && \
bash -ic "nvm install node && nvm alias default node && nvm install lts/dubnium && nvm install lts/erbium && nvm install lts/fermium" && \
Expand Down
52 changes: 30 additions & 22 deletions docker/common/python.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#
# SPDX-License-Identifier: Apache-2.0


# python

ARG venv_base=/home/${adminuser}/.virtualenvs
ARG venv_base=~/.virtualenvs
ARG py36=3.6.13
ARG py37=3.7.10
ARG py38=3.8.9
Expand All @@ -15,35 +16,42 @@ ARG py38venv=py38
ARG py39venv=py39
ARG dev_python="pip wheel pytest cython ipython"

USER ${adminuser}
# as admin user

# pyenv
RUN git clone https://github.com/pyenv/pyenv.git .pyenv && \
RUN \
#
# Clone and configure
#
# paths
PYENV_ROOT=~/.pyenv && PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH && \
# git
git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT && \
git clone https://github.com/pyenv/pyenv-virtualenv.git $PYENV_ROOT/plugins/pyenv-virtualenv && \
git clone https://github.com/pyenv/pyenv-update.git $PYENV_ROOT/plugins/pyenv-update && \
# pyenv
printf '\n#pyenv\nexport PYENV_ROOT="$HOME/.pyenv"\n' >> .bashrc && \
printf 'export PATH="$PYENV_ROOT/bin:$PATH"\n' >> .bashrc && \
printf 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi\n' >> .bashrc
ENV PYENV_ROOT /home/${adminuser}/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN pyenv install ${py39} && \
pyenv install ${py38} && \
pyenv install ${py37} && \
pyenv install ${py36}

# pyenv-virtualenv
USER ${adminuser}
RUN git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv && \
printf 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi\n' >> .bashrc && \
# pyenv-virtualenv
printf 'eval "$(pyenv virtualenv-init -)"\n' >> ~/.bashrc && \
printf 'export PYENV_VIRTUALENV_DISABLE_PROMPT=1\n' >> ~/.bashrc
RUN pyenv virtualenv ${py36} ${py36venv} && \
printf 'export PYENV_VIRTUALENV_DISABLE_PROMPT=1\n' >> ~/.bashrc && \
#
# Build
#
# pyenv
pyenv install ${py36} && \
pyenv install ${py37} && \
pyenv install ${py38} && \
pyenv install ${py39} && \
# pyenv-virtualenv
pyenv virtualenv ${py36} ${py36venv} && \
pyenv virtualenv ${py37} ${py37venv} && \
pyenv virtualenv ${py38} ${py38venv} && \
pyenv virtualenv ${py39} ${py39venv}
RUN bash -ic "source ~/.bashrc && \
pyenv virtualenv ${py39} ${py39venv} && \
# build tools
bash -ic "source ~/.bashrc && \
pyenv activate ${py36venv} && pip install --upgrade ${dev_python} && \
pyenv activate ${py37venv} && pip install --upgrade ${dev_python} && \
pyenv activate ${py38venv} && pip install --upgrade ${dev_python} && \
pyenv activate ${py39venv} && pip install --upgrade ${dev_python}" && \
printf "pyenv activate ${py39venv}\n" >> ~/.bashrc

# pyenv-update
RUN git clone https://github.com/pyenv/pyenv-update.git $(pyenv root)/plugins/pyenv-update
12 changes: 7 additions & 5 deletions docker/common/sapnwrfcsdk.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ ARG nwrfc_host=/sap
ARG nwrfc_source=${nwrfc_host}/${nwrfc_version}
ARG nwrfc_target=/usr/local/sap

RUN printf "\n# nwrfc sdk \n" >> ~/.bashrc && \
printf "export SAPNWRFC_HOME=${nwrfc_target}/nwrfcsdk\n" >> ~/.bashrc
USER root
# as root user

RUN mkdir -p ${nwrfc_target}
COPY --chown=www-admin:www-admin ${nwrfc_source} ${nwrfc_target}/${nwrfc_version}
RUN chmod -R a+r ${nwrfc_target}/${nwrfc_version} && \
COPY --chown=${adminuser}:${adminuser} ${nwrfc_source} ${nwrfc_target}/${nwrfc_version}

RUN printf "\n# nwrfc sdk \n" >> ~/.bashrc && \
printf "export SAPNWRFC_HOME=${nwrfc_target}/nwrfcsdk\n" >> /home/${adminuser}/.bashrc && \
chmod -R a+r ${nwrfc_target}/${nwrfc_version} && \
chmod -R a+x ${nwrfc_target}/${nwrfc_version}/bin && \
chmod -R a+x ${nwrfc_target}/${nwrfc_version}/lib && \
printf "# include nwrfcsdk\n${nwrfc_target}/${nwrfc_version}/lib\n" | tee /etc/ld.so.conf.d/nwrfcsdk.conf && \
Expand Down
13 changes: 3 additions & 10 deletions docker/fedora-node.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,9 @@
# docker start -ai fedora-node
#

# https://github.com/nodejs/node/blob/master/BUILDING.md#supported-toolchains
FROM local/fedora

LABEL maintainer="[email protected]"
LABEL version="2.0"
LABEL description="NodeJS RFC Connector"
# nodejs
INCLUDE+ common/nodejs.dockerfile

ARG adminuser=www-admin

INCLUDE+ common/nodejs.Dockerfile

USER ${adminuser}
CMD ["/bin/bash"]
CMD ["/bin/bash"]
13 changes: 1 addition & 12 deletions docker/fedora-python.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,9 @@
# docker start -ai fedora-python
#

# https://github.com/nodejs/node/blob/master/BUILDING.md#supported-toolchains
FROM local/fedora

LABEL maintainer="[email protected]"
LABEL version="2.0"
LABEL description="Python RFC Connector"

ARG adminuser=www-admin

# python
INCLUDE+ common/python.Dockerfile

# cleanup
USER root
RUN rm -rf /tmp/*

USER ${adminuser}
CMD ["/bin/bash"]
42 changes: 19 additions & 23 deletions docker/fedora.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,34 @@ ENV TZ=Europe/Berlin

ARG adminuser=www-admin
ARG dev_tools="sudo curl wget git unzip vim tree tmux iproute iputils"
ARG dev_libs="uuidd make zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel"
ARG dev_libs="uuidd make ninja-build zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel"

RUN \
# sudo user
dnf -y install sudo && \
useradd -G wheel --create-home --shell /bin/bash ${adminuser} && \
echo "%wheel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers && \
printf "alias e=exit\nalias ..=cd..\nalias :q=exit\nalias ll='ls -l'\nalias la='ls -la'\nalias distro='cat /etc/*-release'\n" > .bash_aliases && \
printf "\n#aliases\nsource ~/.bash_aliases\n\n# colors\nexport TERM=xterm-256color\n" >> /home/${adminuser}/.bashrc && \
# utf-8 locale https://serverfault.com/questions/275403/how-do-i-change-my-locale-to-utf-8-in-centos
# https://stackoverflow.com/questions/58304278/how-to-fix-character-map-file-utf-8-not-found
dnf -y install glibc-locale-source glibc-langpack-en && dnf clean all && rm -rf /var/cache/yum && \
localedef -c -f UTF-8 -i en_US en_US.UTF-8


# Add sudo user
RUN dnf -y install sudo && \
useradd -G wheel --create-home --shell /bin/bash ${adminuser}
RUN echo "%wheel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
USER ${adminuser}
WORKDIR /home/${adminuser}
RUN printf "alias e=exit\nalias ..=cd..\nalias :q=exit\nalias ll='ls -l'\nalias la='ls -la'\nalias distro='cat /etc/*-release'\n" > .bash_aliases && \
printf "\n#aliases\nsource ~/.bash_aliases\n\n# colors\nexport TERM=xterm-256color\n" >> ~/.bashrc

USER root

# utf-8 locale https://serverfault.com/questions/275403/how-do-i-change-my-locale-to-utf-8-in-centos
# https://stackoverflow.com/questions/58304278/how-to-fix-character-map-file-utf-8-not-found
RUN dnf -y install glibc-locale-source glibc-langpack-en
RUN localedef -c -f UTF-8 -i en_US en_US.UTF-8
ENV LC_ALL=en_US.UTF-8

# required packages
RUN dnf -y update && \
dnf -y groupinstall "Development tools" && \
dnf -y install ${dev_tools} && \
dnf -y install ${dev_libs} && \
dnf clean all

USER ${adminuser}
dnf -y install ${dev_tools} ${dev_libs} && \
dnf clean all && rm -rf /var/cache/yum

# nwrfcsdk
INCLUDE+ common/sapnwrfcsdk.Dockerfile

# cleanup
RUN rm -rf /tmp/*

USER ${adminuser}
# work user
USER ${adminuser}
WORKDIR /home/${adminuser}
Loading

0 comments on commit 695a589

Please sign in to comment.