Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add structure and main files.
Ioannis committed Jul 11, 2024
1 parent c78f49a commit 2f61e39
Showing 10 changed files with 1,648 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.idea/**
52 changes: 52 additions & 0 deletions Dockerfile
@@ -0,0 +1,52 @@
# COMANAGE #

ARG COMANAGE_REGISTRY_VERSION
ENV COMANAGE_REGISTRY_VERSION ${COMANAGE_REGISTRY_VERSION:-develop}

ARG COMANAGE_REGISTRY_SRC_URL
ENV COMANAGE_REGISTRY_SRC_URL=https://github.com/Internet2/comanage-registry/archive/${COMANAGE_REGISTRY_VERSION}.tar.gz

LABEL comanage_registry_version=${COMANAGE_REGISTRY_VERSION}
LABEL comanage_registry_src_url=${COMANAGE_REGISTRY_SRC_URL}

ARG COMANAGE_REGISTRY_DIR
ENV COMANAGE_REGISTRY_DIR ${COMANAGE_REGISTRY_DIR:-/srv/comanage-registry}

FROM i2incommon/comanage-base:latest

RUN yum -y update && yum -y install \
busybox \
&& yum clean -y all

WORKDIR "$COMANAGE_REGISTRY_DIR"

RUN mkdir -p "${COMANAGE_REGISTRY_DIR}" \
&& wget -O comanage.tar.gz ${COMANAGE_REGISTRY_SRC_URL} \
&& tar -zxf comanage.tar.gz -C ${COMANAGE_REGISTRY_DIR} --strip-components=1 \
&& rm -f comanage.tar.gz \
&& rm -rf ${COMANAGE_REGISTRY_DIR}/app/tmp \
&& cp -r ${COMANAGE_REGISTRY_DIR}/app/tmp.dist ${COMANAGE_REGISTRY_DIR}/app/tmp \
&& chown -R apache:apache ${COMANAGE_REGISTRY_DIR}/app/tmp \
&& cd ${COMANAGE_REGISTRY_DIR}/local \
&& ln -s ${COMANAGE_REGISTRY_DIR}/app/tmp tmp \
&& chown -h apache:apache ${COMANAGE_REGISTRY_DIR}/local/tmp \
&& cd /var/www/html \
&& ln -s ${COMANAGE_REGISTRY_DIR}/app/webroot registry

COPY --chown=root:root slashRoot/etc/crontab /etc/crontab
COPY --chown=root:root slashRoot/srv/comanage-registry/local/crontab /srv/comanage-registry/local/crontab
COPY --chown=root:root slashRoot/etc/ldap/ldap.conf /etc/ldap/ldap.conf
COPY slashRoot/usr/local/lib/comanage_utils.sh /usr/local/lib/

RUN chmod +x /usr/local/lib/comanage_utils.sh

RUN /usr/bin/crontab -u apache /srv/comanage-registry/local/crontab \
&& /usr/sbin/usermod --shell /bin/bash apache \
&& touch /etc/default/locale

COPY slashRoot/usr/local/bin/docker-comanage-cron-entrypoint /usr/local/bin/

ENTRYPOINT ["docker-comanage-cron-entrypoint"]

CMD ["/usr/sbin/crond", "-n"]

3 changes: 3 additions & 0 deletions common.bash
@@ -0,0 +1,3 @@
maintainer="i2incommon"
imagename="comanage-registry-cron"
comanage_version="4.3.4"
33 changes: 33 additions & 0 deletions jenkins/build.sh
@@ -0,0 +1,33 @@
#!/bin/bash

IMAGENAME=$1
TAG=$2
COMANAGE_REGISTRY_VERSION=$3
DOCKERHUBPW=$4
SUB=multiarch

echo "image name: ${IMAGENAME}"
echo "tag name: ${TAG}"
echo "comanage registry version: ${COMANAGE_REGISTRY_VERSION}"

docker login -u tieradmin -p $DOCKERHUBPW
# NOTE: docker buildx ls when ran using backticks, returns the
# output of a plain ls run. If we do the flow below we get
# the expected output
docker buildx ls | awk '{if (NR>1) {print $1}}' > farm.txt
# Preview the farm.txt file
echo `cat farm.txt`
# Parse the farm.txt file
DOCKER_FARMS=`cat farm.txt`
# Now remove the temporary file
rm -f farm.txt

if [[ "$DOCKER_FARMS" == *"$SUB"* ]]; then
echo "Farm multiarch exists"
else
docker buildx create --use --name multiarch --append
fi

docker buildx inspect --bootstrap
docker buildx build --no-cache --platform linux/amd64 -t ${IMAGENAME}_${TAG} --build-arg COMANAGE_REGISTRY_VERSION=${comanage_version} --load .
docker buildx build --no-cache --platform linux/arm64 -t ${IMAGENAME}_${TAG}:arm64 --build-arg COMANAGE_REGISTRY_VERSION=${comanage_version} --load .
35 changes: 35 additions & 0 deletions jenkins/cleanup.sh
@@ -0,0 +1,35 @@
#!/bin/bash

IMAGENAME=$1
TAG=$2
SUB=multiarch

docker buildx ls | awk '{if (NR>1) {print $1}}' > farm.txt
# Preview the farm.txt file
echo `cat farm.txt`
# Parse the farm.txt file
DOCKER_FARMS=`cat farm.txt`
# Now remove the temporary file
rm -f farm.txt

if [[ "$DOCKER_FARMS" == *"$SUB"* ]]; then
echo "Farm multiarch exists"
else
docker buildx create --use --name multiarch --append
fi

echo 'list docker processes'
docker ps --all
echo 'list all the docker images'
docker image ls
echo 'remove the amd64 docker image'
docker rmi ${IMAGENAME}_${TAG} --force
echo 'remove the arm64 docker image'
docker rmi ${IMAGENAME}_${TAG}:arm64 --force

echo "Remove all dangling images"
docker image prune -a --force
echo "Clear the build cache"
docker buildx prune --force
echo 'list all the docker images'
docker image ls
3 changes: 3 additions & 0 deletions slashRoot/etc/crontab
@@ -0,0 +1,3 @@
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
1 change: 1 addition & 0 deletions slashRoot/etc/ldap/ldap.conf
@@ -0,0 +1 @@
TLS_CACERT /etc/ssl/certs/ca-certificates.crt
14 changes: 14 additions & 0 deletions slashRoot/srv/comanage-registry/local/crontab
@@ -0,0 +1,14 @@
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
# Run Expiration Policies for CO 1 once a day at 1:00 AM
0 1 * * * cd /srv/comanage-registry/app && ./Console/cake job CoreJob.Expire -s --coid 1

# Run Synchronize Org Identity Sources for CO 1 once a day at 1:00 AM
0 1 * * * cd /srv/comanage-registry/app && ./Console/cake job CoreJob.Sync -s --coid 1

# Run Validate Group Member for CO 1 once a day at 1:00 AM
0 1 * * * cd /srv/comanage-registry/app && ./Console/cake job CoreJob.ValidateGroupMember -s --coid 1

# Run queued jobs for CO 1 every 5 minutes
0-59/5 * * * * cd /srv/comanage-registry/app && ./Console/cake job -q -r -c 1
24 changes: 24 additions & 0 deletions slashRoot/usr/local/bin/docker-comanage-cron-entrypoint
@@ -0,0 +1,24 @@
#!/bin/bash

# COmanage Registry Dockerfile entrypoint
#
# Portions licensed to the University Corporation for Advanced Internet
# Development, Inc. ("UCAID") under one or more contributor license agreements.
# See the NOTICE file distributed with this work for additional information
# regarding copyright ownership.
#
# UCAID licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

source /usr/local/lib/comanage_utils.sh

comanage_utils::exec_cron "$@"
1,482 changes: 1,482 additions & 0 deletions slashRoot/usr/local/lib/comanage_utils.sh

Large diffs are not rendered by default.

0 comments on commit 2f61e39

Please sign in to comment.