File suffix support for CF_API_KEY (#3489)

This commit is contained in:
Byron Collins
2025-06-05 21:35:26 +09:00
committed by GitHub
parent 0ba63777a3
commit f84171dca2
9 changed files with 67 additions and 2 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ A specific file can be omitted from each reference to allow for auto-selecting t
!!! warning "CurseForge API key usage" !!! warning "CurseForge API key usage"
A CurseForge API key must be allocated and set with `CF_API_KEY` [as described here](../types-and-platforms/mod-platforms/auto-curseforge.md#api-key). A CurseForge API key must be allocated and set with `CF_API_KEY` (or `CF_API_KEY_FILE`) [as described here](../types-and-platforms/mod-platforms/auto-curseforge.md#api-key).
## Project-file references ## Project-file references
@@ -32,6 +32,20 @@ To manage a CurseForge modpack automatically with upgrade support, pinned or lat
docker run --env-file=.env itzg/minecraft-server docker run --env-file=.env itzg/minecraft-server
``` ```
Alternately you can use [docker secrets](https://docs.docker.com/compose/how-tos/use-secrets/) with a `CF_API_KEY_FILE` environment variable:
```
service:
environment:
CF_API_KEY_FILE: /run/secrets/cf_api_key
secrets:
- cf_api_key
secrets:
cf_api_key:
file: cf_api_key.secret
```
!!! note !!! note
Be sure to use the appropriate [image tag for the Java version compatible with the modpack](../../versions/java.md). Be sure to use the appropriate [image tag for the Java version compatible with the modpack](../../versions/java.md).
+6
View File
@@ -730,6 +730,12 @@ alternatively, you can mount: <code>/etc/localtime:/etc/localtime:ro
<td><code></code></td> <td><code></code></td>
<td>✅</td> <td>✅</td>
</tr> </tr>
<tr>
<td><code>CF_API_KEY_FILE</code></td>
<td>A path to a file inside of container that contains <strong>YOUR</strong> CurseForge (Eternal) API Key.</td>
<td><code></code></td>
<td>✅</td>
</tr>
<tr> <tr>
<td><code>CF_PAGE_URL</code></td> <td><code>CF_PAGE_URL</code></td>
<td>Pass a page URL to the modpack or a specific file</td> <td>Pass a page URL to the modpack or a specific file</td>
+11
View File
@@ -21,9 +21,20 @@ set -eu
: "${CF_DOWNLOADS_REPO=$([ -d /downloads ] && echo '/downloads' || echo '')}" : "${CF_DOWNLOADS_REPO=$([ -d /downloads ] && echo '/downloads' || echo '')}"
: "${CF_MODPACK_MANIFEST:=}" : "${CF_MODPACK_MANIFEST:=}"
: "${CF_API_CACHE_DEFAULT_TTL:=}" # as ISO-8601 duration, such as P2D or PT12H : "${CF_API_CACHE_DEFAULT_TTL:=}" # as ISO-8601 duration, such as P2D or PT12H
: "${CF_API_KEY_FILE:=}" # Path to file containing CurseForge API key
resultsFile=/data/.install-curseforge.env resultsFile=/data/.install-curseforge.env
if [[ -n ${CF_API_KEY_FILE} ]]; then
if [[ -r "${CF_API_KEY_FILE}" ]]; then
CF_API_KEY="$(cat "${CF_API_KEY_FILE}")"
export CF_API_KEY
else
logError "CF_API_KEY_FILE is not readable: ${CF_API_KEY_FILE}"
exit 1
fi
fi
isDebugging && set -x isDebugging && set -x
ensureRemoveAllModsOff "MODPACK_PLATFORM=AUTO_CURSEFORGE" ensureRemoveAllModsOff "MODPACK_PLATFORM=AUTO_CURSEFORGE"
+11
View File
@@ -11,8 +11,19 @@ set -e -o pipefail
: "${PLUGINS_FILE:=}" : "${PLUGINS_FILE:=}"
: "${REMOVE_OLD_MODS_DEPTH:=1} " : "${REMOVE_OLD_MODS_DEPTH:=1} "
: "${REMOVE_OLD_MODS_INCLUDE:=*.jar,*-version.json}" : "${REMOVE_OLD_MODS_INCLUDE:=*.jar,*-version.json}"
: "${CF_API_KEY_FILE:=}" # Path to file containing CurseForge API key
sum_file=/data/.generic_pack.sum sum_file=/data/.generic_pack.sum
if [[ -n ${CF_API_KEY_FILE} ]]; then
if [[ -r "${CF_API_KEY_FILE}" ]]; then
CF_API_KEY="$(cat "${CF_API_KEY_FILE}")"
export CF_API_KEY
else
logError "CF_API_KEY_FILE is not readable: ${CF_API_KEY_FILE}"
exit 1
fi
fi
# shellcheck source=start-utils # shellcheck source=start-utils
. "${SCRIPTS:-/}start-utils" . "${SCRIPTS:-/}start-utils"
isDebugging && set -x isDebugging && set -x
+1
View File
@@ -1 +1,2 @@
data/ data/
cf_api_key.secret
@@ -0,0 +1,18 @@
services:
mc:
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "true"
SETUP_ONLY: "TRUE"
MODPACK_PLATFORM: AUTO_CURSEFORGE
CF_API_KEY_FILE: /run/secrets/cf_api_key
CF_PAGE_URL: https://www.curseforge.com/minecraft/modpacks/the-pixelmon-modpack/files/5954570
DEBUG: true
volumes:
- ./data:/data
secrets:
- cf_api_key
secrets:
cf_api_key:
file: cf_api_key.secret
+2
View File
@@ -0,0 +1,2 @@
[[ -n "$CF_API_KEY" ]] || exit 1
echo "$CF_API_KEY" > cf_api_key.secret || exit 1
@@ -0,0 +1,2 @@
mc-image-helper assert fileExists "/data/mods/ExplorersCompass-1.16.5-1.1.2-forge.jar"
mc-image-helper assert fileExists "/data/forge-1.16.5-36.2.34.jar"