Skip to content
This repository has been archived by the owner on Aug 9, 2019. It is now read-only.

add rhel dockerfile and modify cico script #14

Open
wants to merge 1 commit into
base: master
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
15 changes: 15 additions & 0 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM registry.access.redhat.com/rhel7

ENV MMPP_VERSION 4.4
ENV MMPP_VERSION_MINOR .0

RUN cd /opt && \
curl -L https://github.com/mattermost/mattermost-push-proxy/releases/download/v${MMPP_VERSION}/mattermost-push-proxy-${MMPP_VERSION}${MMPP_VERSION_MINOR}.tar.gz > mmpp.tar.gz && \
tar xvf mmpp.tar.gz && rm mmpp.tar.gz

COPY mattermost-push-proxy.json /opt/mattermost-push-proxy/config/

RUN chmod -R 777 /opt/mattermost-push-proxy/config/
COPY docker-entrypoint.sh /

ENTRYPOINT ["/docker-entrypoint.sh"]
17 changes: 17 additions & 0 deletions Docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
MMPP_CONFIG=/opt/mattermost-push-proxy/config/mattermost-push-proxy.json

echo "Updating mattermost-push-proxy configuration..."

sed -Ei 's/APPLEPUSHCERT/'$APPLEPUSHCERT'/g' $MMPP_CONFIG
sed -Ei 's/APPLEPUSHPASS/'$APPLEPUSHPASS'/g' $MMPP_CONFIG

sed -Ei 's/APPLEPUSHRNCERT/'$APPLEPUSHRNCERT'/g' $MMPP_CONFIG
sed -Ei 's/APPLEPUSHRNPASS/'$APPLEPUSHRNPASS'/g' $MMPP_CONFIG

sed -Ei 's/GOOGLEAPIKEY/'$GOOGLEAPIKEY'/g' $MMPP_CONFIG
sed -Ei 's/GOOGLERNAPIKEY/'$GOOGLERNAPIKEY'/g' $MMPP_CONFIG

cd /opt/mattermost-push-proxy

/opt/mattermost-push-proxy/bin/mattermost-push-proxy
33 changes: 33 additions & 0 deletions Docker/mattermost-push-proxy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"ListenAddress":":8066",
"ThrottlePerSec":300,
"ThrottleMemoryStoreSize":50000,
"ThrottleVaryByHeader":"X-Forwarded-For",
"EnableMetrics": false,
"ApplePushSettings":[
{
"Type":"apple",
"ApplePushUseDevelopment":false,
"ApplePushCertPrivate":"APPLEPUSHCERT",
"ApplePushCertPassword":"APPLEPUSHPASS",
"ApplePushTopic":"com.mattermost.Mattermost"
},
{
"Type":"apple_rn",
"ApplePushUseDevelopment":false,
"ApplePushCertPrivate":"APPLEPUSHRNCERT",
"ApplePushCertPassword":"APPLEPUSHRNPASS",
"ApplePushTopic":"com.mattermost.react.native"
}
],
"AndroidPushSettings":[
{
"Type":"android",
"AndroidApiKey":"GOOGLEAPIKEY"
},
{
"Type":"android_rn",
"AndroidApiKey":"GOOGLERNAPIKEY"
}
]
}
65 changes: 46 additions & 19 deletions cico_build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,54 @@ set -x
# Exit on error
set -e

export BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M:%S`+00:00

# Check the existence of image on registry.centos.org
IMAGE="mattermost-push-proxy"
REGISTRY="https://registry.centos.org"
REPOSITORY="mattermost"
TEMPLATE="openshift/mattermost-push-proxy.app.yaml"
function login() {
if [ -n "${DEVSHIFT_USERNAME}" -a -n "${DEVSHIFT_PASSWORD}" ]; then
docker login -u ${DEVSHIFT_USERNAME} -p ${DEVSHIFT_PASSWORD} ${REGISTRY}
else
echo "Could not login, missing credentials for the registry"
fi
}

#Find tag used by deployment template
echo -e "Scanning OpenShift Deployment Template for Image tag"
TAG=$(cat $TEMPLATE | grep -o -e "registry.*" | awk '{split($0,array,"/")} END{print array[3]}' | awk '{split($0,array,":")} END{print array[2]}')
export BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M:%S`+00:00

#Check if image is in the registry
echo -e "Checking if image exists on the registry"
TAGLIST=$(curl -X GET $REGISTRY/v2/$REPOSITORY/$IMAGE/tags/list)
echo $TAGLIST | grep -w $TAG
if [ "$TARGET" = "rhel" ]; then
IMAGE="mattermost-push-proxy"
REGISTRY="push.registry.devshift.net"
REPOSITORY="osio-prod"
TAG="latest"

login

if [ $? -eq 0 ]; then
echo 'CICO: Image existence check successful. Ready to deploy updated app'
exit 0
docker build ./Docker -t $REGISTRY/$REPOSITORY/$IMAGE:$TAG
docker push $REGISTRY/$REPOSITORY/$IMAGE:$TAG
if [ $? -eq 0 ]; then
echo 'CICO: Image pushed, ready to update deployed app'
exit 0
else
echo 'CICO: Image push failed'
exit 2
fi
else
echo 'CICO: Image existence check failed. Exiting'
exit 2
# Check the existence of image on registry.centos.org
IMAGE="mattermost-push-proxy"
REGISTRY="https://registry.centos.org"
REPOSITORY="mattermost"
TEMPLATE="openshift/mattermost-push-proxy.app.yaml"

#Find tag used by deployment template
echo -e "Scanning OpenShift Deployment Template for Image tag"
TAG=$(cat $TEMPLATE | grep -o -e "registry.*" | awk '{split($0,array,"/")} END{print array[3]}' | awk '{split($0,array,":")} END{print array[2]}')

#Check if image is in the registry
echo -e "Checking if image exists on the registry"
TAGLIST=$(curl -X GET $REGISTRY/v2/$REPOSITORY/$IMAGE/tags/list)
echo $TAGLIST | grep -w $TAG

if [ $? -eq 0 ]; then
echo 'CICO: Image existence check successful. Ready to deploy updated app'
exit 0
else
echo 'CICO: Image existence check failed. Exiting'
exit 2
fi
fi