Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/charlieethan/docker into ch…
Browse files Browse the repository at this point in the history
…arlieethan-master
  • Loading branch information
kslr committed Oct 26, 2020
2 parents 9795254 + 75a104a commit 9027bff
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 52 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ jobs:
echo "TAG=$(cat ReleaseTag | head -n1)" >> $GITHUB_ENV
shell: bash

- name: Install Golang
uses: actions/setup-go@v2
with:
go-version: 1.15.x

- name: Build Target
run: |
chmod +x v2ray.sh
./v2ray.sh
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

Expand All @@ -52,7 +42,6 @@ jobs:
--output "type=image,push=true" \
--tag "${{ secrets.DOCKER_USERNAME }}/v2fly-core:${{ env.TAG }}" \
--file Dockerfile .
test:
needs: build
runs-on: ubuntu-latest
Expand Down
19 changes: 7 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
FROM alpine:latest
FROM --platform=${TARGETPLATFORM} alpine:latest
LABEL maintainer "V2Fly Community <dev@v2fly.org>"

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}"

VOLUME /etc/v2ray
CMD [ "/usr/bin/v2ray", "-config", "/etc/v2ray/config.json" ]
2 changes: 1 addition & 1 deletion ReleaseTag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v4.31.2
v4.31.2
99 changes: 71 additions & 28 deletions v2ray.sh
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"

0 comments on commit 9027bff

Please sign in to comment.