Skip to content

Commit

Permalink
Goとライブラリの更新、gopherjsからwasmに変更 (#91)
Browse files Browse the repository at this point in the history
Goのprotobufを更新したらgopherjs(go v1.19)ではビルドできなくなってしまいました。
gopherjsの更新が遅いことと、Go本体がwasmをサポートし始めたことから、gopherjsの部分をwasmに置き換えてみました。
  • Loading branch information
makiuchi-d authored Dec 25, 2024
2 parents 3b56972 + cc62e5b commit c292844
Show file tree
Hide file tree
Showing 39 changed files with 1,625 additions and 6,356 deletions.
27 changes: 6 additions & 21 deletions .github/workflows/wsnet2-dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,24 @@ on:
- 'server/**'

jobs:
C:
runs-on: "ubuntu-latest"
outputs:
GO: "go1.19.13"
GOPHERJS_VER: "v1.19.0-beta1"
steps:
- run: echo 'Set Constants'

gopherjs:
needs: [ C ]
go-wasm:
runs-on: "ubuntu-latest"
defaults:
run:
working-directory: wsnet2-dashboard/backend/go-binary
working-directory: wsnet2-dashboard/backend
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-version-file: "server/go.mod"
go-version-file: "wsnet2-dashboard/backend/go-binary/go.mod"
cache: true
cache-dependency-path: "server/go.sum"
cache-dependency-path: "wsnet2-dashboard/backend/go-binary/go.sum"

- uses: arduino/setup-protoc@v2
with:
version: '24.x'

- run: make -C ../../../server generate

- run: go install golang.org/dl/${{ needs.C.outputs.GO }}@latest && ${{ needs.C.outputs.GO }} download

- run: cd ../../../server && GOARCH=386 go test ./binary

- run: go install github.com/gopherjs/gopherjs@${{ needs.C.outputs.GOPHERJS_VER }}
- run: make -C ../../server generate

- run: GOPHERJS_GOROOT="$(${{ needs.C.outputs.GO }} env GOROOT)" gopherjs build
- run: make src/plugins/binary.wasm
4 changes: 2 additions & 2 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.22
FROM golang:1.23

ARG protoc_ver="24.2"
ARG protoc_ver="29.2"

RUN apt-get update && apt-get install -y unzip && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
Expand Down
6 changes: 3 additions & 3 deletions server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ test: generate

install-deps:
go install google.golang.org/protobuf/cmd/protoc-gen-go
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1
go install github.com/favadi/protoc-go-inject-tag@v1.4.0
go install golang.org/x/tools/cmd/stringer@v0.18.0
go install honnef.co/go/tools/cmd/staticcheck@v0.4.7
go install golang.org/x/tools/cmd/stringer@v0.28.0
go install honnef.co/go/tools/cmd/staticcheck@v0.5.1

build: $(TARGETS)

Expand Down
2 changes: 1 addition & 1 deletion server/cmd/wsnet2-tool/cmd/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func selectGrpcServers(ctx context.Context, ids []string) (map[string]*grpcServe
}

func (s *grpcServer) Dial() (*grpc.ClientConn, error) {
return grpc.Dial(fmt.Sprintf("%s:%d", s.Host, s.Port),
return grpc.NewClient(fmt.Sprintf("%s:%d", s.Host, s.Port),
grpc.WithTransportCredentials(insecure.NewCredentials()))
}

Expand Down
2 changes: 1 addition & 1 deletion server/common/grpcpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (p *GrpcPool) Get(target string) (*grpc.ClientConn, error) {
return cc, nil
}

cc, err := grpc.Dial(target, p.opts...)
cc, err := grpc.NewClient(target, p.opts...)
if err != nil {
return nil, err
}
Expand Down
24 changes: 12 additions & 12 deletions server/go.mod
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
module wsnet2

go 1.22.0
go 1.23.0

require (
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/go-sql-driver/mysql v1.7.1
github.com/go-sql-driver/mysql v1.8.1
github.com/google/go-cmp v0.6.0
github.com/jmoiron/sqlx v1.3.5
github.com/jmoiron/sqlx v1.4.0
github.com/pelletier/go-toml v1.9.5
github.com/shiguredo/websocket v1.6.1
github.com/spf13/cobra v1.8.0
github.com/spf13/cobra v1.8.1
github.com/vmihailenco/msgpack/v5 v5.4.1
go.uber.org/zap v1.27.0
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028
google.golang.org/grpc v1.62.0
google.golang.org/protobuf v1.32.0
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da
google.golang.org/grpc v1.69.2
google.golang.org/protobuf v1.36.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

require (
github.com/golang/protobuf v1.5.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219192143-6b3ec007d9bb // indirect
)
78 changes: 45 additions & 33 deletions server/go.sum
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g=
github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE=
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shiguredo/websocket v1.6.1 h1:xGZ5LmGjQLfGaCcxZrI2/z0en24eJ3VunnNK1RmJdzg=
github.com/shiguredo/websocket v1.6.1/go.mod h1:qUnxxJOWcK8Q7Q+o31UucO9HJQuhcygUYMuLRa88XTw=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
Expand All @@ -38,29 +43,36 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE=
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY=
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0=
go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc=
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8=
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys=
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c h1:NUsgEN92SQQqzfA+YtqYNqYmB3DMMYLlIwUZAQFVFbo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk=
google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219192143-6b3ec007d9bb h1:3oy2tynMOP1QbTC0MsNNAV+Se8M2Bd0A5+x1QHyw+pI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219192143-6b3ec007d9bb/go.mod h1:lcTa1sDdWEIHMWlITnIczmw5w60CF9ffkb8Z+DVmmjA=
google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU=
google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ=
google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
Expand Down
4 changes: 2 additions & 2 deletions wsnet2-dashboard/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/prisma
/src/pb
/src/plugins/binary.js
/src/plugins/binary.js.map
/node_modules
/src/plugins/binary.wasm
/src/plugins/wasm_exec.js
/.docker_node_modules
/dist
16 changes: 5 additions & 11 deletions wsnet2-dashboard/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
FROM node:18.18.2-bullseye-slim
FROM node:22.12.0-bookworm-slim

RUN apt-get update && apt-get install -y wget make unzip && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
wget -O /wait-for-it.sh https://github.com/vishnubob/wait-for-it/raw/master/wait-for-it.sh > /dev/null 2>&1 && \
chmod +x /wait-for-it.sh

ARG go_ver="1.22.0"
ARG gopherjs_ver="v1.19.0-beta1"
ARG gopherjs_go="go1.19.13"
ARG protoc_ver="24.2"
ARG go_ver="1.23.4"
ARG protoc_ver="29.2"

ENV PATH=/root/go/bin:/go/bin:$PATH
ENV GOPHERJS_GOROOT=/root/sdk/${gopherjs_go}

RUN cd / && \
wget -O go.tar.gz https://go.dev/dl/go${go_ver}.linux-$([ $(uname -m) = aarch64 ] && echo -n arm64 || echo -n amd64).tar.gz && \
tar xvf go.tar.gz && \
wget -q -O go.tar.gz https://go.dev/dl/go${go_ver}.linux-$([ $(uname -m) = aarch64 ] && echo -n arm64 || echo -n amd64).tar.gz && \
tar xf go.tar.gz && \
rm go.tar.gz && \
go install github.com/makiuchi-d/arelo@latest && \
go install github.com/gopherjs/gopherjs@${gopherjs_ver} && \
go install golang.org/dl/${gopherjs_go}@latest && \
$gopherjs_go download && \
wget -O protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v${protoc_ver}/protoc-${protoc_ver}-linux-$(if [ $(uname -m) = "aarch64" ]; then echo aarch_64; else echo x86_64; fi).zip && \
unzip -o protoc.zip "bin/*" "include/*" -d /usr/local && \
rm protoc.zip
Expand Down
26 changes: 15 additions & 11 deletions wsnet2-dashboard/backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ include .env

target := dist/index.js
src.ts := $(wildcard src/*.ts src/*/*.ts src/*/*/*.ts)
plugins := src/plugins/binary.wasm src/plugins/binary.js src/plugins/binary.d.ts src/plugins/wasm_exec.js

PROTO_DST := ./src/pb
PROTO_SRC := ../../server/pb
NODE_PROTOC := npx grpc_tools_node_protoc
PROTOC_GEN_TS := node_modules/.bin/protoc-gen-ts
NODE_PROTOC := protoc
PROTOC_GEN_TS := node_modules/.bin/protoc-gen-es

proto := $(wildcard $(PROTO_SRC)/*.proto)
pb.js := $(proto:$(PROTO_SRC)%.proto=$(PROTO_DST)%_pb.js)
pb.ts := $(proto:$(PROTO_SRC)%.proto=$(PROTO_DST)%_pb.ts)
pb.go := $(proto:%.proto=%.pb.go)

.PHONY: build re-build run re-run clean install-deps
Expand All @@ -33,11 +34,15 @@ install-deps:
npm install
chmod +x node_modules/nexus-prisma/dist-cjs/cli/nexus-prisma.js

$(target): prisma/schema.prisma $(pb.js) $(src.ts) .env src/plugins/binary.js
$(target): prisma/schema.prisma $(pb.ts) $(src.ts) .env $(plugins)
npx tsc
cp src/plugins/binary.wasm dist/plugins/binary.wasm

src/plugins/binary.js: ../../server/binary/*.go go-binary/* $(pb.go)
cd go-binary && gopherjs build -o ../$@
src/plugins/binary.wasm: ../../server/binary/*.go go-binary/* $(pb.go)
cd go-binary && GOOS=js GOARCH=wasm go build -o ../$@

src/plugins/wasm_exec.js:
cp "$(shell go env GOROOT)/misc/wasm/wasm_exec.js" $@

%.pb.go: %.proto
$(MAKE) -C ../../server generate
Expand All @@ -50,11 +55,10 @@ prisma/schema.prisma: $(wildcard ../../server/sql/trigger.d/db.trigger)
fi
npm run generate

$(pb.js): $(proto)
$(pb.ts): $(proto)
mkdir -p ./src/pb
$(NODE_PROTOC) \
--plugin=protoc-gen-ts="$(PROTOC_GEN_TS)" \
--js_out="import_style=commonjs,binary:$(PROTO_DST)" \
--grpc_out="grpc_js:$(PROTO_DST)" \
--ts_out="service=grpc-node,mode=grpc-js:$(PROTO_DST)" \
--plugin=protoc-gen-es="$(PROTOC_GEN_TS)" \
--es_out="$(PROTO_DST)" \
--es_opt="target=ts,import_extension=js" \
-I $(PROTO_SRC) $(proto)
22 changes: 9 additions & 13 deletions wsnet2-dashboard/backend/go-binary/go.mod
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
module wsnet2-dashboard/binary

go 1.19
go 1.23.0

require (
github.com/gopherjs/gopherjs v1.19.0-beta1
wsnet2 v0.0.0
)
require wsnet2 v0.0.0

require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
google.golang.org/grpc v1.62.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219192143-6b3ec007d9bb // indirect
google.golang.org/grpc v1.69.2 // indirect
google.golang.org/protobuf v1.36.0 // indirect
)

replace wsnet2 => ../../../server
Loading

0 comments on commit c292844

Please sign in to comment.