Skip to content
This repository was archived by the owner on Aug 9, 2019. It is now read-only.
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
14 changes: 14 additions & 0 deletions github/Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM registry.devshift.net/osio-prod/base/python2:latest

# Install mattermost-integration-github
RUN pip install git+https://github.com/softdevteam/mattermost-github-integration@acb6833

# copy config file
COPY config.py /opt/

# set env variables
ENV FLASK_APP=mattermostgithub MGI_CONFIG_FILE=/opt/config.py

EXPOSE 5000

CMD flask run --host=0.0.0.0
25 changes: 25 additions & 0 deletions github/Docker/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from os import environ
from sys import exit
USERNAME = "Github"
ICON_URL = ""
reponames = [x for x in environ['REPO_NAMES'].split(',')]
hook_urls = [x for x in environ['HOOK_URLS'].split(',')]
channels = [x for x in environ['CHANNEL_NAMES'].split(',')]

MATTERMOST_WEBHOOK_URLS = {}

if not( len(reponames) == len(hook_urls) == len(channels)):
exit(1)

# MATTERMOST_WEBHOOK_URLS.update( reponame : ( url, channel)
for x in xrange(len(channels)):
MATTERMOST_WEBHOOK_URLS.update({reponames[x] : (hook_urls[x], channels[x])})

SECRET = ""
SHOW_AVATARS = True
SERVER = {
'hook': "/",
'address': "0.0.0.0",
'port': 5000,
}

65 changes: 46 additions & 19 deletions github/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-github-integration"
REGISTRY="https://registry.centos.org"
REPOSITORY="mattermost"
TEMPLATE="openshift/mattermost-github.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 -A 1 "name: IMAGE_TAG_VERSION" | grep "value:" | 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-github-integration"
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-github-integration"
REGISTRY="https://registry.centos.org"
REPOSITORY="mattermost"
TEMPLATE="openshift/mattermost-github.app.yaml"

#Find tag used by deployment template
echo -e "Scanning OpenShift Deployment Template for Image tag"
TAG=$(cat $TEMPLATE | grep -A 1 "name: IMAGE_TAG_VERSION" | grep "value:" | 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
9 changes: 9 additions & 0 deletions gitlab/Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM registry.devshift.net/osio-prod/base/python2:latest

# Install mattermost-integration-gitlab
RUN pip install git+https://github.com/NotSqrt/mattermost-integration-gitlab@4a61a48

# Run the integration as a service after making sure that the webhook url variable is set
CMD if [ "${MATTERMOST_WEBHOOK_URL}" = "" ]; then echo "FAILED. MATTERMOST_WEBHOOK_URL environment variable is not set."; echo "Consult README for more information."; exit 1; fi; mattermost_gitlab "${MATTERMOST_WEBHOOK_URL}" --push --tag --icon "${MATTERMOST_ICON}"

EXPOSE 5000
66 changes: 46 additions & 20 deletions gitlab/cico_build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,53 @@ 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-gitlab-integration"
REGISTRY="https://registry.centos.org"
REPOSITORY="mattermost"
TEMPLATE="openshift/mattermost-gitlab.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 -A 1 "name: IMAGE_TAG_VERSION" | grep "value:" | 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-gitlab-integration"
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
fi
# Check the existence of image on registry.centos.org
IMAGE="mattermost-gitlab-integration"
REGISTRY="https://registry.centos.org"
REPOSITORY="mattermost"
TEMPLATE="openshift/mattermost-gitlab.app.yaml"

#Find tag used by deployment template
echo -e "Scanning OpenShift Deployment Template for Image tag"
TAG=$(cat $TEMPLATE | grep -A 1 "name: IMAGE_TAG_VERSION" | grep "value:" | 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
9 changes: 9 additions & 0 deletions irc/Docker/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM registry.centos.org/centos/centos:7

RUN yum -y install golang git

ENV GOPATH /tmp/

RUN go get github.com/42wim/matterbridge && cd /tmp/src/github.com/42wim/matterbridge && \
git checkout tags/v1.9.0 && \
go build .
15 changes: 15 additions & 0 deletions irc/Docker/Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM registry.devshift.net/osio-prod/base/pcp:latest

RUN mkdir -p /opt/matterbridge

COPY . /opt/matterbridge

RUN chown -R 1001 /opt/matterbridge && \
chmod -R 777 /opt/matterbridge && \
chmod +x /opt/matterbridge/docker-entry.sh

WORKDIR /opt/matterbridge

USER 1001

ENTRYPOINT ["/opt/matterbridge/docker-entry.sh"]
14 changes: 14 additions & 0 deletions irc/Docker/docker-entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
config=/opt/matterbridge/matterbridge.toml
sed -Ei "s/IRC_NICK/`echo $IRC_NICK`/" $config
sed -Ei "s/MM_SERVER_NAME/`echo $MM_SERVER_NAME`/" $config
sed -Ei "s/MM_TEAM_NAME/`echo $MM_TEAM_NAME`/" $config
sed -Ei "s/MM_LOGIN/`echo $MM_LOGIN`/" $config
sed -Ei "s/MM_PASS/`echo $MM_PASS`/" $config
sed -Ei "s/NICKSERV_NICK/`echo $NICKSERV_NICK`/" $config
sed -Ei "s/NICKSERV_PASS/`echo $NICKSERV_PASS`/" $config

python setuptoml.py
#sed -Ei "s/IRC_CHANNEL_NAME/`echo $IRC_CHANNEL_NAME`/" $config
#sed -Ei "s/MM_CHANNEL_NAME/`echo $MM_CHANNEL_NAME`/" $config
./matterbridge
22 changes: 22 additions & 0 deletions irc/Docker/matterbridge.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[irc]
[irc.freenode]
Server="irc.freenode.net:6697"
UseTLS=true
SkipTLSVerify=true
Nick="IRC_NICK"
PrefixMessagesWithNick=true
ShowJoinPart=false
RemoteNickFormat="<{NICK}> "
UseSASL=true
NickServNick="NICKSERV_NICK"
NickServPassword="NICKSERV_PASS"

[mattermost]
[mattermost.work]
Server="MM_SERVER_NAME"
Team="MM_TEAM_NAME"
Login="MM_LOGIN"
Password="MM_PASS"
PrefixMessagesWithNick=true
ShowJoinPart=false
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
14 changes: 14 additions & 0 deletions irc/Docker/setuptoml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from os import environ

irc_chan = environ['IRC_CHANNEL_NAMES'].split(",")
mm_chan = environ['MM_CHANNEL_NAMES'].split(",")
counter = 1
o = open("matterbridge.toml",'a')
print irc_chan, mm_chan
for x,y in zip(irc_chan, mm_chan):
o.write("\n[[gateway]]\nname=\"gateway%d\"\nenable=true\n" %counter)
counter+=1
o.write(" [[gateway.inout]]\n account=\"irc.freenode\"\n channel=\"%s\"\n" %x)
o.write(" [[gateway.inout]]\n account=\"mattermost.work\"\n channel=\"%s\"\n" %y)
o.close()

69 changes: 51 additions & 18 deletions irc/cico_build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,60 @@ set -x
# Exit on error
set -e

export BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M:%S`+00:00
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
}

# Check the existence of image on registry.centos.org
IMAGE="matterbridge"
REGISTRY="https://registry.centos.org"
REPOSITORY="mattermost"
TEMPLATE="openshift/mattermost-irc-bridge.app.yaml"
export BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M:%S`+00:00

#Find tag used by deployment template
echo -e "Scanning OpenShift Deployment Template for Image tag"
TAG=$(cat $TEMPLATE | grep -A 1 "name: IMAGE_TAG_VERSION" | grep "value:" | awk '{split($0,array,":")} END{print array[2]}')
if [ "$TARGET" = "rhel" ]; then
IMAGE="matterbridge"
REGISTRY="push.registry.devshift.net"
REPOSITORY="osio-prod"
TAG="latest"
BUILDER_IMAGE="matterbridge-builder"
BUILDER_CONT="matterbridge-build-container"

#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
# build the bin on centos based container
docker build Docker -f Docker/Dockerfile.build -t BUILDER_IMAGE="matterbridge-builder"
docker run --detach=true --name ${BUILDER_CONT} -t ${BUILDER_IMAGE} /bin/tail -f /dev/null
docker cp ${BUILDER_CONT}:/tmp/src/github.com/42wim/matterbridge/matterbridge .

if [ $? -eq 0 ]; then
echo 'CICO: Image existence check successful. Ready to deploy updated app'
exit 0
# building the final image
docker build Docker -f Docker/Dockerfile.rhel -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="matterbridge"
REGISTRY="https://registry.centos.org"
REPOSITORY="mattermost"
TEMPLATE="openshift/mattermost-irc-bridge.app.yaml"

#Find tag used by deployment template
echo -e "Scanning OpenShift Deployment Template for Image tag"
TAG=$(cat $TEMPLATE | grep -A 1 "name: IMAGE_TAG_VERSION" | grep "value:" | 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
12 changes: 12 additions & 0 deletions rssfeeds/Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM registry.devshift.net/osio-prod/base/python2:latest

# clone the upstream source repo
RUN git clone https://github.com/bitbackofen/Rss-Atom-Feed-Integration-for-Mattermost &&\
cd Rss-Atom-Feed-Integration-for-Mattermost && git checkout 8e189eb &&\
pip install -r requirements.txt

RUN mv Rss-Atom-Feed-Integration-for-Mattermost/settings.py.docker Rss-Atom-Feed-Integration-for-Mattermost/settings.py

WORKDIR Rss-Atom-Feed-Integration-for-Mattermost

CMD python feedfetcher.py
Loading