-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding COmanage Registry PostgreSQL example
- Loading branch information
Showing
3 changed files
with
63 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,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" |
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,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
10
comanage-registry-postgres/init-comanage-registry-database.sh
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,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 |