Skip to content

Commit

Permalink
Adding COmanage Registry PostgreSQL example
Browse files Browse the repository at this point in the history
  • Loading branch information
skoranda committed Feb 10, 2017
1 parent 1e3692f commit 547f5ce
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
21 changes: 21 additions & 0 deletions comanage-registry-postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
32 changes: 32 additions & 0 deletions comanage-registry-postgres/README.md
Original file line number Diff line number Diff line change
@@ -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
```
10 changes: 10 additions & 0 deletions comanage-registry-postgres/init-comanage-registry-database.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 547f5ce

Please sign in to comment.