Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added centos based dockerfile for UI and cccp.yml #171

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions Dockerfile.centos7
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
FROM registry.centos.org/centos/centos:7
MAINTAINER "Mohammed Zeeshan Ahmed"

ENV SOURCE_DIR /tmp/source
ENV WWW_DIR /var/www/html
ENV START_SCRIPT /opt/start-apache.sh

# RUN yum -y update && yum clean all

# Create dirs
RUN mkdir -p $SOURCE_DIR/dist \
$SOURCE_DIR/app \
$SOURCE_DIR/test \
$SOURCE_DIR/.git

# Add dirs
ADD app $SOURCE_DIR/app
ADD test $SOURCE_DIR/test

# Dot files
ADD .jshintrc $SOURCE_DIR/
ADD .bowerrc $SOURCE_DIR/
ADD .editorconfig $SOURCE_DIR/
ADD .travis.yml $SOURCE_DIR/

# Other files
ADD bower.json $SOURCE_DIR/
ADD Gruntfile.js $SOURCE_DIR/
ADD LICENSE $SOURCE_DIR/
ADD package.json $SOURCE_DIR/
ADD README.md $SOURCE_DIR/

# Add some git files for versioning
ADD .git/HEAD $SOURCE_DIR/.git/HEAD
ADD .git/refs $SOURCE_DIR/.git/refs

RUN yum -y install epel-release && \
yum -y install httpd \
mod_auth_kerb \
mod_proxy_html \
mod_ssl \
bzip2 \
git \
nodejs \
nodejs-legacy \
npm && \
cd $SOURCE_DIR && \
export GITREF=$(cat .git/HEAD | cut -d" " -f2) && \
export GITSHA1=$(cat .git/$GITREF) && \
echo "{\"git\": {\"sha1\": \"$GITSHA1\", \"ref\": \"$GITREF\"}}" > $WWW_DIR/app-version.json && \
cd $SOURCE_DIR && \
rm -rf $SOURCE_DIR/.git && \
git config --global url."https://".insteadOf git:// && \
cd $SOURCE_DIR && \
npm install && \
node_modules/bower/bin/bower install --allow-root && \
node_modules/grunt-cli/bin/grunt build --allow-root && \
cp -rf $SOURCE_DIR/dist/* $WWW_DIR && \
rm -rf $SOURCE_DIR && \
yum -y remove git nodejs nodejs-legacy npm bzip2 && \
yum clean all

ADD apache-site.conf /etc/httpd/conf.d/docker-site.conf
ADD start.sh $START_SCRIPT
RUN chmod +x $START_SCRIPT

# Exposed ports
EXPOSE 80 443

VOLUME ["/etc/apache2/server.crt", "/etc/apache2/server.key"]

CMD $START_SCRIPT
10 changes: 10 additions & 0 deletions cccp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This is for the purpose of building containers on the CentOS Community Container
# Pipeline. The containers are built, tested and delivered to registry.centos.org and
# lifecycled as well. A corresponding entry must exist in the container index itself,
# located at https://github.com/CentOS/container-index/tree/master/index.d
# You can know more at the following links:
# * https://github.com/CentOS/container-pipeline-service/blob/master/README.md
# * https://github.com/CentOS/container-index/blob/master/README.rst
# * https://wiki.centos.org/ContainerPipeline

job-id: docker-registry-frontend
108 changes: 108 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/bash

die() {
echo "ERROR: $1"
exit 2
}

mod_activate_deactivate() {
mod_name=$1;
en_en=$2;
httpd_path="/etc/httpd"
conf_path="${httpd_path}/conf.d"
conf_modules_path="${httpd_path}/conf.modules.d"

case ${mod_name} in
SSL)
mod_file1="${conf_path}/ssl.conf";
mod_file1_back="${mod_file1}.back"
mod_file2="${conf_modules_path}/00-ssl.conf"
mod_file2_back="${mod_file2}.back"
if [ ${en_en} -eq 0 ]; then
mv ${mod_file1} ${mod_file1_back};
mv ${mod_file2} ${mod_file2_back};
else
mv ${mod_file1_back} ${mod_file1};
mv ${mod_file2_back} ${mod_file2};
fi
;;
KERB)
mod_file1="${conf_modules_path}/10-auth_kerb.conf";
mod_file1_back="${mod_file1}.back"

if [ ${en_en} -eq 0 ]; then
mv ${mod_file1} ${mod_file1_back};
else
mv ${mod_file1_back} ${mod_file1};
fi
;;
esac
}

for item in SSL KERB; do
mod_activate_deactivate ${item} 0;
done

[[ -z "$ENV_DOCKER_REGISTRY_HOST" ]] && die "Missing environment variable: ENV_DOCKER_REGISTRY_HOST=url-to-your-registry"
[[ -z "$ENV_DOCKER_REGISTRY_PORT" ]] && ENV_DOCKER_REGISTRY_PORT=80
[[ -z "$ENV_REGISTRY_PROXY_FQDN" ]] && ENV_REGISTRY_PROXY_FQDN=$ENV_DOCKER_REGISTRY_HOST
[[ -z "$ENV_REGISTRY_PROXY_PORT" ]] && ENV_REGISTRY_PROXY_PORT=$ENV_DOCKER_REGISTRY_PORT

export DOCKER_REGISTRY_HOST=$ENV_DOCKER_REGISTRY_HOST
export DOCKER_REGISTRY_PORT=$ENV_DOCKER_REGISTRY_PORT
export REGISTRY_PROXY_FQDN=$ENV_REGISTRY_PROXY_FQDN
export REGISTRY_PROXY_PORT=$ENV_REGISTRY_PROXY_PORT

needModSsl=0
if [ -n "$ENV_DOCKER_REGISTRY_USE_SSL" ]; then
export DOCKER_REGISTRY_SCHEME=https
needModSsl=1
else
export DOCKER_REGISTRY_SCHEME=http
fi

# docker-registry-frontend acts as a proxy so may well
# have a different hostname than the registry itself.
echo "{\"host\": \"$ENV_REGISTRY_PROXY_FQDN\", \"port\": $ENV_REGISTRY_PROXY_PORT}" > /var/www/html/registry-host.json

# information about browse mode.
[[ x$ENV_MODE_BROWSE_ONLY =~ ^x(true|false)$ ]] || ENV_MODE_BROWSE_ONLY=false
# Overwrite browse-only option for now since only browse-only is working right now
ENV_MODE_BROWSE_ONLY=true
[[ -z "$ENV_DEFAULT_REPOSITORIES_PER_PAGE" ]] && ENV_DEFAULT_REPOSITORIES_PER_PAGE=20
[[ -z "$ENV_DEFAULT_TAGS_PER_PAGE" ]] && ENV_DEFAULT_TAGS_PER_PAGE=10
echo "{\"browseOnly\":$ENV_MODE_BROWSE_ONLY, \"defaultRepositoriesPerPage\":$ENV_DEFAULT_REPOSITORIES_PER_PAGE , \"defaultTagsPerPage\":$ENV_DEFAULT_TAGS_PER_PAGE }" > /var/www/html/app-mode.json
if [ "$ENV_MODE_BROWSE_ONLY" == "true" ]; then
export APACHE_ARGUMENTS='-D FRONTEND_BROWSE_ONLY_MODE'
fi

# Optionally enable Kerberos authentication and do some parameter checks
if [ -n "$ENV_AUTH_USE_KERBEROS" ]; then

[[ -z "$ENV_AUTH_NAME" ]] && die "Missing environment variable for Kerberos: ENV_AUTH_NAME"
[[ -z "$ENV_AUTH_KRB5_KEYTAB" ]] && die "Missing environment variable for Kerberos: ENV_AUTH_KRB5_KEYTAB"
[[ -z "$ENV_AUTH_KRB_REALMS" ]] && die "Missing environment variable for Kerberos: ENV_AUTH_KRB_REALMS"
[[ -z "$ENV_AUTH_KRB_SERVICE_NAME" ]] && die "Missing environment variable for Kerberos: ENV_AUTH_KRB_SERVICE_NAME"

mod_activate_deactivate KERB 1;
export USE_KERBEROS_AUTH=$ENV_AUTH_USE_KERBEROS
export AUTH_NAME=\"$ENV_AUTH_NAME\"
export AUTH_KRB5_KEYTAB=$ENV_AUTH_KRB5_KEYTAB
export AUTH_KRB_REALMS=$ENV_AUTH_KRB_REALMS
export AUTH_KRB_SERVICE_NAME=$ENV_AUTH_KRB_SERVICE_NAME
fi

# Optionally enable SSL
if [ -n "$ENV_USE_SSL" ]; then
useSsl="-D USE_SSL"

[[ ! -e /etc/apache2/server.crt ]] && die "/etc/apache2/server.crt is missing"
[[ ! -e /etc/apache2/server.key ]] && die "/etc/apache2/server.key is missing"
needModSsl=1
fi

if [ $needModSsl -ne 0 ]; then
mod_activate_deactivate SSL 1;
fi

exec /usr/sbin/httpd -D FOREGROUND ${useSsl}