Skip to content

Commit

Permalink
[RFR-932] Upgrade to image 7.1.0 (support object storage)
Browse files Browse the repository at this point in the history
Task/rfr 932 support object storage
  • Loading branch information
hb0 authored Feb 8, 2024
2 parents 93bb8c1 + 6b91731 commit a2dffe4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

# Specify JARs version here.
env:
JARS_VERSION: '7.0.1'
JARS_VERSION: '7.1.0'

jobs:
publish:
Expand Down
7 changes: 3 additions & 4 deletions collector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2022 Cyface GmbH
# Copyright 2018-2024 Cyface GmbH
#
# This file is part of the Cyface Data Collector.
#
Expand All @@ -15,10 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with the Cyface Data Collector. If not, see <http://www.gnu.org/licenses/>.
#
# Version 1.0.1
# Version 1.0.2

# Use the official JDK Repo for version 11 as target (use slim version to remove all UI stuff, and since we do only need to run software, we just use the JRE).
FROM openjdk:11-jre-slim
FROM eclipse-temurin:17-jre
MAINTAINER Cyface GmbH <[email protected]>

# Create user. Unproblematic default id (wikipedia.org/wiki/User_identifier)
Expand Down
78 changes: 61 additions & 17 deletions collector/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@

DEFAULT_API_PORT="8080"
JAR_FILE="collector-all.jar"
LOG_FILE="/app/logs/collector-out.log"
SERVICE_NAME="Cyface Collector API"

main() {
loadAuthParameters
loadApiParameters
loadCollectorParameters
loadConfig
waitForDatabase "mongo"
waitForDependency "mongo" 27017
startApi
}

loadApiParameters() {
if [ -z "$CYFACE_API_STD_OUT_FILE" ]; then
CYFACE_API_STD_OUT_FILE="/app/logs/collector-out.log"
fi

if [ -z "$CYFACE_API_PORT" ]; then
CYFACE_API_PORT=$DEFAULT_API_PORT
fi
Expand All @@ -43,7 +46,8 @@ loadApiParameters() {
fi

if [ -z $CYFACE_API_ENDPOINT ]; then
CYFACE_API_ENDPOINT="/api/v4/"
echo "Unable to find API Endpoint. Please set the environment variable CYFACE_API_ENDPOINT to an appropriate value! API will not start!"
exit 1
fi
}

Expand All @@ -59,8 +63,8 @@ loadAuthParameters() {
fi

if [ -z CYFACE_OAUTH_SECRET ]; then
echo "Unable to find OAuth client secret. Please set the environment variable CYFACE_OAUTH_SECRET to an appropriate value! API will not start!"
exit 1
echo "Unable to find OAuth client secret. Please set the environment variable CYFACE_OAUTH_SECRET to an appropriate value! API will not start!"
exit 1
fi

if [ -z "$CYFACE_OAUTH_SITE" ]; then
Expand Down Expand Up @@ -94,17 +98,60 @@ loadCollectorParameters() {

# Storage type
if [ -z $STORAGE_TYPE ]; then
STORAGE_TYPE="gridfs"
echo "Unable to find Storage Type. Please set the environment variable STORAGE_TYPE to an appropriate value! API will not start!"
exit 1
fi

echo "Setting storage type to $STORAGE_TYPE"
# GridFS Storage Configuration
if [ "$STORAGE_TYPE" == "gridfs" ]; then

# Storage uploads folder
if [ -z $STORAGE_UPLOADS_FOLDER ]; then
STORAGE_UPLOADS_FOLDER="file-uploads"
fi
if [ -z "$STORAGE_UPLOADS_FOLDER" ]; then
echo "Unable to find Storage Uploads Folder. Please set the environment variable STORAGE_UPLOADS_FOLDER to an appropriate value! API will not start!"
exit 1
fi

STORAGE_CONFIGURATION="{\
\"type\":\"$STORAGE_TYPE\",\
\"uploads-folder\":\"$STORAGE_UPLOADS_FOLDER\"\
}"

# Google Cloud Storage Configuration
elif [ "$STORAGE_TYPE" == "google" ]; then

if [ -z "$STORAGE_PROJECT_IDENTIFIER" ]; then
echo "Unable to find Storage Project Identifier. Please set the environment variable STORAGE_PROJECT_IDENTIFIER to an appropriate value! API will not start!"
exit 1
fi

echo "Setting storage uploads-folder to $STORAGE_UPLOADS_FOLDER"
if [ -z "$STORAGE_BUCKET_NAME" ]; then
echo "Unable to find Storage Bucket Name. Please set the environment variable STORAGE_BUCKET_NAME to an appropriate value! API will not start!"
exit 1
fi

if [ -z "$STORAGE_CREDENTIALS_FILE" ]; then
echo "Unable to find Storage Credentials File. Please set the environment variable STORAGE_CREDENTIALS_FILE to an appropriate value! API will not start!"
exit 1
fi

if [ -z "$STORAGE_COLLECTION_NAME" ]; then
echo "Unable to find Storage Collection Name. Please set the environment variable STORAGE_COLLECTION_NAME to an appropriate value! API will not start!"
exit 1
fi

STORAGE_CONFIGURATION="{\
\"type\":\"$STORAGE_TYPE\",\
\"project-identifier\":\"$STORAGE_PROJECT_IDENTIFIER\",\
\"bucket-name\":\"$STORAGE_BUCKET_NAME\",\
\"credentials-file\":\"$STORAGE_CREDENTIALS_FILE\",\
\"collection-name\":\"$STORAGE_COLLECTION_NAME\"\
}"

else
echo "Unsupported Storage Type $STORAGE_TYPE. Please set the environment variable to an appropriate value! API will not start!"
exit 1
fi

echo "Setting storage configuration to $STORAGE_CONFIGURATION"

# Monitoring
if [ -z $METRICS_ENABLED ]; then
Expand All @@ -128,10 +175,7 @@ loadConfig() {
\"metrics.enabled\":$METRICS_ENABLED,\
\"upload.expiration\":$UPLOAD_EXPIRATION_TIME_MILLIS,\
\"measurement.payload.limit\":$MEASUREMENT_PAYLOAD_LIMIT_BYTES,\
\"storage-type\":{\
\"type\":\"$STORAGE_TYPE\",\
\"uploads-folder\":\"$STORAGE_UPLOADS_FOLDER\"\
},\
\"storage-type\":$STORAGE_CONFIGURATION,\
\"auth-type\":\"$CYFACE_AUTH_TYPE\",
\"oauth.callback\":\"$CYFACE_OAUTH_CALLBACK\",\
\"oauth.client\":\"$CYFACE_OAUTH_CLIENT\",\
Expand Down Expand Up @@ -175,7 +219,7 @@ startApi() {
-Dlogback.configurationFile=/app/logback.xml \
-jar $JAR_FILE \
-conf "$CONFIG" \
&> $LOG_FILE
&> $CYFACE_API_STD_OUT_FILE
echo "API started or failed. Checking logs might give more insights."
}

Expand Down

0 comments on commit a2dffe4

Please sign in to comment.