Skip to content
Draft
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
79 changes: 79 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
os: linux
dist: trusty

services: docker

language: shell

branches:
only:
- master
- develop

before_install:
- env | sort
- export TAG=travis
- export VCS_REF=`git rev-parse --short HEAD`
- export BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
- export IMAGE_NAME=mattermostldap
- export home=$(pwd)
- export travis_dir="${home}"
- export BUILD_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-${TRAVIS_BRANCH}}
- export BUILD_URL=https://github.com/${TRAVIS_PULL_REQUEST_SLUG:-${TRAVIS_REPO_SLUG}}

install:
- echo "Changing to travis directory ($travis_dir)"
- cd "$travis_dir"
# Test container build
- travis_retry docker-compose -f docker-compose.yaml build

before_script:
- docker images

script:
- echo "Changing to travis test directory ($travis_dir)"
- cd "$travis_dir"
- cp env.example .env
# Test container run
- travis_retry docker-compose -f docker-compose.yaml up -d && sleep 60
- docker-compose -f docker-compose.yaml ps
- docker-compose -f docker-compose.yaml logs "db"
- docker-compose -f docker-compose.yaml ps "db" | grep "Up" || exit 1
- docker-compose -f docker-compose.yaml logs "mattermost-ldap"
- docker-compose -f docker-compose.yaml ps "mattermost-ldap" | grep "Up" || exit 1
- echo 'Wait until sites and apps database installed (1 minute)' && sleep 60
- docker-compose -f docker-compose.yaml ps
- docker-compose -f docker-compose.yaml logs "db"
- docker-compose -f docker-compose.yaml ps "db" | grep "Up"
- docker-compose -f docker-compose.yaml logs "mattermost-ldap"
- docker-compose -f docker-compose.yaml ps "mattermost-ldap" | grep "Up"
# Test container restart
- docker-compose -f docker-compose.yaml down
- travis_retry docker-compose -f docker-compose.yaml up -d && sleep 60
- docker-compose -f docker-compose.yaml ps
- docker-compose -f docker-compose.yaml logs "db"
- docker-compose -f docker-compose.yaml ps "db" | grep "Up"
- docker-compose -f docker-compose.yaml logs "mattermost-ldap"
- docker-compose -f docker-compose.yaml ps "mattermost-ldap" | grep "Up"

after_script:
- echo "Changing to project directory ($home)"
- cd "$home"
# Publish coverage to Coveralls
- test ! -f "$home/.coverage" || coveralls -b "$home" -d "$home/.coverage"
# Publish coverage to Codacy
- test -z "$CODACY_PROJECT_TOKEN" || bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Python -r "./coverage.xml"
# Publish coverage to Codecov
- test -z "$CODECOV_TOKEN" || bash <(curl -s https://codecov.io/bash)

notifications:
email: false

jobs:
allow_failures:
#- env: VERSION=master DATABASE=mariadb
- env: VERSION=master DATABASE=postgres

env: # Environments
#- VERSION=master DATABASE=mariadb
- VERSION=master DATABASE=postgres
24 changes: 18 additions & 6 deletions Docker/mattermostldap/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ FROM php:apache

RUN set -x \
&& apt-get update \
&& apt-get install -y libpq-dev libldap2-dev git\
&& apt-get install -y --no-install-recommends \
libpq-dev \
libldap2-dev \
git \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure pgsql --with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install pdo pdo_pgsql pgsql \
Expand All @@ -13,14 +16,23 @@ RUN set -x \
# Enable development php.ini config (Solve empty answer from token.php)
RUN ln -s /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini

# Get Mattermost-LDAP project
RUN git clone https://github.com/crivaledaz/Mattermost-LDAP.git /opt/Mattermost-LDAP/
ARG BUILD_BRANCH=master
ARG BUILD_URL=https://github.com/crivaledaz/Mattermost-LDAP.git

# Get Mattermost-LDAP project
# Install server Oauth
RUN cp -r /opt/Mattermost-LDAP/oauth/ /var/www/html/

# Get config file
RUN cp /var/www/html/oauth/config_db.php.example /var/www/html/oauth/config_db.php; cp /var/www/html/oauth/LDAP/config_ldap.php.example /var/www/html/oauth/LDAP/config_ldap.php
RUN set -ex; \
git clone --branch "${BUILD_BRANCH}" "${BUILD_URL}" /opt/Mattermost-LDAP/; \
cp -r /opt/Mattermost-LDAP/oauth/ /var/www/html/ ; \
cp \
/var/www/html/oauth/config_db.php.example \
/var/www/html/oauth/config_db.php\
; \
cp \
/var/www/html/oauth/LDAP/config_ldap.php.example \
/var/www/html/oauth/LDAP/config_ldap.php \
;

# Open and expose port 80 for Apache server
EXPOSE 80
5 changes: 4 additions & 1 deletion Docker/php-ldap-pgsql/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ FROM php:fpm

RUN set -x \
&& apt-get update \
&& apt-get install -y libpq-dev libldap2-dev git\
&& apt-get install -y --no-install-recommends \
libpq-dev \
libldap2-dev \
git \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure pgsql --with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install pdo pdo_pgsql pgsql \
Expand Down
10 changes: 9 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
version: '3'
services:
mattermost-ldap:
build: Docker/mattermostldap
build:
context: Docker/mattermostldap
args:
- VERSION=${VERSION}
image: mattermostldap
restart: always
ports:
- 80:80
- 443:443
#depends_on:
# db:
# condition: service_healthy
environment:
- ldap_host
- ldap_port
Expand All @@ -26,6 +32,8 @@ services:
db:
image: postgres:alpine
restart: always
#healthcheck:
# test: ["CMD", "pg_isready", "-U", "${POSTGRES_USER}"]
volumes:
- ./db_init/init_postgres.sh:/docker-entrypoint-initdb.d/init_postgres.sh
- ./db_init/config_init.sh.example:/docker-entrypoint-initdb.d/config_init.sh
Expand Down
10 changes: 10 additions & 0 deletions hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# See documentation for details:
# https://docs.docker.com/docker-hub/builds/advanced/

docker build \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
-f $DOCKERFILE_PATH \
-t $IMAGE_NAME .