diff --git a/compose/services.yml b/compose/services.yml index 7546a8d..bdf3a34 100644 --- a/compose/services.yml +++ b/compose/services.yml @@ -73,15 +73,16 @@ services: BALENA_ROOT_CA: ${OPENBALENA_ROOT_CA} BALENA_TOKEN_AUTH_ISSUER: api.${OPENBALENA_HOST_NAME} BALENA_TOKEN_AUTH_REALM: https://api.${OPENBALENA_HOST_NAME}/auth/v1/token - COMMON_REGION: + COMMON_REGION: ${OPENBALENA_S3_REGION} REGISTRY2_CACHE_ENABLED: "false" REGISTRY2_CACHE_ADDR: 127.0.0.1:6379 REGISTRY2_CACHE_DB: 0 REGISTRY2_CACHE_MAXMEMORY_MB: 1024 # megabytes REGISTRY2_CACHE_MAXMEMORY_POLICY: allkeys-lru - REGISTRY2_S3_BUCKET: - REGISTRY2_S3_KEY: - REGISTRY2_S3_SECRET: + REGISTRY2_S3_REGION_ENDPOINT: ${OPENBALENA_S3_ENDPOINT} + REGISTRY2_S3_BUCKET: ${OPENBALENA_REGISTRY2_S3_BUCKET} + REGISTRY2_S3_KEY: ${OPENBALENA_S3_ACCESS_KEY} + REGISTRY2_S3_SECRET: ${OPENBALENA_S3_SECRET_KEY} REGISTRY2_SECRETKEY: ${OPENBALENA_REGISTRY_SECRET_KEY} REGISTRY2_STORAGEPATH: /data @@ -125,8 +126,9 @@ services: volumes: - s3:/export environment: - S3_MINIO_ACCESS_KEY: abcdef1234 - S3_MINIO_SECRET_KEY: "1234567890" + S3_MINIO_ACCESS_KEY: ${OPENBALENA_S3_ACCESS_KEY} + S3_MINIO_SECRET_KEY: ${OPENBALENA_S3_SECRET_KEY} + BUCKETS: ${OPENBALENA_S3_BUCKETS} redis: extends: diff --git a/compose/versions b/compose/versions index dfe7f7e..fe971ac 100644 --- a/compose/versions +++ b/compose/versions @@ -1,6 +1,6 @@ export OPENBALENA_API_VERSION_TAG=v0.19.5 export OPENBALENA_DB_VERSION_TAG=v2.0.3 -export OPENBALENA_REGISTRY_VERSION_TAG=v2.11.1 -export OPENBALENA_S3_VERSION_TAG=v2.6.2 -export OPENBALENA_VPN_VERSION_TAG=v8.10.0 export OPENBALENA_MDNS_PUBLISHER_VERSION_TAG=v1.6.2 +export OPENBALENA_REGISTRY_VERSION_TAG=v2.11.1 +export OPENBALENA_S3_VERSION_TAG=v2.8.5 +export OPENBALENA_VPN_VERSION_TAG=v8.10.0 diff --git a/scripts/logger.sh b/scripts/logger.sh new file mode 100644 index 0000000..5ead895 --- /dev/null +++ b/scripts/logger.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +BLACK=`tput setaf 0` +RED=`tput setaf 1` +GREEN=`tput setaf 2` +YELLOW=`tput setaf 3` +BLUE=`tput setaf 4` +MAGENTA=`tput setaf 5` +CYAN=`tput setaf 6` +WHITE=`tput setaf 7` + +BOLD=`tput bold` +RESET=`tput sgr0` + +log_raw () { + local COLOR="${WHITE}" + local LEVEL="${1}" + local MESSAGE="${2}" + case "${LEVEL}" in + info) + COLOR="${BLUE}" + ;; + warn) + COLOR="${YELLOW}" + ;; + fatal) + COLOR="${RED}" + ;; + *) + LEVEL="debug" + ;; + esac + LEVEL="${LEVEL} " + echo "[$(date +%T)] ${COLOR}$(echo "${LEVEL:0:5}" | tr '[:lower:]' '[:upper:]')${RESET} ${MESSAGE}"; +} + +log () { + log_raw "debug" "${1}" +} + +info () { + log_raw "info" "${1}"; +} + +warn () { + log_raw "warn" "${1}"; +} + +die () { + log_raw "fatal" "${1}"; + exit 1; +} + +die_unless_forced () { + if [ ! -z "$1" ]; then + log_raw "warn" "$2"; + return; + fi + + log_raw "fatal" "$2"; + die "Use -f to forcibly upgrade."; +} \ No newline at end of file diff --git a/scripts/make-env b/scripts/make-env index 2e27561..5f2b916 100755 --- a/scripts/make-env +++ b/scripts/make-env @@ -40,11 +40,15 @@ b64file() { b64encode "$(cat "$@")" } +# buckets to create in the S3 service... +REGISTRY2_S3_BUCKET="registry-data" + cat <> "${CONFIG_FILE}" + else + sed -i '' "s~export ${1}=.*~export ${1}=${2}~" "${CONFIG_FILE}" + fi +} + +upsert_config "OPENBALENA_REGISTRY2_S3_BUCKET" "registry-data" || warn "Failed to update config value OPENBALENA_REGISTRY2_S3_BUCKET" +upsert_config "OPENBALENA_S3_ACCESS_KEY" "$(randstr 32)" || warn "Failed to update config value OPENBALENA_S3_ACCESS_KEY" +upsert_config "OPENBALENA_S3_ENDPOINT" "https://s3.${OPENBALENA_HOST_NAME}" || warn "Failed to update config value OPENBALENA_S3_ENDPOINT" +upsert_config "OPENBALENA_S3_REGION" "us-east-1" || warn "Failed to update config value OPENBALENA_S3_REGION" +upsert_config "OPENBALENA_S3_SECRET_KEY" "$(randstr 32)" || warn "Failed to update config value OPENBALENA_S3_SECRET_KEY" + +# Step 4. Migrate Registry data to S3... +info "Copying data from the Registry volume to the S3 volume..." +migrate_data_to_s3 "registry-data" +case $? in + 1) die "Invalid bucket name";; + 2) die "Unable to find the running Registry or S3 containers";; + 3) die "Unable to determine the data volumes for the Registry or S3 containers";; + *) info "Registry data copied" + ;; +esac +info "Upgrade complete" \ No newline at end of file