Compare commits

...
Sign in to create a new pull request.

6 commits

Author SHA1 Message Date
Marek Skalický
939845fe49 Do sync from upstream -
https://github.com/sclorg/s2i-base-container/tree/master/base
2017-12-05 11:18:35 +01:00
Honza Horak
0bcdd208bf Bump RELEASE for rebuild for new s2i-core 2017-12-04 17:29:34 +01:00
Adam Miller
88ecb1a474 Bump RELEASE for automatic rebuild 2017-11-14 14:18:59 -06:00
Adam Miller
a9b260335d Bump RELEASE for automatic rebuild 2017-09-21 14:25:29 -05:00
Adam Miller
02f9a800b1 Bump RELEASE for automatic rebuild 2017-08-24 16:57:12 -05:00
Adam Miller
2c05d89746 Bump RELEASE for automatic rebuild 2017-07-25 16:23:57 -05:00
8 changed files with 131 additions and 179 deletions

View file

@ -1,45 +1,36 @@
# This image is the base image for all OpenShift v3 language Docker images.
FROM fedora:26
FROM registry.fedoraproject.org/26/s2i-core
LABEL \
io.openshift.s2i.scripts-url=image:///usr/libexec/s2i \
io.s2i.scripts-url=image:///usr/libexec/s2i
ENV SUMMARY="Base image with essential libraries and tools used as a base for \
builder images like perl, python, ruby, etc." \
DESCRIPTION="The s2i-base image, being built upon s2i-core, provides any \
images layered on top of it with all the tools needed to use source-to-image \
functionality. Additionally, s2i-base also contains various libraries needed for \
it to serve as a base for other builder images, like s2i-python or s2i-ruby." \
NAME=s2i-base \
VERSION=1 \
RELEASE=14 \
ARCH=x86_64
ENV NAME=s2i-base VERSION=1 RELEASE=8 ARCH=x86_64
LABEL BZComponent="$NAME" \
Name="$FGC/$NAME" \
Version="$VERSION" \
Release="$RELEASE.$DISTTAG" \
Architecture="$ARCH"
ENV \
# DEPRECATED: Use above LABEL instead, because this will be removed in future versions.
STI_SCRIPTS_URL=image:///usr/libexec/s2i \
# Path to be used in other layers to place s2i scripts into
STI_SCRIPTS_PATH=/usr/libexec/s2i \
# The $HOME is not set by default, but some applications needs this variable
# TODO: There is a bug in rhel7.1 image where the PATH variable is not exported
# properly as Docker image metadata, which causes the $PATH variable do not
# expand properly.
HOME=/opt/app-root/src \
PATH=/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.description="$DESCRIPTION" \
io.k8s.display-name="s2i base" \
com.redhat.component="$NAME" \
name="$FGC/$NAME" \
version="$VERSION" \
release="$RELEASE.$DISTTAG" \
architecture="$ARCH" \
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
# This is the list of basic dependencies that all language Docker image can
# consume.
# Also setup the 'openshift' user that is used for the build execution and for the
# application runtime execution.
# TODO: Use better UID and GID values
RUN dnf repolist > /dev/null && \
INSTALL_PKGS="autoconf \
RUN INSTALL_PKGS="autoconf \
automake \
bsdtar \
bzip2 \
findutils \
gcc-c++ \
gd-devel \
gdb \
gettext \
git \
libcurl-devel \
libxml2-devel \
@ -48,33 +39,16 @@ RUN dnf repolist > /dev/null && \
make \
mariadb-devel \
mariadb-libs \
npm \
openssl-devel \
patch \
postgresql-devel \
procps-ng \
redhat-rpm-config \
scl-utils \
sqlite-devel \
tar \
unzip \
wget \
which \
yum-utils \
zlib-devel" && \
mkdir -p ${HOME}/.pki/nssdb && \
chown -R 1001:0 ${HOME}/.pki && \
dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
dnf clean all -y && \
useradd -u 1001 -r -g 0 -d ${HOME} -s /sbin/nologin \
-c "Default Application User" default && \
chown -R 1001:0 /opt/app-root
# Copy executable utilities.
COPY bin/ /usr/bin/
# Directory with the sources is set as the working directory so all STI scripts
# can execute relative to this path.
WORKDIR ${HOME}
CMD ["base-usage"]
dnf clean all -y

104
README.md Normal file
View file

@ -0,0 +1,104 @@
OpenShift base images
========================================
This repository contains Dockerfiles for images which serve as base images with all the
essential libraries and tools needed for OpenShift language images, for example:
* [s2i-ruby](https://github.com/sclorg/s2i-ruby-container)
* [s2i-nodejs](https://github.com/sclorg/s2i-nodejs-container)
* [s2i-python](https://github.com/sclorg/s2i-python-container)
* [s2i-perl](https://github.com/sclorg/s2i-perl-container)
* [s2i-php](https://github.com/sclorg/s2i-php-container)
This container image also installs several development libraries, that are
often required in the builder images above. It also includes NPM package manager.
Sharing those development packages in a common layer saves disk space and
improves pulling speed.
NPM, a package manager for Node.js, offers a pleasant way to install JavaScript
libraries, that are often needed as static files for various web applications.
In order to offer good experience for web developers, the NPM package manager
is also installed in the image.
For containers where the development libraries and NPM package manager are not
necessary, users are advised to use the s2i-core variant of this container image.
Description
-----------
OpenShift S2I images use [Software Collections](https://www.softwarecollections.org/en/)
packages to provide the latest versions of various software.
The SCL packages are released more frequently than the RHEL or CentOS systems,
which are unlikely to change for several years.
We rely on RHEL and CentOS for base images, on the other hand,
because those are stable, supported, and secure platforms.
Normally, SCL requires manual operation to enable the collection you want to use.
This is burdensome and can be prone to error.
The OpenShift S2I approach is to set Bash environment variables that
serve to automatically enable the desired collection:
* `BASH_ENV`: enables the collection for all non-interactive Bash sessions
* `ENV`: enables the collection for all invocations of `/bin/sh`
* `PROMPT_COMMAND`: enables the collection in interactive shell
Two examples:
* If you specify `BASH_ENV`, then all your `#!/bin/bash` scripts
do not need to call `scl enable`.
* If you specify `PROMPT_COMMAND`, then on execution of the
`docker exec ... /bin/bash` command, the collection will be automatically enabled.
*Note*:
Executables in Software Collections packages (e.g., `ruby`)
are not directly in a directory named in the `PATH` environment variable.
This means that you cannot do:
$ docker exec <cid> ... ruby
but must instead do:
$ docker exec <cid> ... /bin/bash -c ruby
The `/bin/bash -c`, along with the setting the appropriate environment variable,
ensures the correct `ruby` executable is found and invoked.
Usage
------------------------
Choose either the CentOS7 or RHEL7 base image:
* **RHEL7 base image**
To build a RHEL7 based image, you need to build it on properly subscribed RHEL machine.
```
$ git clone --recursive https://github.com/sclorg/s2i-base-container.git
$ cd s2i-base-container
$ make build VERSIONS=base TARGET=rhel7
```
* **CentOS7 base image**
This image is available on DockerHub. To download it run:
```console
docker pull sclorg/s2i-base-centos7
```
To build a Base image from scratch run:
```
$ git clone --recursive https://github.com/sclorg/s2i-base-container.git
$ cd s2i-base-container
$ make build VERSIONS=base
```
**Notice: By omitting the `VERSION` parameter, the build/test action will be performed
on all provided versions of s2i image.**
See also
--------
Dockerfile and other sources are available on https://github.com/sclorg/s2i-base-container.
In that repository you also can find another variants of S2I base Dockerfiles.
Dockerfile for CentOS is called Dockerfile, Dockerfile for RHEL is called Dockerfile.rhel7.

View file

@ -1,24 +0,0 @@
#!/bin/sh -e
cat <<EOF
This image serves as the base image for all OpenShift v3 S2I builder images.
It provides all essential libraries and development tools needed to
successfully build and run an application.
To use this image as a base image, you need to have 's2i/bin' directory in the
same directory as your S2I image Dockerfile. This directory should contain S2I
scripts.
This base image also provides the default user you should use to run your
application. Your Dockerfile should include this instruction after you finish
installing software:
USER default
The default directory for installing your application sources is
'/opt/app-root/src' and the WORKDIR and HOME for the 'default' user is set
to this directory as well. In your S2I scripts, you don't have to use absolute
path, but rather rely on the relative path.
To learn more about S2I visit: https://github.com/openshift/source-to-image
EOF

View file

@ -1,92 +0,0 @@
#!/usr/bin/python
"""
Script for parsing cgroup information
This script will read some limits from the cgroup system and parse
them, printing out "VARIABLE=VALUE" on each line for every limit that is
successfully read. Output of this script can be directly fed into
bash's export command. Recommended usage from a bash script:
set -o errexit
export_vars=$(cgroup-limits) ; export $export_vars
Variables currently supported:
MAX_MEMORY_LIMIT_IN_BYTES
Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
currently constant value of 9223372036854775807.
MEMORY_LIMIT_IN_BYTES
Maximum amount of user memory in bytes. If this value is set
to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
there is no limit set. The value is taken from
/sys/fs/cgroup/memory/memory.limit_in_bytes
NUMBER_OF_CORES
Number of detected CPU cores that can be used. This value is
calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
NO_MEMORY_LIMIT
Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
can act as if no memory limit was set. Undefined otherwise.
"""
from __future__ import print_function
import sys
def _read_file(path):
try:
with open(path, 'r') as f:
return f.read().strip()
except IOError:
return None
def get_memory_limit():
"""
Read memory limit, in bytes.
"""
limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
if limit is None or not limit.isdigit():
print("Warning: Can't detect memory limit from cgroups",
file=sys.stderr)
return None
return int(limit)
def get_number_of_cores():
"""
Read number of CPU cores.
"""
core_count = 0
line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
if line is None:
print("Warning: Can't detect number of CPU cores from cgroups",
file=sys.stderr)
return None
for group in line.split(','):
core_ids = list(map(int, group.split('-')))
if len(core_ids) == 2:
core_count += core_ids[1] - core_ids[0] + 1
else:
core_count += 1
return core_count
if __name__ == "__main__":
env_vars = {
"MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
"MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
"NUMBER_OF_CORES": get_number_of_cores()
}
env_vars = {k: v for k, v in env_vars.items() if v is not None}
if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
env_vars["NO_MEMORY_LIMIT"] = "true"
for key, value in env_vars.items():
print("{0}={1}".format(key, value))

View file

@ -1,2 +0,0 @@
#!/bin/bash
exec "$@"

View file

@ -1,6 +0,0 @@
#!/bin/sh
# Fix permissions on the given directory to allow group read/write of
# regular files and execute of directories.
find $1 -exec chgrp 0 {} \;
find $1 -exec chmod g+rw {} \;
find $1 -type d -exec chmod g+x {} +

View file

@ -1,2 +0,0 @@
# This file contains automatic SCL enablement.
unset BASH_ENV PROMPT_COMMAND ENV

View file

@ -6,7 +6,7 @@
# IMAGE_NAME specifies a name of the candidate image used for testing.
# The image has to be available before this script is executed.
#
IMAGE_NAME=${IMAGE_NAME-openshift/base-centos7-candidate}
IMAGE_NAME=${IMAGE_NAME-centos/s2i-base-centos7-candidate}
test_docker_run_usage() {
echo "Testing 'docker run' usage..."