Skip to content

Commit 81c8b04

Browse files
committed
build: Improve docker setup
1 parent e8fdb25 commit 81c8b04

File tree

10 files changed

+199
-7
lines changed

10 files changed

+199
-7
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules
2+
/dist
3+
/.git

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ yarn-error.log*
2121
*.sw?
2222

2323
# application specific
24-
board-config.yaml
24+
/config

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ RUN GOOS=linux GOARCH=amd64 packr build -o ../../release/ssl-status-board_linux_
1717
FROM alpine:3.9
1818
COPY --from=build_go /go/src/github.com/RoboCup-SSL/ssl-status-board/release/ssl-status-board_linux_amd64 /app/ssl-status-board
1919
EXPOSE 8082
20+
WORKDIR "/"
2021
ENTRYPOINT ["/app/ssl-status-board"]
21-
CMD ["/app/ssl-status-board", "-address", ":8082"]
22+
CMD ["/app/ssl-status-board"]

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ A Status Board for the Small Size League, optimized to show the current game sta
1212
If you just want to use this app, simply download the latest [release binary](https://github.com/RoboCup-SSL/ssl-status-board/releases/latest).
1313
The binary is self-contained. No dependencies are required.
1414

15+
You can also use pre-build docker images:
16+
```shell script
17+
docker pull robocupssl/ssl-status-board
18+
docker run -p 8082:8082 robocupssl/ssl-status-board
19+
# if you want to pass in the config file:
20+
docker run -p 8082:8082 -v "$(pwd)/config:/config" ssl-status-board
21+
```
22+
23+
By default, the UI is available at http://localhost:8082
24+
25+
A configuration file will be generated to `config/board-config.yaml` and can be tweaked.
26+
1527
### Runtime Requirements
1628
* No software dependencies (except for development, see below)
1729
* 64bit Linux, Windows, OSX (build your 32bit binaries yourself...)

cmd/ssl-status-board/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"net/http"
99
)
1010

11-
var address = flag.String("address", "localhost:8082", "The address on which the UI and API is served")
12-
var configFile = flag.String("c", "board-config.yaml", "The config file to use")
11+
var address = flag.String("address", ":8082", "The address on which the UI and API is served")
12+
var configFile = flag.String("c", "config/board-config.yaml", "The config file to use")
1313

1414
func main() {
1515
flag.Parse()

docker-compose.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: '2'
2+
3+
services:
4+
ssl-status-board:
5+
build: .
6+
ports:
7+
- "8082:8082"
8+
volumes:
9+
- "./config:/config"

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@ module github.com/RoboCup-SSL/ssl-status-board
33
go 1.14
44

55
require (
6+
github.com/gobuffalo/envy v1.9.0 // indirect
67
github.com/gobuffalo/packr v1.30.1
8+
github.com/gobuffalo/packr/v2 v2.8.0 // indirect
79
github.com/gorilla/websocket v1.4.2
10+
github.com/karrick/godirwalk v1.15.6 // indirect
811
github.com/pkg/errors v0.9.1
12+
github.com/rogpeppe/go-internal v1.6.0 // indirect
13+
github.com/sirupsen/logrus v1.6.0 // indirect
14+
github.com/spf13/cobra v1.0.0 // indirect
15+
github.com/spf13/pflag v1.0.5 // indirect
16+
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 // indirect
17+
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 // indirect
18+
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
919
gopkg.in/yaml.v2 v2.2.8
1020
)

go.sum

Lines changed: 151 additions & 0 deletions
Large diffs are not rendered by default.

pkg/board/serverConfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (c *Config) WriteTo(fileName string) (err error) {
6565
}
6666
err = os.MkdirAll(filepath.Dir(fileName), 0755)
6767
if err != nil {
68-
err = errors.Wrapf(err, "Could not create directly for config file: %v", fileName)
68+
err = errors.Wrapf(err, "Could not create directory for config file: %v", fileName)
6969
return
7070
}
7171
err = ioutil.WriteFile(fileName, b, 0600)

src/main.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ if (process.env.NODE_ENV === 'development') {
5959
wsAddress = 'ws://localhost:8082/api/referee';
6060
} else {
6161
// UI and backend are served on the same host+port on production builds
62-
wsAddress = 'ws://' + window.location.hostname + ':' + window.location.port + '/api/referee';
62+
let protocol;
63+
if (window.location.protocol === 'http:') {
64+
protocol = 'ws:'
65+
} else {
66+
protocol = 'wss:'
67+
}
68+
wsAddress = protocol + '//' + window.location.hostname + ':' + window.location.port + '/api/referee';
6369
}
6470

65-
var ws = new WebSocket(wsAddress);
71+
const ws = new WebSocket(wsAddress);
6672
ws.binaryType = "arraybuffer";
6773

6874
// Connect to the backend with a single websocket that communicates with JSON format and is attached to the store

0 commit comments

Comments
 (0)