From 0eee539d2d773db1d1a3e97d284bf42dee688dee Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sun, 19 Jan 2020 12:26:27 +0100 Subject: [PATCH] new: [gogocartojs] added charm Signed-off-by: Valentin Lab --- gogocartojs/hooks/init | 21 +++++++++++++++++++++ gogocartojs/lib/common | 15 +++++++++++++++ gogocartojs/metadata.yml | 21 +++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100755 gogocartojs/hooks/init create mode 100644 gogocartojs/lib/common create mode 100644 gogocartojs/metadata.yml diff --git a/gogocartojs/hooks/init b/gogocartojs/hooks/init new file mode 100755 index 0000000..671f382 --- /dev/null +++ b/gogocartojs/hooks/init @@ -0,0 +1,21 @@ +#!/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 + + +. lib/common + +set -e + + +if ! [ -e "$GOGOCARTOJS_CODE" ]; then + gogocartojs:build +fi \ No newline at end of file diff --git a/gogocartojs/lib/common b/gogocartojs/lib/common new file mode 100644 index 0000000..0ea0fac --- /dev/null +++ b/gogocartojs/lib/common @@ -0,0 +1,15 @@ +# -*- mode: bash -*- + +GOGOCARTOJS_CODE="$SERVICE_DATASTORE/opt/apps/gogocartojs" +GOGOCARTOJS_DOCKER_IMAGE=docker.0k.io/gogocartojs:1.0.0 + +gogocartojs:build() { + docker pull "$GOGOCARTOJS_DOCKER_IMAGE" || return 1 + container_id=$(docker run -d --entrypoint true "$GOGOCARTOJS_DOCKER_IMAGE") || return 1 + mkdir -p "$GOGOCARTOJS_CODE" && + docker cp "$container_id":/opt/apps/gogocartojs/build "$GOGOCARTOJS_CODE"/ && + docker cp "$container_id":/opt/apps/gogocartojs/web "$GOGOCARTOJS_CODE"/ && + docker cp "$container_id":/opt/apps/gogocartojs/dist "$GOGOCARTOJS_CODE"/ && + docker cp "$container_id":/opt/apps/gogocartojs/assets "$GOGOCARTOJS_CODE"/ && + docker rm "$container_id" +} diff --git a/gogocartojs/metadata.yml b/gogocartojs/metadata.yml new file mode 100644 index 0000000..eeca464 --- /dev/null +++ b/gogocartojs/metadata.yml @@ -0,0 +1,21 @@ +description: Gogocartojs server +subordinate: true +requires: + web-publishing-directory: + interface: publish-dir + scope: container + + +uses: + publish-dir: + #constraint: required | recommended | optional + #auto: pair | summon | none ## default: pair + scope: container + constraint: required + auto: summon + solves: + container: "main running server" + default-options: + location: !var-expand "$DATASTORE/$BASE_SERVICE_NAME/opt/apps/gogocartojs" + # data-dirs: ## write permission for web-app + # - .