Skip to content

Commit

Permalink
obtain images from release
Browse files Browse the repository at this point in the history
  • Loading branch information
kslr committed Oct 10, 2020
1 parent 1c8f327 commit 723e558
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 81 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
on:
push:
paths:
- "ReleaseTag"

name: docker push
jobs:
build:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2

- name: Set env
run: |
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: |
cp ReleaseTag DockerHub
cd DockerHub
chmod +x v2ray.sh
./v2ray.sh
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build latest
run: |
cd DockerHub
docker buildx build --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x \
--output "type=image,push=true" \
--tag "${{ secrets.DOCKER_USERNAME }}/v2fly-core:latest" \
--file Dockerfile.multi .
- name: Build tag
run: |
cd DockerHub
docker buildx build --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x \
--output "type=image,push=true" \
--tag "${{ secrets.DOCKER_USERNAME }}/v2fly-core:${{ env.TAG }}" \
--file Dockerfile.multi .
test:
needs: build
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2

- name: Set env
run: |
echo "TAG=$(cat ReleaseTag | head -n1)" >> $GITHUB_ENV
shell: bash

- name: Test Docker image
run: |
docker run --rm --entrypoint /usr/bin/v2ray ${{ secrets.DOCKER_USERNAME }}/v2fly-core:latest -version
docker run --rm --entrypoint /usr/bin/v2ray ${{ secrets.DOCKER_USERNAME }}/v2fly-core:${{ env.TAG }} -version
80 changes: 0 additions & 80 deletions .github/workflows/docker-tag.yml

This file was deleted.

19 changes: 19 additions & 0 deletions DockerHub/Dockerfile.multi
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM 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
COPY geoip.dat /usr/bin/geoip.dat
COPY geosite.dat /usr/bin/geosite.dat
COPY config.json /etc/v2ray/config.json

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

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

0 comments on commit 723e558

Please sign in to comment.