Spaces:
Running
Running
File size: 2,321 Bytes
1193472 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | # syntax=docker/dockerfile:1.7
FROM ghcr.io/rachelos/base-full:latest AS runtime
ARG REPO_URL=https://github.com/CaPaCaptain/WeRSS.git
ARG REPO_REF=main
ENV DEBIAN_FRONTEND=noninteractive \
INSTALL=True \
BROWSER_TYPE=webkit \
PLANT_PATH=/app/env \
PORT=7860 \
DB=sqlite:////data/db.db \
THREADS=1 \
AUTO_RELOAD=False \
LOG_LEVEL=INFO \
PYTHONUNBUFFERED=1
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends bash ca-certificates git \
&& rm -rf /var/lib/apt/lists/*
RUN --mount=type=secret,id=GITHUB_TOKEN,required=false \
set -eu; \
TOKEN="$(cat /run/secrets/GITHUB_TOKEN 2>/dev/null || true)"; \
rm -rf /app; \
git init /app; \
git -C /app remote add origin "${REPO_URL}"; \
if [ -n "${TOKEN}" ]; then \
AUTH_HEADER="$(printf 'x-access-token:%s' "${TOKEN}" | base64 | tr -d '\n')"; \
git -C /app -c http.extraHeader="Authorization: Basic ${AUTH_HEADER}" fetch --depth 1 origin "${REPO_REF}"; \
else \
git -C /app fetch --depth 1 origin "${REPO_REF}"; \
fi; \
git -C /app checkout --detach FETCH_HEAD
WORKDIR /app
RUN python3 - <<'PY'
from pathlib import Path
import re
config_path = Path("/app/config.example.yaml")
config_text = config_path.read_text(encoding="utf-8")
config_text = re.sub(
r"\$\{([A-Z][A-Z0-9_.]*)(?=[:-])",
lambda match: "${" + match.group(1).replace(".", "_"),
config_text,
)
config_path.write_text(config_text, encoding="utf-8")
main_path = Path("/app/main.py")
main_text = main_path.read_text(encoding="utf-8")
unsafe = ' print("环境变量:")\n for k,v in os.environ.items():\n print(f"{k}={v}")\n'
safe = ' print("Environment configuration loaded; values are hidden.")\n'
if unsafe in main_text:
main_text = main_text.replace(unsafe, safe)
main_path.write_text(main_text, encoding="utf-8")
PY
RUN chmod +x /app/install.sh /app/start.sh \
&& /app/install.sh \
&& cp /app/config.example.yaml /app/config.template.yaml
EXPOSE 7860
CMD ["bash", "-lc", "set -eu; unset GITHUB_TOKEN || true; mkdir -p /data; if [ ! -f /data/config.yaml ]; then cp /app/config.template.yaml /data/config.yaml; fi; rm -f /app/config.yaml; ln -s /data/config.yaml /app/config.yaml; rm -rf /app/data; ln -s /data /app/data; exec /app/start.sh"] |