1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00

Merge pull request #91 from CzBiX/docker

generate server config on first run
This commit is contained in:
Darien Raymond 2016-02-22 11:49:15 +01:00
commit 5c8ac0d6e0
5 changed files with 32 additions and 13 deletions

View File

@ -1,10 +1,14 @@
FROM golang:latest FROM golang:latest
RUN go get -u github.com/v2ray/v2ray-core RUN go get -u github.com/v2ray/v2ray-core \
RUN rm -f $GOPATH/bin/build && rm -f $GOPATH/bin/build \
RUN go install github.com/v2ray/v2ray-core/tools/build && go install github.com/v2ray/v2ray-core/tools/build \
RUN $GOPATH/bin/build && build \
&& rm -rf pkg src
EXPOSE 27183 EXPOSE 27183
ADD server-cfg.json /go/server-cfg.json COPY gen-server-cfg.sh /go/gen-server-cfg.sh
CMD /go/bin/v2ray-custom-linux-64/v2ray --config="/go/server-cfg.json" COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/go/bin/v2ray-custom-linux-64/v2ray", "--config=/go/server-cfg.json"]

View File

@ -16,11 +16,21 @@ Then spin up a v2ray instance with:
./run.sh ./run.sh
``` ```
The build script will generate a server config file with random user id. You The docker image will generate a server config file with random user id on first run.
can get it from `server-cfg.json`. You can get see it with:
```bash
docker logs v2ray
```
You can also specify config file by manual with:
```bash
docker run -d --name=v2ray -p 27183:27183 -v /config/file.json:/go/server-config.json $USER/v2ray
```
To tail the access log, run: To tail the access log, run:
```bash ```bash
docker exec v2ray tail -F /v2ray/logs/access.log docker exec v2ray tail -F /go/access.log
``` ```

View File

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

View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
if [ ! -e "server-cfg.json" ]; then
./gen-server-cfg.sh
fi
exec "$@"

View File

@ -7,6 +7,7 @@ rand_str () {
} }
ID="$(rand_str 8)-$(rand_str 4)-$(rand_str 4)-$(rand_str 4)-$(rand_str 12)" ID="$(rand_str 8)-$(rand_str 4)-$(rand_str 4)-$(rand_str 4)-$(rand_str 12)"
echo "Generated client ID: $ID"
cat <<EOF > server-cfg.json cat <<EOF > server-cfg.json
{ {