diff --git a/apps/gomodel/0.1.96/docker-compose.yml b/apps/gomodel/0.1.96/docker-compose.yml index 3215d2b89..c877b3859 100644 --- a/apps/gomodel/0.1.96/docker-compose.yml +++ b/apps/gomodel/0.1.96/docker-compose.yml @@ -1,6 +1,6 @@ services: gomodel: - image: "enterpilot/gomodel:0.2.3" + image: "enterpilot/gomodel:0.2.1" container_name: ${CONTAINER_NAME} restart: unless-stopped user: "65532:65532" diff --git a/apps/gomodel/0.2.2/docker-compose.yml b/apps/gomodel/0.2.2/docker-compose.yml index 3215d2b89..d6d4f3224 100644 --- a/apps/gomodel/0.2.2/docker-compose.yml +++ b/apps/gomodel/0.2.2/docker-compose.yml @@ -1,6 +1,6 @@ services: gomodel: - image: "enterpilot/gomodel:0.2.3" + image: "enterpilot/gomodel:0.2.2" container_name: ${CONTAINER_NAME} restart: unless-stopped user: "65532:65532" diff --git a/apps/gomodel/0.2.3/.env.sample b/apps/gomodel/0.2.3/.env.sample new file mode 100644 index 000000000..806e56309 --- /dev/null +++ b/apps/gomodel/0.2.3/.env.sample @@ -0,0 +1,4 @@ +CONTAINER_NAME=gomodel-compose-check +PANEL_APP_PORT_HTTP=8080 +GOMODEL_MASTER_KEY= +APP_DATA_DIR=./data diff --git a/apps/gomodel/0.2.3/data.yml b/apps/gomodel/0.2.3/data.yml new file mode 100644 index 000000000..f167084cd --- /dev/null +++ b/apps/gomodel/0.2.3/data.yml @@ -0,0 +1,85 @@ +additionalProperties: + formFields: + - default: 8080 + edit: true + envKey: PANEL_APP_PORT_HTTP + labelEn: HTTP Port + labelZh: HTTP 端口 + label: + en: HTTP Port + zh: HTTP 端口 + zh-hant: HTTP 連接埠 + ja: HTTP ポート + ko: HTTP 포트 + ru: Порт HTTP + ms: Port HTTP + pt-br: Porta HTTP + tr: HTTP Bağlantı Noktası + es-es: Puerto HTTP + fa: درگاه HTTP + lo: ພອດ HTTP + required: true + rule: paramPort + type: number + - default: '' + edit: true + envKey: GOMODEL_MASTER_KEY + labelEn: Master Key + labelZh: 主密钥 + label: + en: Master Key + zh: 主密钥 + zh-hant: 主密鑰 + ja: マスターキー + ko: 마스터 키 + ru: Главный ключ + ms: Kunci Induk + pt-br: Chave mestra + tr: Ana Anahtar + es-es: Clave maestra + fa: کلید اصلی + lo: ຄີຫຼັກ + random: true + required: true + rule: paramComplexity + type: password + - default: ./data + edit: true + envKey: APP_DATA_DIR + labelEn: Data Directory + labelZh: 数据目录 + label: + en: Data Directory + zh: 数据目录 + zh-hant: 資料目錄 + ja: データディレクトリ + ko: 데이터 디렉터리 + ru: Каталог данных + ms: Direktori Data + pt-br: Diretorio de dados + tr: Veri Dizini + es-es: Directorio de datos + fa: شاخه داده + lo: ໄດເຣັກທໍຣີຂໍ້ມູນ + required: true + type: text + - default: Asia/Shanghai + edit: true + envKey: TZ + labelEn: Timezone + labelZh: 时区 + label: + en: Timezone + zh: 时区 + zh-hant: 時區 + ja: タイムゾーン + ko: 시간대 + ru: Часовой пояс + ms: Zon waktu + pt-br: Fuso horário + tr: Saat Dilimi + es-es: Zona horaria + fa: منطقه زمانی + lo: ເຂດເວລາ + required: true + type: text diff --git a/apps/gomodel/0.2.3/data/.gitkeep b/apps/gomodel/0.2.3/data/.gitkeep new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/apps/gomodel/0.2.3/data/.gitkeep @@ -0,0 +1 @@ + diff --git a/apps/gomodel/0.2.3/docker-compose.yml b/apps/gomodel/0.2.3/docker-compose.yml new file mode 100644 index 000000000..3215d2b89 --- /dev/null +++ b/apps/gomodel/0.2.3/docker-compose.yml @@ -0,0 +1,51 @@ +services: + gomodel: + image: "enterpilot/gomodel:0.2.3" + container_name: ${CONTAINER_NAME} + restart: unless-stopped + user: "65532:65532" + networks: + - 1panel-network + ports: + - "${PANEL_APP_PORT_HTTP}:8080" + environment: + - PORT=8080 + - GOMODEL_MASTER_KEY=${GOMODEL_MASTER_KEY} + - STORAGE_TYPE=sqlite + - SQLITE_PATH=/app/data/gomodel.db + - GOMODEL_CACHE_DIR=/app/.cache + - CONFIG_STRICT=true + - BODY_SIZE_LIMIT=10M + - ADMIN_ENDPOINTS_ENABLED=true + - ADMIN_UI_ENABLED=true + - LOGGING_ENABLED=true + - LOGGING_LOG_BODIES=false + - LOGGING_LOG_HEADERS=false + - LOGGING_ONLY_MODEL_INTERACTIONS=true + - USAGE_ENABLED=true + - METRICS_ENABLED=false + - SWAGGER_ENABLED=false + - PPROF_ENABLED=false + - LOG_LEVEL=info + volumes: + - "${APP_DATA_DIR}:/app/data" + read_only: true + tmpfs: + - /app/.cache:uid=65532,gid=65532,mode=0750,size=64m + - /tmp:uid=65532,gid=65532,mode=1777,size=64m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + healthcheck: + test: ["CMD", "/gomodel", "--health"] + interval: 30s + timeout: 5s + start_period: 10s + retries: 5 + labels: + createdBy: "Apps" + +networks: + 1panel-network: + external: true diff --git a/apps/gomodel/0.2.3/scripts/init.sh b/apps/gomodel/0.2.3/scripts/init.sh new file mode 100755 index 000000000..74473b7e3 --- /dev/null +++ b/apps/gomodel/0.2.3/scripts/init.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" +ENV_FILE="${ENV_FILE:-$ROOT_DIR/.env}" + +fail() { + printf '%s\n' "$1" >&2 + exit 1 +} + +read_env_value() { + local key="$1" + [[ -f "$ENV_FILE" ]] || return 0 + local value + value="$(sed -n "s/^${key}=//p" "$ENV_FILE" | tail -n 1)" + case "$value" in + \"*\") value="${value#\"}"; value="${value%\"}" ;; + \'*\') value="${value#\'}"; value="${value%\'}" ;; + esac + printf '%s\n' "$value" +} + +configured_value() { + local key="$1" + local default_value="$2" + local value + value="${!key:-}" + if [[ -z "$value" ]]; then + value="$(read_env_value "$key")" + fi + printf '%s\n' "${value:-$default_value}" +} + +resolve_app_path() { + local key="$1" + local raw="$2" + local clean candidate resolved current part + local -a parts=() + case "$raw" in + ""|/*|.|..|../*|*/../*|*/..) echo "unsafe ${key} path" >&2; return 1 ;; + esac + if [[ "$raw" =~ [[:cntrl:]] ]]; then + echo "unsafe ${key} path" >&2 + return 1 + fi + clean="${raw#./}" + [[ -n "$clean" ]] || { echo "unsafe ${key} path" >&2; return 1; } + command -v realpath >/dev/null 2>&1 || { echo "realpath is required" >&2; return 1; } + candidate="$ROOT_DIR/$clean" + resolved="$(realpath -m -- "$candidate")" || { echo "unsafe ${key} path" >&2; return 1; } + case "$resolved" in + "$ROOT_DIR"/*) ;; + *) echo "unsafe ${key} path" >&2; return 1 ;; + esac + current="$ROOT_DIR" + IFS='/' read -r -a parts <<< "$clean" + for part in "${parts[@]}"; do + [[ -z "$part" || "$part" == "." ]] && continue + current="$current/$part" + if [[ -L "$current" ]]; then + echo "unsafe ${key} path" >&2 + return 1 + fi + done + printf '%s\n' "$resolved" +} + +ensure_dir() { + local key="$1" + local raw + local path + raw="$(configured_value "$key" "$2")" + path="$(resolve_app_path "$key" "$raw")" + install -d -m 0750 -- "$path" + [[ "$(resolve_app_path "$key" "$raw")" == "$path" ]] || { echo "unsafe ${key} path" >&2; return 1; } +} + +[[ -f "$ENV_FILE" && ! -L "$ENV_FILE" ]] || fail "$ENV_FILE must be a regular file" + +master_key="${GOMODEL_MASTER_KEY:-$(read_env_value GOMODEL_MASTER_KEY)}" + +[[ ${#master_key} -ge 24 && ${#master_key} -le 512 ]] || fail 'GOMODEL_MASTER_KEY must contain 24 to 512 characters' +[[ "$master_key" != *$'\n'* && "$master_key" != *$'\r'* ]] || fail 'GOMODEL_MASTER_KEY must not contain line breaks' + +ensure_dir "APP_DATA_DIR" "./data" +data_value="$(configured_value "APP_DATA_DIR" "./data")" +data_dir="$(resolve_app_path "APP_DATA_DIR" "$data_value")" +chown 65532:65532 -- "$data_dir" +chmod 0750 -- "$data_dir" diff --git a/apps/gomodel/0.2.3/scripts/uninstall.sh b/apps/gomodel/0.2.3/scripts/uninstall.sh new file mode 100755 index 000000000..c6af20129 --- /dev/null +++ b/apps/gomodel/0.2.3/scripts/uninstall.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail + +docker-compose down --volumes --remove-orphans diff --git a/apps/gomodel/0.2.3/scripts/upgrade.sh b/apps/gomodel/0.2.3/scripts/upgrade.sh new file mode 100755 index 000000000..5ec28d784 --- /dev/null +++ b/apps/gomodel/0.2.3/scripts/upgrade.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +exec "$SCRIPT_DIR/init.sh"