Upload 4 files
Browse files- Dockerfile +3 -3
- README.md +3 -3
- bootstrap.py +1 -1
- space_boot.sh +15 -12
Dockerfile
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
FROM ghcr.io/1111qwq1111/meme-generator:latest
|
| 2 |
|
| 3 |
-
# Hugging Face Spaces expects the app to listen on $PORT (default
|
| 4 |
-
ENV PORT=
|
| 5 |
-
EXPOSE
|
| 6 |
|
| 7 |
WORKDIR /workspace
|
| 8 |
|
|
|
|
| 1 |
FROM ghcr.io/1111qwq1111/meme-generator:latest
|
| 2 |
|
| 3 |
+
# Hugging Face Spaces expects the app to listen on $PORT (default 7860)
|
| 4 |
+
ENV PORT=7860
|
| 5 |
+
EXPOSE 7860
|
| 6 |
|
| 7 |
WORKDIR /workspace
|
| 8 |
|
README.md
CHANGED
|
@@ -4,13 +4,13 @@ emoji: 😎
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: docker
|
| 7 |
-
app_port:
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
| 11 |
# Hugging Face Space for ghcr.io/1111qwq1111/meme-generator:latest
|
| 12 |
|
| 13 |
-
This Space wraps your published image and adapts it for Spaces (listening on `$PORT`, default
|
| 14 |
|
| 15 |
## How to use
|
| 16 |
|
|
@@ -26,7 +26,7 @@ This Space wraps your published image and adapts it for Spaces (listening on `$P
|
|
| 26 |
The container will:
|
| 27 |
- Ensure built-in memes load after the translator monkey‑patch.
|
| 28 |
- Use your OpenAI‑compatible translator if envs are present, otherwise fallback to upstream behavior.
|
| 29 |
-
- Bind the server to `$PORT` (
|
| 30 |
|
| 31 |
## Endpoints
|
| 32 |
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
| 11 |
# Hugging Face Space for ghcr.io/1111qwq1111/meme-generator:latest
|
| 12 |
|
| 13 |
+
This Space wraps your published image and adapts it for Spaces (listening on `$PORT`, default 7860). It also supports translator env variables via Space Secrets.
|
| 14 |
|
| 15 |
## How to use
|
| 16 |
|
|
|
|
| 26 |
The container will:
|
| 27 |
- Ensure built-in memes load after the translator monkey‑patch.
|
| 28 |
- Use your OpenAI‑compatible translator if envs are present, otherwise fallback to upstream behavior.
|
| 29 |
+
- Bind the server to `$PORT` (7860 by default on Spaces).
|
| 30 |
|
| 31 |
## Endpoints
|
| 32 |
|
bootstrap.py
CHANGED
|
@@ -174,6 +174,6 @@ register_routers()
|
|
| 174 |
data_dir = os.environ.get("MEME_DATA_DIR", "/app/data")
|
| 175 |
app.mount("/memes/static", StaticFiles(directory=data_dir), name="static")
|
| 176 |
|
| 177 |
-
port = int(os.environ.get("PORT", "
|
| 178 |
print(f"[bootstrap] Starting uvicorn on 0.0.0.0:{port}", flush=True)
|
| 179 |
uvicorn.run(app, host="0.0.0.0", port=port)
|
|
|
|
| 174 |
data_dir = os.environ.get("MEME_DATA_DIR", "/app/data")
|
| 175 |
app.mount("/memes/static", StaticFiles(directory=data_dir), name="static")
|
| 176 |
|
| 177 |
+
port = int(os.environ.get("PORT", "7860"))
|
| 178 |
print(f"[bootstrap] Starting uvicorn on 0.0.0.0:{port}", flush=True)
|
| 179 |
uvicorn.run(app, host="0.0.0.0", port=port)
|
space_boot.sh
CHANGED
|
@@ -8,7 +8,7 @@ CONFIG_DIR="${XDG_CONFIG_HOME}/meme_generator"
|
|
| 8 |
CONFIG_FILE="${CONFIG_DIR}/config.toml"
|
| 9 |
mkdir -p "${CONFIG_DIR}"
|
| 10 |
|
| 11 |
-
PORT="${PORT:-
|
| 12 |
MEME_DATA_DIR="${MEME_DATA_DIR:-/app/data}"
|
| 13 |
|
| 14 |
# Snapshot translator env for logs (no secrets printed)
|
|
@@ -39,15 +39,18 @@ log_level = "INFO"
|
|
| 39 |
EOF
|
| 40 |
echo "[space] Wrote config to ${CONFIG_FILE}"
|
| 41 |
|
| 42 |
-
# Choose a Python interpreter (
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
| 51 |
fi
|
| 52 |
-
echo "[space] Using interpreter: $
|
| 53 |
-
exec "$PY_BIN" -u /workspace/bootstrap.py
|
|
|
|
| 8 |
CONFIG_FILE="${CONFIG_DIR}/config.toml"
|
| 9 |
mkdir -p "${CONFIG_DIR}"
|
| 10 |
|
| 11 |
+
PORT="${PORT:-7860}"
|
| 12 |
MEME_DATA_DIR="${MEME_DATA_DIR:-/app/data}"
|
| 13 |
|
| 14 |
# Snapshot translator env for logs (no secrets printed)
|
|
|
|
| 39 |
EOF
|
| 40 |
echo "[space] Wrote config to ${CONFIG_FILE}"
|
| 41 |
|
| 42 |
+
# Choose a Python interpreter (prefer virtualenv if present)
|
| 43 |
+
if [ -n "${VIRTUAL_ENV:-}" ] && [ -x "${VIRTUAL_ENV}/bin/python" ]; then
|
| 44 |
+
PY_BIN="${VIRTUAL_ENV}/bin/python"
|
| 45 |
+
elif [ -x "/opt/venv/bin/python" ]; then
|
| 46 |
+
PY_BIN="/opt/venv/bin/python"
|
| 47 |
+
elif command -v python >/dev/null 2>&1; then
|
| 48 |
+
PY_BIN="$(command -v python)"
|
| 49 |
+
elif command -v python3 >/dev/null 2>&1; then
|
| 50 |
+
PY_BIN="$(command -v python3)"
|
| 51 |
+
else
|
| 52 |
+
echo "[space] Error: no python interpreter found (virtualenv/python/python3)" >&2
|
| 53 |
+
exit 1
|
| 54 |
fi
|
| 55 |
+
echo "[space] Using interpreter: ${PY_BIN}"
|
| 56 |
+
exec "${PY_BIN}" -u /workspace/bootstrap.py
|