-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (41 loc) · 1.58 KB
/
Copy pathDockerfile
File metadata and controls
54 lines (41 loc) · 1.58 KB
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
FROM alpine:latest
# install packages
RUN apk add --no-cache python3 py3-jinja2 libqrencode-tools s6-overlay
RUN addgroup -g 1000 -S docker && \
adduser -u 1000 -G docker -S docker
# download packages
RUN <<'EOF'
set -euo pipefail
apk add --no-cache --virtual .build-deps unzip curl jq wget
mkdir -p /opt/xray
JSON=$(curl -fsSL https://api.github.com/repos/XTLS/Xray-core/releases/latest)
DOWNLOAD_URL=$(printf '%s' "$JSON" | jq -r '.assets[] | select(.name | endswith("Xray-linux-64.zip")) | .browser_download_url')
wget -q -O /tmp/xray.zip "${DOWNLOAD_URL}"
unzip /tmp/xray.zip -d /opt/xray
rm /tmp/xray.zip
XRAY_VERSION=$(printf '%s' "$JSON" | jq -r '.tag_name')
printf '%s\n' "$XRAY_VERSION" > /opt/xray/XRAY_VERSION
echo "XRAY: $XRAY_VERSION"
JSON=$(curl -fsSL https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest)
DOWNLOAD_URL=$(printf '%s' "$JSON" | jq -r '.assets[] | select(.name | endswith("geoip.dat")) | .browser_download_url')
wget -q -O /opt/xray/geoip.dat "${DOWNLOAD_URL}"
echo "GeoIP: $DOWNLOAD_URL"
DOWNLOAD_URL=$(printf '%s' "$JSON" | jq -r '.assets[] | select(.name | endswith("geosite.dat")) | .browser_download_url')
wget -q -O /opt/xray/geosite.dat "${DOWNLOAD_URL}"
echo "GeoSite: $DOWNLOAD_URL"
apk del .build-deps
EOF
COPY ./opt /opt/
RUN chown -R docker:docker /opt/xray
#
# Copy s6 service files
#
COPY --chown=root:root ./s6 /etc/s6-overlay/s6-rc.d/
RUN <<'EOF'
set -euo pipefail
chmod +x /etc/s6-overlay/s6-rc.d/init/up
chmod +x /etc/s6-overlay/s6-rc.d/xray/run
chmod +x /etc/s6-overlay/s6-rc.d/xray-ip/run
EOF
VOLUME /etc/d2ray
ENTRYPOINT ["/init"]