Merge branch 'dockerdev' into flymaster

pull/2141/head
vcptr 2019-10-31 12:38:01 +08:00
commit 3c8c9adcf7
2 changed files with 40 additions and 3 deletions

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
############################
# STEP 1 build executable binary
############################
FROM golang:alpine AS builder
RUN apk update && apk add --no-cache git bash wget
WORKDIR /go/src/v2ray.com/core
RUN git clone --progress --depth=1 https://github.com/v2fly/v2ray-core.git . && \
bash ./release/user-package.sh nosource noconf abpathtgz=/tmp/v2ray.tgz
############################
# STEP 2 build a small image
############################
FROM alpine
COPY --from=builder /tmp/v2ray.tgz /tmp
RUN apk update && apk add ca-certificates && \
mkdir -p /usr/bin/v2ray && \
tar xvfz /tmp/v2ray.tgz -C /usr/bin/v2ray
ENTRYPOINT ["/usr/bin/v2ray/v2ray"]

View File

@ -86,6 +86,14 @@ packtgz() {
echo ">>> Generated: $(basename $PKG)"
}
packtgzAbPath() {
local ABPATH="$1"
echo ">>> Generating tgz package at $ABPATH"
pushd $TMP
tar cvfz $ABPATH .
echo ">>> Generated: $ABPATH"
}
pkg=zip
nosource=0
@ -127,6 +135,15 @@ case $arg in
tgz)
pkg=tgz
;;
abpathtgz=*)
pkg=${arg##abpathtgz=}
;;
codename=*)
CODENAME=${arg##codename=}
;;
buildname=*)
BUILDNAME=${arg##buildname=}
;;
esac
done
@ -135,6 +152,8 @@ if [[ $nosource != 1 ]]; then
fi
export GOOS GOARCH
echo "Build ARGS: GOOS=${GOOS} GOARCH=${GOARCH} CODENAME=${CODENAME} BUILDNAME=${BUILDNAME}"
echo "PKG ARGS: pkg=${pkg}"
build_v2
if [[ $nodat != 1 ]]; then
@ -147,11 +166,12 @@ fi
if [[ $pkg == "zip" ]]; then
packzip
elif [[ $pkg == "tgz" ]]; then
packtgz
else
packtgzAbPath $pkg
fi
if [[ $pkg == "tgz" ]]; then
packtgz
fi
cleanup