Browse Source

refactor: reduce the image volume

master
dnomd343 3 years ago
parent
commit
42e525d6ab
  1. 13
      Dockerfile
  2. 11
      asset.sh

13
Dockerfile

@ -4,15 +4,12 @@ RUN apk --update add --no-cache curl wget && \
sh /asset.sh
FROM alpine
COPY . /tmp/xray
COPY --from=asset /tmp/asset/ /tmp/xray/asset/
RUN apk --update add --no-cache iptables ip6tables net-tools curl && \
COPY ["./load.sh", "./tproxy.sh", "/etc/xray/"]
COPY --from=asset /tmp/asset/ /etc/xray/asset/
COPY --from=asset /tmp/xray/xray /usr/bin/
RUN apk --update add --no-cache iptables ip6tables && \
mkdir -p /etc/xray/conf && \
mkdir -p /etc/xray/expose/log && \
mkdir -p /etc/xray/expose/segment && \
mv /tmp/xray/tproxy.sh / && \
mv /tmp/xray/load.sh /etc/xray/ && \
mv /tmp/xray/asset/xray /usr/bin/ && \
mv /tmp/xray/asset /etc/xray/ && \
rm -rf /tmp/xray
mv /etc/xray/tproxy.sh /
CMD ["sh","/tproxy.sh"]

11
asset.sh

@ -2,15 +2,16 @@ get_github_latest_version() {
VERSION=$(curl --silent "https://api.github.com/repos/$1/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/');
}
XRAY_DIR="/tmp/xray"
ASSET_DIR="/tmp/asset"
mkdir -p $ASSET_DIR/pkg
mkdir -p $XRAY_DIR/pkg
XRAY_PKG_NAME="Xray-linux-arm64-v8a.zip"
get_github_latest_version "XTLS/Xray-core"
wget -P $ASSET_DIR/pkg "https://hub.fastgit.org/XTLS/Xray-core/releases/download/$VERSION/$XRAY_PKG_NAME"
unzip $ASSET_DIR/pkg/$XRAY_PKG_NAME -d /$ASSET_DIR/pkg
cp $ASSET_DIR/pkg/xray $ASSET_DIR
rm -rf $ASSET_DIR/pkg
wget -P $XRAY_DIR/pkg "https://hub.fastgit.org/XTLS/Xray-core/releases/download/$VERSION/$XRAY_PKG_NAME"
unzip $XRAY_DIR/pkg/$XRAY_PKG_NAME -d /$XRAY_DIR/pkg
cp $XRAY_DIR/pkg/xray $XRAY_DIR
rm -rf $XRAY_DIR/pkg
get_github_latest_version "Loyalsoldier/v2ray-rules-dat"
wget -P $ASSET_DIR "https://hub.fastgit.org/Loyalsoldier/v2ray-rules-dat/releases/download/$VERSION/geoip.dat"

Loading…
Cancel
Save