-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb92646
commit b4b887d
Showing
7 changed files
with
159 additions
and
18 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 |
---|---|---|
@@ -1,14 +1,26 @@ | ||
FROM postgres:9.6 | ||
|
||
MAINTAINER Gabriel Xia <ga.xiajin@gmail.com> | ||
|
||
ENV POSTGRES_USER postgres | ||
ENV POSTGRES_PASSWORD postgres | ||
|
||
RUN mkdir -p /etc/iglu/ && \ | ||
mkdir -p /opt/iglu/ | ||
|
||
WORKDIR /opt/iglu/ | ||
|
||
RUN apt-get update \ | ||
&& apt-get install default-jre -y | ||
&& apt-get install default-jre -y \ | ||
&& apt-get install curl -y | ||
|
||
COPY ./iglu-server-0.2.0.jar /opt/iglu/iglu-server-0.2.0.jar | ||
COPY ./config/ /etc/iglu/config/ | ||
COPY ./script/iglu-upload.sh /opt/iglu/iglu-upload.sh | ||
COPY ./iglu-terasology/ /etc/iglu/iglu-terasology/ | ||
|
||
COPY ./script/iglu-start.sh /docker-entrypoint-initdb.d/iglu-start.sh | ||
|
||
COPY ./iglu-server-0.2.0.jar ./iglu-server-0.2.0.jar | ||
COPY ./config/application.conf ./config/application.conf | ||
COPY ./iglu-start.sh ./docker-entrypoint-initdb.d/iglu-start.sh | ||
RUN chmod +x /opt/iglu/iglu-upload.sh | ||
|
||
EXPOSE 8080 |
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
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
docker/iglu/iglu-terasology/schemas/org.terasology/os/jsonschema/1-0-0
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,28 @@ | ||
{ | ||
"$schema": "http://localhost:8000/api/schemas/org.terasology/os/jsonschema/1-0-0#", | ||
"description": "Schema for os information of a player", | ||
"self": { | ||
"vendor": "org.terasology", | ||
"name": "os", | ||
"format": "jsonschema", | ||
"version": "1-0-0" | ||
}, | ||
"type": "object", | ||
"properties": { | ||
"osName": { | ||
"type": "string" | ||
}, | ||
"osVersion": { | ||
"type": "string" | ||
}, | ||
"osArchitecture": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"osName", | ||
"osVersion", | ||
"osArchitecture" | ||
], | ||
"additionalProperties": true | ||
} |
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,23 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL | ||
CREATE USER snowplow PASSWORD 'snowplow'; | ||
CREATE DATABASE iglu; | ||
GRANT ALL PRIVILEGES ON DATABASE iglu TO snowplow; | ||
EOSQL | ||
|
||
echo "Initialising postgres data base" | ||
java -Dconfig.file=/etc/iglu/config/application.conf -jar /opt/iglu/iglu-server-0.2.0.jar com.snowplowanalytics.iglu.server.Boot & | ||
|
||
sleep 60 | ||
|
||
VALUE=$(PGPASSWORD=snowplow psql -v ON_ERROR_STOP=1 --username=snowplow --dbname=iglu <<-EOSQL | ||
INSERT INTO apikeys (uid, vendor_prefix, permission, createdat) VALUES ('980ae3ab-3aba-4ffe-a3c2-3b2e24e2ffce','*','super',current_timestamp); | ||
EOSQL) | ||
echo $VALUE | ||
echo "uploading terasology event schemas" | ||
/opt/iglu/iglu-upload.sh http://iglu:8080 980ae3ab-3aba-4ffe-a3c2-3b2e24e2ffce /etc/iglu/iglu-terasology/schemas |
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,78 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2016 Snowplow Analytics Ltd. All rights reserved. | ||
# | ||
# This program is licensed to you under the Apache License Version 2.0, and | ||
# you may not use this file except in compliance with the Apache License | ||
# Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
# http://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the Apache License Version 2.0 is distributed on an "AS | ||
# IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. See the Apache License Version 2.0 for the specific language | ||
# governing permissions and limitations there under. | ||
|
||
# Script to upload all schemas in a folder to the Iglu repo | ||
# Takes three arguments: the target repo host, the Super API key, and the input schema directory | ||
# Uses PUT rather than POST, so existing schemas are overwritten | ||
|
||
echo "=================================" | ||
echo " Starting Iglu Server Uploader" | ||
echo "---------------------------------" | ||
|
||
if [ "$#" -ne 3 ] | ||
then | ||
echo "ERROR: 3 arguments required, $# provided" | ||
exit 1 | ||
fi | ||
|
||
host=$1; | ||
apikey=$2; | ||
schemafolder=$3; | ||
|
||
echo "" | ||
echo "Making all_vendor API Keys:" | ||
api_keys="$(curl --silent ${host}/api/auth/keygen -X POST -H "apikey: ${apikey}" -d "vendor_prefix=*")" | ||
write_api_key="$(echo ${api_keys} | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["write"]')" | ||
read_api_key="$(echo ${api_keys} | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["read"]')" | ||
echo "Keys: $(echo ${api_keys} | xargs)" | ||
|
||
echo "" | ||
echo "Uploading all Schemas found in ${schemafolder}:" | ||
|
||
good_counter=0 | ||
bad_counter=0 | ||
|
||
for schemapath in $(find $schemafolder -type f | grep 'jsonschema'); do | ||
destination="$host/api/schemas/$( | ||
# Keep the last 4 slash-separated components of the filename | ||
echo $schemapath | awk -F '/' '{print $(NF-3)"/"$(NF-2)"/"$(NF-1)"/"$(NF)}'; | ||
)"; | ||
echo "Uploading schema in file '$schemapath' to endpoint '$destination'"; | ||
result="$(curl --silent "${destination}?isPublic=true" -XPUT -d @$schemapath -H "apikey: $write_api_key")"; | ||
echo " - Result: $(echo ${result} | xargs)" | ||
|
||
# Process result | ||
status="$(echo ${result} | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["status"]')" | ||
if [[ "${status}" -eq "200" ]] || [[ "${status}" -eq "201" ]]; then | ||
let good_counter=good_counter+1 | ||
else | ||
let bad_counter=bad_counter+1 | ||
fi | ||
done; | ||
|
||
echo "" | ||
echo "Result Counts:" | ||
echo " - 200/201: ${good_counter}" | ||
echo " - 400/401/500: ${bad_counter}" | ||
|
||
echo "" | ||
echo "Remove created API Keys:" | ||
echo " - Remove ${write_api_key}: $(curl --silent ${host}/api/auth/keygen -X DELETE -H "apikey: ${apikey}" -d "key=${write_api_key}" | xargs)" | ||
echo " - Remove ${read_api_key}: $(curl --silent ${host}/api/auth/keygen -X DELETE -H "apikey: ${apikey}" -d "key=${read_api_key}" | xargs)" | ||
|
||
echo "" | ||
echo "--------" | ||
echo " Done " | ||
echo "========" |
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