Skip to content

Commit 1e38ddc

Browse files
committed
chore: add Dockerfile with updating go modules
1 parent 44c03b8 commit 1e38ddc

File tree

5 files changed

+112
-6
lines changed

5 files changed

+112
-6
lines changed

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM golang:1.25-alpine AS build
2+
3+
LABEL maintainer="Iori Mizutani <iori.mizutani@gmail.com>"
4+
5+
# build the app
6+
RUN mkdir -p /build
7+
WORKDIR /build
8+
COPY go.mod .
9+
COPY go.sum .
10+
COPY api api
11+
COPY cmd cmd
12+
COPY config config
13+
COPY connection connection
14+
COPY server server
15+
COPY tag tag
16+
RUN go mod vendor
17+
RUN CGO_ENABLED=0 GOOS=linux go build -mod=vendor -o golemu ./cmd/golemu/...
18+
19+
# export to a single layer image
20+
FROM alpine:latest
21+
22+
# install some required binaries
23+
RUN apk add --no-cache ca-certificates \
24+
ffmpeg \
25+
tzdata
26+
27+
WORKDIR /app
28+
29+
COPY --from=build /build/golemu /app/golemu
30+
31+
# set timezone
32+
ENV TZ "Asia/Tokyo"
33+
34+
ENTRYPOINT ["/app/golemu"]

README.md

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ go install ./cmd/golemu
3535
golemu --help
3636
```
3737

38-
**Note:** Make sure `$GOPATH/bin` or `$HOME/go/bin` is in your `PATH` environment variable to use the `golemu` command directly.
38+
**Note:** Make sure `$GOBIN`, `$GOPATH/bin` or `$HOME/go/bin` is in your `PATH` environment variable to use the `golemu` command directly. When `$GOBIN` is set, go installs `golemu` there.
3939

4040
## Build Locally
4141

@@ -57,12 +57,58 @@ golemu has 3 commands (`client`, `server`, and `simulator`) to operate in differ
5757

5858
## LLRP client mode(`golemu client`)
5959

60+
```console
61+
% golemu client --help
62+
usage: golemu client
63+
64+
Run as an LLRP client; connect to an LLRP server and receive events (test-only).
65+
66+
Flags:
67+
--help Show context-sensitive help (also try --help-long
68+
and --help-man).
69+
-v, --debug Enable debug mode.
70+
--initialMessageID=1000 The initial messageID to start from.
71+
--initialKeepaliveID=80000
72+
The initial keepaliveID to start from.
73+
-a, --ip=0.0.0.0 LLRP listening address.
74+
-k, --keepalive=0 LLRP Keepalive interval.
75+
-p, --port=5084 LLRP listening port.
76+
-m, --pdu=1500 The maximum size of LLRP PDU.
77+
-i, --reportInterval=10000 The interval of ROAccessReport in ms. Pseudo
78+
ROReport spec option.
79+
--version Show application version.
80+
```
81+
6082
The client mode establishes an LLRP connection with an LLRP server (interrogator). Retry connecting to the server until it becomes online and keep receiving the events until the server closes the connection.
6183

6284
This command is test-only; which means it only displays the number of events (TAG REPORT DATA parameter) in each received RO ACCESS REPORT message.
6385

6486
## LLRP server mode(`golemu server`)
6587

88+
```console
89+
% golemu server --help
90+
usage: golemu server [<flags>]
91+
92+
Run as an LLRP tag stream server.
93+
94+
Flags:
95+
--help Show context-sensitive help (also try --help-long
96+
and --help-man).
97+
-v, --debug Enable debug mode.
98+
--initialMessageID=1000 The initial messageID to start from.
99+
--initialKeepaliveID=80000
100+
The initial keepaliveID to start from.
101+
-a, --ip=0.0.0.0 LLRP listening address.
102+
-k, --keepalive=0 LLRP Keepalive interval.
103+
-p, --port=5084 LLRP listening port.
104+
-m, --pdu=1500 The maximum size of LLRP PDU.
105+
-i, --reportInterval=10000 The interval of ROAccessReport in ms. Pseudo
106+
ROReport spec option.
107+
--version Show application version.
108+
--apiPort=3000 The port for the API endpoint.
109+
-f, --file="tags.gob" The file containing Tag data.
110+
```
111+
66112
The server mode first loads tags from a file (`tags.gob` by default) to produce a "virtual inventory of tags." The gob encoded file speeds up the loading process of tags since it is critical for the emulation of hundreds to thousands of tags.
67113

68114
Follow the steps below to generate a gob file; however, this is at the moment _very ugly_ and as golemu and [go-llrp](https://github.com/iomz/go-llrp) only takes PC bits and EPC data parameter to represent a tag. I may come up with another way or format to load up tags to golemu in the future.
@@ -101,6 +147,31 @@ The resulting gob file of the above example (just 1 SGTIN-96 tag) should look li
101147

102148
## Interrogation simulator mode(`golemu simulator`):
103149

150+
```console
151+
% golemu simulator --help
152+
usage: golemu simulator <simulationDir>
153+
154+
Run in the simulator mode.
155+
156+
Flags:
157+
--help Show context-sensitive help (also try --help-long
158+
and --help-man).
159+
-v, --debug Enable debug mode.
160+
--initialMessageID=1000 The initial messageID to start from.
161+
--initialKeepaliveID=80000
162+
The initial keepaliveID to start from.
163+
-a, --ip=0.0.0.0 LLRP listening address.
164+
-k, --keepalive=0 LLRP Keepalive interval.
165+
-p, --port=5084 LLRP listening port.
166+
-m, --pdu=1500 The maximum size of LLRP PDU.
167+
-i, --reportInterval=10000 The interval of ROAccessReport in ms. Pseudo
168+
ROReport spec option.
169+
--version Show application version.
170+
171+
Args:
172+
<simulationDir> The directory contains tags for each event cycle.
173+
```
174+
104175
The simulator mode also operates as an LLRP server (RFID interrogator) – the only difference is that it iterates through generated gob files in a directory. This mode is intended to simulate a batch of event cycles designed to evaluate specific situations.
105176

106177
One gob file for one event cycle. golemu iterates the file by the file names in ascending order. Suppose there are 3 files (`00.gob`, `01.gob`, and `02.gob` for example) in `/path/to/sim`,

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
var (
1414
// Version is the current version
15-
Version = "0.2.0"
15+
Version = "0.5.1"
1616

1717
// App is the kingpin application
1818
App = kingpin.New("golemu", "A mock LLRP-based logical reader emulator for RFID Tags.")

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.2
55
require (
66
github.com/fatih/structs v1.1.0
77
github.com/gin-gonic/gin v1.3.0
8-
github.com/iomz/go-llrp v0.0.0-20190410202645-2a695d402856
8+
github.com/iomz/go-llrp v0.1.0
99
github.com/sirupsen/logrus v1.4.1
1010
gopkg.in/alecthomas/kingpin.v2 v2.2.6
1111
)

go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ github.com/gin-gonic/gin v1.3.0 h1:kCmZyPklC0gVdL728E6Aj20uYBJV93nj/TkwBTKhFbs=
1212
github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y=
1313
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
1414
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
15-
github.com/iomz/go-llrp v0.0.0-20190410202645-2a695d402856 h1:GwX9fkbNdaa/tqMn0whUA+3lSH8aW29hzwpr7XlMFgk=
16-
github.com/iomz/go-llrp v0.0.0-20190410202645-2a695d402856/go.mod h1:EjdwFHjQgCf9pFwZeg9rNu4MLb5bQ9ZW02ZXBDcOiag=
15+
github.com/iomz/go-llrp v0.1.0 h1:YShbjFJ5uYNkAuIu2fZH93e/zR6IqEEBHMitZqvuMWw=
16+
github.com/iomz/go-llrp v0.1.0/go.mod h1:OvPX5QaELjVbp80tpZk1rrW0l6hUDT5CvkpCQ7bXkCk=
1717
github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs=
1818
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
1919
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
@@ -30,8 +30,9 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
3030
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
3131
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
3232
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
33-
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
3433
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
34+
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
35+
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
3536
github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=
3637
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
3738
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

0 commit comments

Comments
 (0)