Skip to content

Commit a19cd64

Browse files
committed
Create state store in a data dir for easier docker volume handling
1 parent 8f02d93 commit a19cd64

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
node_modules
33
/dist
4+
/data
45

56
# Editor directories and files
67
.idea/*

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN GOOS=linux GOARCH=amd64 packr build -o ../../release/ssl-game-controller_lin
1717
FROM alpine:3.9
1818
COPY --from=build_go /go/src/github.com/RoboCup-SSL/ssl-game-controller/release/ssl-game-controller_linux_amd64 /app/ssl-game-controller
1919
COPY config config
20-
WORKDIR /work
20+
RUN mkdir data
2121
EXPOSE 8081 10007 10008 10011 10009
2222
ENTRYPOINT ["/app/ssl-game-controller", "-address", ":8081"]
2323
CMD []

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ You can also use pre-build docker images:
2020
docker pull robocupssl/ssl-game-controller
2121
# Run GC with default configuration
2222
docker run -p 8081:8081 robocupssl/ssl-game-controller
23-
# You can also mount the config and work directories locally
23+
# Mount local directories
2424
docker run -p 8081:8081 \
2525
# Local config dir
2626
-v "$(pwd)"/config:/config \
27-
# Local working dir with the current state
28-
-v "$(pwd)"/work:/work \
27+
# Local data dir (current state)
28+
-v "$(pwd)"/data:/data \
2929
robocupssl/ssl-game-controller
3030
```
3131

config/ssl-game-controller.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ server:
2222
engine:
2323
config-filename: config/engine.yaml
2424
game:
25-
state-store-file: state-store.json.stream
25+
state-store-file: data/state-store.json.stream
2626
yellow-card-duration: 2m
2727
yellow-card-bot-removal-time: 10s
2828
multiple-card-step: 2

internal/app/store/store.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ func (s *Store) LatestEntry() *statemachine.StateChange {
5151

5252
// Open opens the store file
5353
func (s *Store) Open() error {
54+
err := os.MkdirAll(filepath.Dir(s.filename), 0755)
55+
if err != nil {
56+
return errors.Wrapf(err, "Could not create directory for store file: %v", s.filename)
57+
}
5458
f, err := os.OpenFile(s.filename, os.O_RDWR|os.O_CREATE, 0600)
5559
if err != nil {
5660
return err

0 commit comments

Comments
 (0)