forked from v2fly/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'charlieethan-master' into master
- Loading branch information
Showing
4 changed files
with
80 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
FROM alpine:latest | ||
FROM --platform=${TARGETPLATFORM} alpine:latest | ||
LABEL maintainer "V2Fly Community <[email protected]>" | ||
|
||
WORKDIR /root | ||
ARG TARGETVARIANT | ||
ARG TARGETARCH | ||
COPY v2ray-${TARGETARCH}${TARGETVARIANT}.tar.gz /usr/bin/v2ray.tar.gz | ||
RUN mkdir -p /usr/local/share/v2ray | ||
COPY geoip.dat /usr/local/share/v2ray/geoip.dat | ||
COPY geosite.dat /usr/local/share/v2ray/geosite.dat | ||
COPY config.json /etc/v2ray/config.json | ||
ARG TARGETPLATFORM | ||
COPY v2ray.sh /root/v2ray.sh | ||
|
||
RUN set -ex \ | ||
&& apk add --no-cache tzdata ca-certificates \ | ||
&& mkdir -p /etc/v2ray/ /var/log/v2ray \ | ||
&& tar -zxvf /usr/bin/v2ray.tar.gz -C /usr/bin \ | ||
&& rm -fv /usr/bin/v2ray.tar.gz | ||
&& apk add --no-cache tzdata openssl ca-certificates \ | ||
&& mkdir -p /etc/v2ray /usr/local/share/v2ray /var/log/v2ray \ | ||
&& chmod +x /root/v2ray.sh \ | ||
&& /root/v2ray.sh "${TARGETPLATFORM}" \ | ||
&& rm /root/v2ray.sh | ||
|
||
VOLUME /etc/v2ray | ||
CMD [ "/usr/bin/v2ray", "-config", "/etc/v2ray/config.json" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v4.31.2 | ||
v4.31.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,71 @@ | ||
#!/bin/bash | ||
|
||
# Get code | ||
CUR=${PWD} | ||
TAG=$(cat ReleaseTag | head -n1) | ||
git clone -b ${TAG} https://github.com/v2fly/v2ray-core.git && cp v2ray-core/release/config/*.dat ${CUR} && cp v2ray-core/release/config/config.json ${CUR} | ||
cd v2ray-core | ||
|
||
# Build release | ||
ARCHS=( 386 amd64 arm arm64 ppc64le s390x ) | ||
ARMS=( 6 7 ) | ||
LDFLAGS="-s -w -buildid=" | ||
|
||
for ARCH in ${ARCHS[@]}; do | ||
if [ "${ARCH}" = "arm" ]; then | ||
for ARM in ${ARMS[@]}; do | ||
echo "Building v2ray-linux-${ARCH}v${ARM}" | ||
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${ARM} go build -o v2ray -trimpath -ldflags "${LDFLAGS}" ./main | ||
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${ARM} go build -o v2ctl -trimpath -ldflags "${LDFLAGS}" -tags confonly ./infra/control/main | ||
chmod +x v2ray v2ctl && tar -zvcf ${CUR}/v2ray-${ARCH}v${ARM}.tar.gz v2ray v2ctl && rm -fv v2ray v2ctl | ||
done | ||
else | ||
echo "Building v2ray-linux-${ARCH}" | ||
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o v2ray -trimpath -ldflags "${LDFLAGS}" ./main | ||
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o v2ctl -trimpath -ldflags "${LDFLAGS}" -tags confonly ./infra/control/main | ||
chmod +x v2ray v2ctl && tar -zvcf ${CUR}/v2ray-${ARCH}.tar.gz v2ray v2ctl && rm -fv v2ray v2ctl | ||
fi | ||
done | ||
#!/bin/sh | ||
|
||
# Set ARG | ||
PLATFORM=$1 | ||
if [ -z "$PLATFORM" ]; then | ||
ARCH="64" | ||
else | ||
case "$PLATFORM" in | ||
linux/386) | ||
ARCH="32" | ||
;; | ||
linux/amd64) | ||
ARCH="64" | ||
;; | ||
linux/arm/v6) | ||
ARCH="arm32-v6" | ||
;; | ||
linux/arm/v7) | ||
ARCH="arm32-v7a" | ||
;; | ||
linux/arm64|linux/arm64/v8) | ||
ARCH="arm64-v8a" | ||
;; | ||
linux/ppc64le) | ||
ARCH="ppc64le" | ||
;; | ||
linux/s390x) | ||
ARCH="s390x" | ||
;; | ||
*) | ||
ARCH="" | ||
;; | ||
esac | ||
fi | ||
[ -z "${ARCH}" ] && echo "Error: Not supported OS Architecture" && exit 1 | ||
|
||
# Download files | ||
V2RAY_FILE="v2ray-linux-${ARCH}.zip" | ||
DGST_FILE="v2ray-linux-${ARCH}.zip.dgst" | ||
echo "Downloading binary file: ${V2RAY_FILE}" | ||
echo "Downloading binary file: ${DGST_FILE}" | ||
|
||
TAG=$(wget -qO- https://raw.githubusercontent.com/v2fly/docker/master/ReleaseTag | head -n1) | ||
wget -O ${PWD}/v2ray.zip https://github.com/v2fly/v2ray-core/releases/download/${TAG}/${V2RAY_FILE} > /dev/null 2>&1 | ||
wget -O ${PWD}/v2ray.zip.dgst https://github.com/v2fly/v2ray-core/releases/download/${TAG}/${DGST_FILE} > /dev/null 2>&1 | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Error: Failed to download binary file: ${V2RAY_FILE} ${DGST_FILE}" && exit 1 | ||
fi | ||
echo "Download binary file: ${V2RAY_FILE} ${DGST_FILE} completed" | ||
|
||
# Check SHA512 | ||
LOCAL=$(openssl dgst -sha512 v2ray.zip | sed 's/([^)]*)//g') | ||
STR=$(cat v2ray.zip.dgst | grep 'SHA512' | head -n1) | ||
|
||
if [ "${LOCAL}" = "${STR}" ]; then | ||
echo " Check passed" && rm -fv v2ray.zip.dgst | ||
else | ||
echo " Check have not passed yet " && exit 1 | ||
fi | ||
|
||
# Prepare | ||
echo "Prepare to use" | ||
unzip v2ray.zip && chmod +x v2ray v2ctl | ||
mv v2ray v2ctl /usr/bin/ | ||
mv geosite.dat geoip.dat /usr/local/share/v2ray/ | ||
mv config.json /etc/v2ray/config.json | ||
|
||
# Clean | ||
rm -rf ${PWD}/* | ||
echo "Done" |