forked from 0k/0k-charms
Valentin Lab
4 years ago
5 changed files with 134 additions and 1 deletions
-
47cyclos/hooks/init
-
19cyclos/hooks/postgres_database-relation-joined
-
14cyclos/lib/common
-
41cyclos/metadata.yml
-
14postgres/lib/common
@ -0,0 +1,47 @@ |
|||
#!/bin/bash |
|||
|
|||
## Init is run on host |
|||
## For now it is run every time the script is launched, but |
|||
## it should be launched only once after build. |
|||
|
|||
## Accessible variables are: |
|||
## - SERVICE_NAME Name of current service |
|||
## - DOCKER_BASE_IMAGE Base image from which this service might be built if any |
|||
## - SERVICE_DATASTORE Location on host of the DATASTORE of this service |
|||
## - SERVICE_CONFIGSTORE Location on host of the CONFIGSTORE of this service |
|||
|
|||
|
|||
# Please note that postgres detect on its own if its datadir needs to be populated |
|||
|
|||
|
|||
. lib/common |
|||
|
|||
|
|||
if ! [ -f "$HOST_CYCLOS_CONFIG" ]; then |
|||
## create cyclos.properties |
|||
cyclos:build || exit 1 |
|||
fi |
|||
|
|||
if ! [ -f "$HOST_CYCLOS_CONFIG" ]; then |
|||
err "No file '$HOST_CYCLOS_CONFIG'." |
|||
return 1 |
|||
fi |
|||
|
|||
PROPS=( |
|||
cyclos.header.remoteAddress X-Forwarded-For |
|||
cyclos.header.protocol X-Forwarded-Proto |
|||
) |
|||
|
|||
while read-0 label value; do |
|||
sed -ri "s/^($label\s+=)\s*.*/\1 $value/g" "$HOST_CYCLOS_CONFIG" >&2 |
|||
done < <(array_values_to_stdin PROPS) |
|||
|
|||
|
|||
init-config-add " |
|||
$SERVICE_NAME: |
|||
environment: |
|||
JAVA_OPTS: | |
|||
-Dcyclos.cors.origin=* |
|||
-Dcyclos.header.remoteAddress=X-Forwarded-For |
|||
-Dcyclos.header.protocol=X-Forwarded-Proto |
|||
" |
@ -0,0 +1,19 @@ |
|||
#!/bin/bash |
|||
|
|||
set -e |
|||
|
|||
PASSWORD="$(relation-get password)" |
|||
USER="$(relation-get user)" |
|||
DBNAME="$(relation-get dbname)" |
|||
|
|||
config-add "\ |
|||
services: |
|||
$MASTER_BASE_SERVICE_NAME: |
|||
environment: |
|||
DB_HOST: \"$MASTER_TARGET_SERVICE_NAME\" |
|||
DB_NAME: \"$DBNAME\" |
|||
DB_USER: \"$USER\" |
|||
DB_PASSWORD: \"$PASSWORD\" |
|||
" |
|||
|
|||
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access." |
@ -0,0 +1,14 @@ |
|||
# -*- mode: bash -*- |
|||
|
|||
|
|||
CYCLOS_CONFIG="/usr/local/cyclos/WEB-INF/classes/cyclos.properties" |
|||
HOST_CYCLOS_CONFIG="$SERVICE_CONFIGSTORE$CYCLOS_CONFIG" |
|||
|
|||
cyclos:build() { |
|||
docker pull "$DOCKER_BASE_IMAGE" || return 1 |
|||
mkdir -p "$(dirname "$HOST_CYCLOS_CONFIG")" |
|||
container_id=$(docker run -d --entrypoint true "$DOCKER_BASE_IMAGE") || return 1 |
|||
mkdir -p "$(dirname "$HOST_CYCLOS_CODE")" && |
|||
docker cp "$container_id":"$CYCLOS_CONFIG" "$HOST_CYCLOS_CONFIG" && |
|||
docker rm "$container_id" |
|||
} |
@ -0,0 +1,41 @@ |
|||
## Based on cyclos/cyclos:4.13.2 |
|||
docker-image: docker.0k.io/cyclos:4.13.2 |
|||
config-resources: |
|||
- /usr/local/cyclos/WEB-INF/classes/cyclos.properties |
|||
data-resources: |
|||
- /var/log/cyclos |
|||
|
|||
default-options: |
|||
|
|||
uses: |
|||
postgres-database: |
|||
#constraint: required | recommended | optional |
|||
#auto: pair | summon | none ## default: pair |
|||
constraint: required |
|||
auto: summon |
|||
solves: |
|||
database: "main storage" |
|||
default-options: |
|||
extensions: |
|||
- cube |
|||
- earthdistance |
|||
- postgis |
|||
- unaccent |
|||
log-rotate: |
|||
#constraint: required | recommended | optional |
|||
#auto: pair | summon | none ## default: pair |
|||
constraint: recommended |
|||
auto: pair |
|||
solves: |
|||
unmanaged-logs: "in docker logs" |
|||
#default-options: |
|||
web-proxy: |
|||
#constraint: required | recommended | optional |
|||
#auto: pair | summon | none ## default: pair |
|||
constraint: recommended |
|||
auto: pair |
|||
solves: |
|||
proxy: "Public access" |
|||
default-options: |
|||
target: !var-expand ${MASTER_BASE_SERVICE_NAME}:8080 |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue