Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
First commit
0 parents
commit b4e1fae
Showing
55 changed files
with
3,872 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<!-- | ||
COmanage Docker documentation | ||
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. | ||
--> | ||
|
||
# COmanage Match Docker | ||
|
||
These instructions detail how to | ||
build and deploy a Dockerized version of | ||
[COmanage Match](https://spaces.internet2.edu/display/COmanage/Home), as well as | ||
other infrastructure commonly deployed with COmanage Match. | ||
|
||
Since COmanage Match is a web application that requires a relational database | ||
and an authentication mechanism such as | ||
[Shibboleth](https://www.shibboleth.net/products/service-provider/), | ||
[mod\_auth\_openidc](https://github.com/zmartzone/mod_auth_openidc), | ||
or just simple [Basic Authentication](https://httpd.apache.org/docs/2.4/mod/mod_auth_basic.html), | ||
this repository includes multiple Dockerfiles to build images that use various | ||
combinations of tools. | ||
|
||
## Evaluate COmanage Match | ||
|
||
If you are new to COmanage Match follow [these instructions](docs/evaluation.md) to build | ||
and run a simple deployment suitable for evaluating COmanage Match. | ||
|
||
## Building Images | ||
|
||
The following link to detailed instructions for building each individual image. See the next | ||
section for links to documentation on how to deploy the images as services. | ||
|
||
* [COmanage Match base image](comanage-match-base/README.md) | ||
* [COmanage Match with Basic Authentication](comanage-match-basic-auth/README.md) | ||
* [COmanage Shibboleth SP base image](../comanage-shibboleth-sp-base/README.md) | ||
* [COmanage Match with Shibboleth SP](comanage-match-shibboleth-sp/README.md) | ||
* [COmanage Match for Internet2 TAP base](comanage-match-internet2-tap-base/README.md) | ||
* [COmanage Match for Internet2 TAP](comanage-match-internet2-tap/README.md) | ||
* [PostgreSQL for COmanage Match](comanage-match-postgres/README.md) | ||
|
||
## Deploying Images and Running Services | ||
|
||
Since COmanage Match requires a relational database | ||
it is commont that multiple images need to be simultanesouly instantiated | ||
as containers. Orchestrating multiple containers to create services is easiest using | ||
tools such as [Docker Compose](https://docs.docker.com/compose/), | ||
[Docker Swarm](https://docs.docker.com/engine/swarm/), or | ||
[Kubernetes](https://kubernetes.io/). | ||
|
||
The images built from Dockerfiles in this repository may be used with any container | ||
orchestration platform but the documentation demonstrates how to deploy with | ||
Docker Swarm (the simple evaluation scenario above uses Docker Compose). | ||
|
||
The following link to detailed instructions for a number of deployment scenarios. | ||
|
||
* [COmanage Match using the Shibboleth SP and PostgreSQL database](docs/shibboleth-sp-postgresql.md) | ||
|
||
## All Documentation | ||
|
||
### Building Images | ||
|
||
* [COmanage Match base image](comanage-match-base/README.md) | ||
* [COmanage Match with Basic Authentication](comanage-match-basic-auth/README.md) | ||
* [COmanage Shibboleth SP base image](../comanage-shibboleth-sp-base/README.md) | ||
* [COmanage Match with Shibboleth SP](comanage-match-shibboleth-sp/README.md) | ||
* [COmanage Match for Internet2 TAP base](comanage-match-internet2-tap-base/README.md) | ||
* [COmanage Match for Internet2 TAP](comanage-match-internet2-tap/README.md) | ||
* [PostgreSQL for COmanage Match](comanage-match-postgres/README.md) | ||
|
||
### Deploying Services | ||
|
||
* [COmanage Match using the Shibboleth SP and PostgreSQL database](docs/shibboleth-sp-postgresql.md) | ||
|
||
### Other | ||
|
||
* [COmanage Match Volumes and Data Persistence](docs/volumes-and-data-persistence.md) | ||
* [Evaluating COmanage Match using Docker](docs/evaluation.md) | ||
* [Environment Variables Common to All Images](docs/comanage-match-common-environment-variables.md) | ||
* [Environment Variables Common to Images using Shibboleth SP for Authentication](../docs/comanage-common-shibboleth-environment-variables.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* COmanage Database Connectivity Test Command, shared between Match and Registry | ||
* | ||
* 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. | ||
* | ||
* @link http://www.internet2.edu/comanage COmanage Project | ||
* @package match | ||
* @since COmanage Common v1.0.0 | ||
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
*/ | ||
|
||
/** | ||
* THIS FILE SHOULD BE MASTERED IN THE COMMON REPOSITORY. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Command; | ||
|
||
use Cake\Console\Arguments; | ||
use Cake\Console\Command; | ||
use Cake\Console\ConsoleIo; | ||
use Cake\Datasource\ConnectionManager; | ||
|
||
use Doctrine\DBAL\DriverManager; | ||
|
||
class DatabaseConnectivityTestCommand extends Command { | ||
/** | ||
* Test Connectivity to the Database | ||
* | ||
* @since COmanage Match v1.0.0, COmanage Registry v5.0.0 | ||
* @param Arguments $args Command Arguments | ||
* @param ConsoleIo $io Console IO | ||
* @throws RuntimeException | ||
*/ | ||
|
||
public function execute(Arguments $args, ConsoleIo $io) { | ||
// Use the ConnectionManager to get the database config. | ||
$db = ConnectionManager::get('default'); | ||
|
||
// $db is a ConnectionInterface object | ||
$cfg = $db->config(); | ||
|
||
$config = new \Doctrine\DBAL\Configuration(); | ||
|
||
$cfargs = [ | ||
'dbname' => $cfg['database'], | ||
'user' => $cfg['username'], | ||
'password' => $cfg['password'], | ||
'host' => $cfg['host'], | ||
'driver' => ($cfg['driver'] == 'Cake\Database\Driver\Postgres' ? "pdo_pgsql" : "pdo_mysql") | ||
]; | ||
|
||
$conn = DriverManager::getConnection($cfargs, $config); | ||
|
||
try { | ||
$conn->query('SELECT NOW()'); | ||
$io->out("Connected to database"); | ||
return 0; | ||
} | ||
catch(\Exception $e) { | ||
$io->out("Unable to connect to database"); | ||
return 1; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/** | ||
* COmanage Database Setup Already Command, shared between Match and Registry | ||
* | ||
* 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. | ||
* | ||
* @link http://www.internet2.edu/comanage COmanage Project | ||
* @package match | ||
* @since COmanage Common v1.0.0 | ||
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
*/ | ||
|
||
/** | ||
* THIS FILE SHOULD BE MASTERED IN THE COMMON REPOSITORY. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Command; | ||
|
||
use Cake\Console\Arguments; | ||
use Cake\Console\Command; | ||
use Cake\Console\ConsoleIo; | ||
use Cake\ORM\TableRegistry; | ||
|
||
class DatabaseSetupAlreadyCommand extends Command { | ||
/** | ||
* Test Connectivity to the Database | ||
* | ||
* @since COmanage Match v1.0.0, COmanage Registry v5.0.0 | ||
* @param Arguments $args Command Arguments | ||
* @param ConsoleIo $io Console IO | ||
* @throws RuntimeException | ||
*/ | ||
|
||
public function execute(Arguments $args, ConsoleIo $io) { | ||
$metaTable = TableRegistry::get('Meta'); | ||
|
||
try { | ||
$metaTable->findById('1')->firstOrFail(); | ||
$io->out("Match database is setup"); | ||
return 0; | ||
} | ||
catch(\Exception $e) { | ||
$io->out("Match database is not setup"); | ||
return 1; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# COmanage Match Dockerfile | ||
# | ||
# 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. | ||
FROM php:7.3.5-apache-stretch | ||
|
||
# Official PHP image with Apache HTTPD includes | ||
# --with-openssl | ||
# --with-mbstring | ||
# but intl, pdo, pdo_pgsql, pgsql, | ||
# extensions must be built. | ||
RUN apt-get update && apt-get install -y \ | ||
libicu-dev \ | ||
libpq-dev \ | ||
patch \ | ||
ssl-cert \ | ||
wget \ | ||
zlib1g \ | ||
libpcre3-dev \ | ||
&& docker-php-ext-configure intl \ | ||
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ | ||
&& docker-php-ext-install intl pdo pdo_pgsql pgsql \ | ||
&& docker-php-source delete \ | ||
&& apt-get purge -y \ | ||
libicu-dev \ | ||
libpq-dev \ | ||
&& apt-get clean | ||
|
||
ARG COMANAGE_MATCH_VERSION | ||
ENV COMANAGE_MATCH_VERSION ${COMANAGE_MATCH_VERSION:-develop} | ||
LABEL comanage_match_version=${COMANAGE_MATCH_VERSION} | ||
|
||
ENV COMANAGE_MATCH_SRC_URL=https://github.internet2.edu/COmanage/match/archive/${COMANAGE_MATCH_VERSION}.tar.gz | ||
|
||
ARG COMANAGE_MATCH_DIR | ||
ENV COMANAGE_MATCH_DIR ${COMANAGE_MATCH_DIR:-/srv/comanage-match} | ||
LABEL comanage_match_dir=${COMANAGE_MATCH_DIR} | ||
|
||
WORKDIR $COMANAGE_MATCH_DIR | ||
|
||
RUN mkdir -p ${COMANAGE_MATCH_DIR} \ | ||
&& wget -O comanage.tar.gz ${COMANAGE_MATCH_SRC_URL} \ | ||
&& tar -zxf comanage.tar.gz -C ${COMANAGE_MATCH_DIR} --strip-components=1 \ | ||
&& rm -f comanage.tar.gz \ | ||
&& rm -f ${COMANAGE_MATCH_DIR}/app/tmp \ | ||
&& rm -f ${COMANAGE_MATCH_DIR}/app/logs \ | ||
&& mkdir ${COMANAGE_MATCH_DIR}/app/tmp \ | ||
&& mkdir ${COMANAGE_MATCH_DIR}/app/logs \ | ||
&& chown -R www-data:www-data ${COMANAGE_MATCH_DIR}/app/tmp \ | ||
&& chown -R www-data:www-data ${COMANAGE_MATCH_DIR}/app/logs \ | ||
&& cd /var/www/html \ | ||
&& ln -s ${COMANAGE_MATCH_DIR}/app/webroot match | ||
|
||
RUN a2enmod headers \ | ||
&& a2enmod ssl \ | ||
&& a2enmod rewrite \ | ||
&& a2dissite 000-default.conf \ | ||
&& a2disconf other-vhosts-access-log \ | ||
&& cd /etc/apache2 \ | ||
&& ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem cert.pem \ | ||
&& ln -s /etc/ssl/private/ssl-cert-snakeoil.key privkey.pem | ||
|
||
COPY apache-include-directory-match /etc/apache2/ | ||
COPY apache-include-virtual-host-port443-base /etc/apache2/ | ||
COPY apache-include-virtual-host-port80-redirect /etc/apache2/ | ||
|
||
COPY comanage_utils.sh /usr/local/lib/ | ||
COPY comanage_shibboleth_sp_utils.sh /usr/local/lib/ | ||
COPY docker-comanage-match-entrypoint /usr/local/bin/ | ||
|
||
# Patch to configure console logging. The patch is | ||
# applied by the entry point script when appropriate. | ||
# | ||
# The patch is the output of the command | ||
# | ||
# diff -Naur app.php.original app.php > comanage_match_console_logging.patch | ||
COPY comanage_match_console_logging.patch /usr/local/src/ | ||
|
||
# Add commands for testing database connectivity and setup status until | ||
# they are part of Match source. | ||
COPY DatabaseConnectivityTestCommand.php ${COMANAGE_MATCH_DIR}/app/src/Command/ | ||
COPY DatabaseSetupAlreadyCommand.php ${COMANAGE_MATCH_DIR}/app/src/Command/ | ||
|
||
VOLUME ${COMANAGE_MATCH_DIR}/local | ||
|
||
EXPOSE 80 443 | ||
|
||
# Allow values for first administrator bootstrapped into the | ||
# platform to be specified at image build time, in addition to | ||
# being injected at run time through the entrypoint script. | ||
ARG COMANAGE_MATCH_ADMIN_USERNAME | ||
|
||
# Set simple defaults for first administrator bootstrapped into the | ||
ENV COMANAGE_MATCH_ADMIN_USERNAME ${COMANAGE_MATCH_ADMIN_USERNAME:-match.admin} | ||
|
||
ENTRYPOINT ["docker-comanage-match-entrypoint"] | ||
|
||
CMD ["apache2-foreground"] |
Oops, something went wrong.