File size: 1,520 Bytes
f938cda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM alpine:3.22.0

ARG CLIPROXYAPI_REPO=router-for-me/CLIProxyAPI

ENV APP_HOME=/opt/cli-proxy-api \
    DATA_DIR=/data \
    HOME=/data \
    TZ=Asia/Shanghai

RUN apk add --no-cache ca-certificates curl tar tzdata

RUN mkdir -p "$APP_HOME" "$DATA_DIR"

RUN set -eux; \
    latest_url="$(curl -fsSLI -o /dev/null -w '%{url_effective}' "https://github.com/${CLIPROXYAPI_REPO}/releases/latest")"; \
    tag="${latest_url##*/}"; \
    version="${tag#v}"; \
    asset="CLIProxyAPI_${version}_linux_amd64.tar.gz"; \
    asset_url="https://github.com/${CLIPROXYAPI_REPO}/releases/download/${tag}/${asset}"; \
    checksums_url="https://github.com/${CLIPROXYAPI_REPO}/releases/download/${tag}/checksums.txt"; \
    curl -fsSL "$checksums_url" -o /tmp/checksums.txt; \
    curl -fsSL "$asset_url" -o /tmp/cli-proxy-api.tar.gz; \
    expected_sha="$(grep " ${asset}$" /tmp/checksums.txt | awk '{print $1}')"; \
    test -n "$expected_sha"; \
    echo "$expected_sha  /tmp/cli-proxy-api.tar.gz" | sha256sum -c -; \
    tar -xzf /tmp/cli-proxy-api.tar.gz -C "$APP_HOME"; \
    if [ -f "$APP_HOME/CLIProxyAPI" ]; then mv "$APP_HOME/CLIProxyAPI" "$APP_HOME/cli-proxy-api"; fi; \
    test -f "$APP_HOME/cli-proxy-api"; \
    chmod +x "$APP_HOME/cli-proxy-api"; \
    rm -f /tmp/checksums.txt /tmp/cli-proxy-api.tar.gz

COPY entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh && \
    cp /usr/share/zoneinfo/${TZ} /etc/localtime && \
    echo "${TZ}" > /etc/timezone

WORKDIR /data

EXPOSE 8317

ENTRYPOINT ["/entrypoint.sh"]