Merge pull request #91 from CzBiX/docker

generate server config on first run
pull/93/head
Darien Raymond 9 years ago
commit 5c8ac0d6e0

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

@ -16,11 +16,21 @@ Then spin up a v2ray instance with:
./run.sh
```
The build script will generate a server config file with random user id. You
can get it from `server-cfg.json`.
The docker image will generate a server config file with random user id on first run.
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:
```bash
docker exec v2ray tail -F /v2ray/logs/access.log
docker exec v2ray tail -F /go/access.log
```

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

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

@ -7,6 +7,7 @@ rand_str () {
}
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
{

Loading…
Cancel
Save