1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-16 09:26:21 -05:00

Merge pull request #62 from adoot/master

docker build for v2ray
This commit is contained in:
V2 Ray 2015-12-27 21:07:23 +01:00
commit ed5be19dbe
6 changed files with 92 additions and 11 deletions

23
contrib/docker/Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM phusion/baseimage
ENV GOPATH /v2ray
ENV PATH $PATH:/usr/local/go/bin
RUN apt-get update
RUN apt-get install -y git
RUN apt-get clean
RUN mkdir -p /v2ray/logs
RUN curl -o /go.tar.gz https://storage.googleapis.com/golang/go1.5.2.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf /go.tar.gz
RUN rm /go.tar.gz
RUN go get -u github.com/v2ray/v2ray-core
RUN rm -f $GOPATH/bin/build
RUN go install github.com/v2ray/v2ray-core/tools/build
RUN $GOPATH/bin/build
EXPOSE 27183
ADD server-cfg.json /v2ray/server-cfg.json
CMD /v2ray/bin/v2ray-custom-linux-64/v2ray --config="/v2ray/server-cfg.json"

26
contrib/docker/README.md Normal file
View File

@ -0,0 +1,26 @@
Docker build for v2ray
=======================
Usage
-----
To build the image:
```bash
./build.sh
```
Then spin up a v2ray instance with:
```bash
./run.sh
```
The build script will generate a server config file with random user id. You
can get it from `server-cfg.json`.
To tail the access log, run:
```bash
docker exec v2ray tail -F /v2ray/logs/access.log
```

7
contrib/docker/build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
if [ ! -e server-cfg.json ]; then
./gen-server-config.sh
fi
docker build --rm=true --tag=$USER/v2ray ./

View File

@ -0,0 +1,30 @@
#!/bin/bash
PORT=27183
rand_str () {
cat /dev/urandom | tr -dc 'a-f0-9' | fold -w $1 | head -n 1
}
ID="$(rand_str 8)-$(rand_str 4)-$(rand_str 4)-$(rand_str 4)-$(rand_str 12)"
cat <<EOF > server-cfg.json
{
"port": $PORT,
"log" : {
"access": "/v2ray/logs/access.log"
},
"inbound": {
"protocol": "vmess",
"settings": {
"clients": [
{"id": "$ID"}
]
}
},
"outbound": {
"protocol": "freedom",
"settings": {}
}
}
EOF

3
contrib/docker/run.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker run -d --name=v2ray -p 27183:27183/tcp $USER/v2ray

View File

@ -9,23 +9,15 @@ if [ "$ARCH" == "i686" ] || [ "$ARCH" == "i386" ]; then
GO_CUR=${GO_X86}
fi
function git_not_installed {
git --version 2>&1 >/dev/null
GIT_IS_AVAILABLE=$?
return $GIT_IS_AVAILABLE
}
if [ git_not_installed ]; then
apt-get install git -y
fi
which git > /dev/null || apt-get install git -y
if [ -z "$GOPATH" ]; then
curl -o go_latest.tar.gz ${GO_CUR}
tar -C /usr/local -xzf go_latest.tar.gz
rm go_latest.tar.gz
export PATH=$PATH:/usr/local/go/bin
mkdir /v2ray
mkdir /v2ray &> /dev/null
export GOPATH=/v2ray
fi