add: docker file

pull/62/head
adoot 2015-12-25 02:27:13 +00:00
parent 3bbb1c6a93
commit ffa2f49621
5 changed files with 89 additions and 0 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