File size: 2,596 Bytes
60ad684
 
 
3c196e5
60ad684
 
 
 
3c196e5
60ad684
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b96dca
60ad684
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b96dca
60ad684
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Upload this file and README.md to the Docker Space root.
FROM ghcr.io/rachelos/base-full:latest AS runtime

ARG REPO_URL=https://github.com/CaPaCaptain/WeRSS.git
ARG REPO_REF=main
# Change this value, or use Factory rebuild, to bypass the Git fetch cache.
ARG REBUILD_TAG=initial

ENV DEBIAN_FRONTEND=noninteractive \
    INSTALL=True \
    BROWSER_TYPE=webkit \
    PLANT_PATH=/app/env \
    PORT=7860 \
    THREADS=1 \
    AUTO_RELOAD=False \
    ENABLE_JOB=True \
    HEADLESS=false \
    ENABLE_XVFB=true \
    DB=sqlite:////data/db.db \
    WERSS_DATA_DIR=/data \
    WEREAD_LIC_PATH=/app/data/wx.lic \
    WEREAD_PROFILE_DIR=/app/data/weread-chrome-profile \
    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/*

# The private repository token is a BuildKit secret, never a build argument
# or part of the Git remote URL. Scope its header to GitHub only.
RUN --mount=type=secret,id=GITHUB_TOKEN,required=false \
    set -eu; \
    : "$REBUILD_TAG"; \
    case "$REPO_URL" in https://github.com/*) ;; *) echo "REPO_URL must be an HTTPS GitHub URL" >&2; exit 1;; esac; \
    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.https://github.com/.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; \
    git -C /app rev-parse HEAD > /app/docker_revision.txt

WORKDIR /app
# Preserve the original install/start flow and the tracked static/ frontend.
# Install Chromium as well as WebKit for the upstream WeRead QR/profile flow.
RUN set -eu; \
    chmod +x /app/install.sh /app/start.sh /app/huggingface/start.sh; \
    /app/install.sh; \
    VENV="/app/env_$(uname -m)"; \
    . /app/environment.sh; \
    "$VENV/bin/python3" -m playwright install chromium --with-deps; \
    test -s /app/static/index.html; \
    test -d /app/static/assets; \
    cp /app/config.example.yaml /app/config.template.yaml; \
    if ! getent passwd 1000 >/dev/null; then useradd --create-home --uid 1000 werss; fi; \
    mkdir -p /app/data /data; \
    chown -R 1000:1000 /app; \
    chown 1000:1000 /data

USER 1000:1000
EXPOSE 7860
CMD ["/app/huggingface/start.sh"]