[docker] generate server config on first run

pull/91/head
CzBiX 2016-02-22 17:57:43 +08:00
parent f55d22e8cf
commit c07cc6c6af
5 changed files with 25 additions and 12 deletions

View File

@ -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"]

View File

@ -16,8 +16,12 @@ 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
```
To tail the access log, run:

View File

@ -1,7 +1,3 @@
#!/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,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)"
echo "Generated client ID: $ID"
cat <<EOF > server-cfg.json
{