Add Dockerfile and update README
This commit is contained in:
parent
0cb42d84ea
commit
956a5dc355
32
README.md
32
README.md
|
@ -21,13 +21,41 @@ worth my time.
|
|||
|
||||
### Building
|
||||
|
||||
`go install -ldflags="-s -w" -trimpath ./cmd/ubsserver`
|
||||
You can get prebuilt binaries for a number of platforms from the gitlab repository in the "Download artifacts" section.
|
||||
To build from source, just run:
|
||||
|
||||
`go install ./cmd/ubsserver`
|
||||
|
||||
It is also possible to build a very basic Docker container image by running:
|
||||
|
||||
`docker build -t ubsserver -f docker/ubsserver/Dockerfile .`
|
||||
|
||||
### Running
|
||||
|
||||
To run the binary you just built:
|
||||
|
||||
`~/go/bin/ubsserver`
|
||||
|
||||
TODO: Suggest deployment setups
|
||||
It will start the API server listening on port 8090 and using the `data` directory under $PWD as the datastore.
|
||||
You can change the listening address using the `-listen` flag (e.g.: `-listen :9999` will listen on port 9999 on all
|
||||
addresses).
|
||||
|
||||
Similarly, you can change the datastore using the `-store` flag. The store is defined in the format
|
||||
`driver_name:driver_args` where `driver_name` is the name of the store driver while `driver_args` contains
|
||||
driver-specific settings.
|
||||
|
||||
Currently, only two drivers are implemented:
|
||||
|
||||
- **mem**: a volatile RAM-backed datastore only useful for testing and debugging. It does not take any arguments.
|
||||
- **fs**: the default driver: it stores sync data in json files in the directory specified as the argument (default is
|
||||
`data`)
|
||||
|
||||
If you built the container image, you can run the containerised version:
|
||||
|
||||
`docker run -it --rm -v /tmp/data:/data -p 8888:8090 localhost/ubsserver`
|
||||
|
||||
You can replace `/tmp/data` with the name of the directory where you want to store sync data and `8888` with the port
|
||||
where you want to expose the API service.
|
||||
|
||||
## Roadmap
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
FROM golang:alpine as builder
|
||||
WORKDIR /go/src/uBrowserSync
|
||||
COPY . .
|
||||
ARG GOOS=linux
|
||||
ARG GOARCH=amd64
|
||||
ARG GOARM=6
|
||||
RUN CGO_ENABLED=0 go install -ldflags="-w -s" -trimpath ./cmd/ubsserver
|
||||
|
||||
FROM scratch
|
||||
WORKDIR /
|
||||
VOLUME ["/data"]
|
||||
COPY --from=builder /go/bin/ubsserver /usr/bin/
|
||||
EXPOSE 8090
|
||||
ENTRYPOINT ["/usr/bin/ubsserver"]
|
Loading…
Reference in New Issue