From 547f5cea5e5f0ff9a68695c0e14874a2a8855ee1 Mon Sep 17 00:00:00 2001 From: Scott Koranda Date: Fri, 10 Feb 2017 13:32:59 -0600 Subject: [PATCH] Adding COmanage Registry PostgreSQL example --- comanage-registry-postgres/Dockerfile | 21 ++++++++++++ comanage-registry-postgres/README.md | 32 +++++++++++++++++++ .../init-comanage-registry-database.sh | 10 ++++++ 3 files changed, 63 insertions(+) create mode 100644 comanage-registry-postgres/Dockerfile create mode 100644 comanage-registry-postgres/README.md create mode 100644 comanage-registry-postgres/init-comanage-registry-database.sh diff --git a/comanage-registry-postgres/Dockerfile b/comanage-registry-postgres/Dockerfile new file mode 100644 index 0000000..027a446 --- /dev/null +++ b/comanage-registry-postgres/Dockerfile @@ -0,0 +1,21 @@ +# Copyright (C) 2010-15 University Corporation for Advanced Internet Development, Inc. +# +# Licensed 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 postgres + +ENV INIT_DIR /docker-entrypoint-initdb.d + +RUN mkdir -p "$INIT_DIR" + +COPY init-comanage-registry-database.sh "$INIT_DIR/init-comanage-registry-database.sh" + +RUN chmod 0755 "$INIT_DIR/init-comanage-registry-database.sh" diff --git a/comanage-registry-postgres/README.md b/comanage-registry-postgres/README.md new file mode 100644 index 0000000..a6f8ea6 --- /dev/null +++ b/comanage-registry-postgres/README.md @@ -0,0 +1,32 @@ +# PostgreSQL for COmanage Registry + +A simple example demonstrating how to create and image and container +based on PostgreSQL to use with COmanage Registry containers. + +## Build + +``` +docker build -t comanage-registry-postgres . +``` + +## Run + +Create a user-defined network bridge with + +``` +docker network create --driver=bridge \ + --subnet=192.168.0.0/16 \ + --gateway=192.168.0.100 \ + comanage-registry-internal-network +``` + +and then mount a host directory such as `/tmp/postgres-data` +to `/var/lib/postgresql/data` inside the container to persist +data, eg. + +``` +docker run -d --name comanage-registry-database \ + --network comanage-registry-internal-network \ + -v /tmp/postgres-data:/var/lib/postgresql/data \ + comanage-registry-postgres +``` diff --git a/comanage-registry-postgres/init-comanage-registry-database.sh b/comanage-registry-postgres/init-comanage-registry-database.sh new file mode 100644 index 0000000..ddcf51a --- /dev/null +++ b/comanage-registry-postgres/init-comanage-registry-database.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +# CREATE USER registry_user WITH PASSWORD 'tigger'; + +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL + CREATE USER registry_user; + CREATE DATABASE registry; + GRANT ALL PRIVILEGES ON DATABASE registry TO registry_user; +EOSQL