Skip to content

Commit

Permalink
Fixed various issues
Browse files Browse the repository at this point in the history
  • Loading branch information
LINCKODE committed Jul 15, 2024
1 parent 49a3664 commit 5c42407
Show file tree
Hide file tree
Showing 20 changed files with 199 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ jobs:

- name: 'Build Inventory Image'
run: |
docker build . --tag ghcr.io/qubic/frontend-processor:dev
docker push ghcr.io/qubic/frontend-processor:dev
# Processor
docker build processor --tag ghcr.io/qubic/qubic-stats-processor:dev
docker push ghcr.io/qubic/qubic-stats-processor:dev
# API
docker build api --tag ghcr.io/qubic/qubic-stats-api:dev
docker push ghcr.io/qubic/qubic-stats-api:dev
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ jobs:

- name: 'Build Inventory Image'
run: |
docker build . --tag ghcr.io/qubic/frontend-processor:${{github.ref_name}}
docker push ghcr.io/qubic/frontend-processor:${{github.ref_name}}
# Processor
docker build processor --tag ghcr.io/qubic/qubic-stats-processor:${{github.ref_name}}
docker push ghcr.io/qubic/qubic-stats-processor:${{github.ref_name}}
# API
docker build api --tag ghcr.io/qubic/qubic-stats-api:${{github.ref_name}}
docker push ghcr.io/qubic/qubic-stats-api:${{github.ref_name}}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.idea/

frontend-service-processor
*.qs
*.json
18 changes: 18 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.22 AS builder
ENV CGO_ENABLED=0

WORKDIR /build
COPY .. /build

RUN go build -o "/build/qubic-stats-api"


FROM alpine:latest
COPY --from=builder /build/qubic-stats-api /app/api
RUN chmod +x /app/api

EXPOSE 80

WORKDIR /app

ENTRYPOINT ["./api"]
3 changes: 3 additions & 0 deletions api/buildDocker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

docker build -t qubic-stats-api .
3 changes: 2 additions & 1 deletion api/cache/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func (s *Service) Start() chan bool {

err := s.updateCache(updateSpectrum, true)
if err != nil {
fmt.Printf("Failed to update Cache. Error: %v", err)
fmt.Printf("Failed to update Cache. Error: %v\n", err)
continue
}
println("Done updating.")
}
Expand Down
6 changes: 3 additions & 3 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ func run() error {
}

if err := conf.Parse(os.Args[1:], prefix, &config); err != nil {
switch err {
case conf.ErrHelpWanted:
switch {
case errors.Is(err, conf.ErrHelpWanted):
usage, err := conf.Usage(prefix, &config)
if err != nil {
return errors.Wrap(err, "generating config usage")
}
fmt.Println(usage)
return nil
case conf.ErrVersionWanted:
case errors.Is(err, conf.ErrVersionWanted):
version, err := conf.VersionString(prefix, &config)
if err != nil {
return errors.Wrap(err, "generating config version")
Expand Down
7 changes: 7 additions & 0 deletions buildDev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cd api || exit
sh buildDocker.sh
cd ..

cd processor || exit
sh buildDocker.sh
cd ..
41 changes: 41 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
services:
mongo:
image: mongo
container_name: "mongo-db"
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: user
MONGO_INITDB_ROOT_PASSWORD: pass
networks:
- qubic-stats
ports:
- "27017:27017"

processor:
image: qubic-stats-processor
container_name: "stats-processor"
environment:
QUBIC_STATS_PROCESSOR_MONGO_HOSTNAME: "mongo"
QUBIC_STATS_PROCESSOR_SERVICE_ARCHIVER_GRPC_ADDRESS: "host.docker.internal:8001"
networks:
- qubic-stats
depends_on:
- mongo
extra_hosts:
- "host.docker.internal:host-gateway"

api:
image: qubic-stats-api
container_name: "stats-api"
environment:
QUBIC_STATS_API_MONGO_HOSTNAME: "mongo"
networks:
- qubic-stats
ports:
- "8081:8080"
- "8082:8081"
depends_on:
- mongo

networks:
qubic-stats:
2 changes: 2 additions & 0 deletions processor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
qubic-stats-processor
qubic-stats-processor.exe
4 changes: 2 additions & 2 deletions processor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ ENV CGO_ENABLED=0
WORKDIR /build
COPY .. /build

RUN go build -o "/build/frontend-service-processor"
RUN go build -o "/build/qubic-stats-processor"


FROM alpine:latest
COPY --from=builder /build/frontend-service-processor /app/processor
COPY --from=builder /build/qubic-stats-processor /app/processor
RUN chmod +x /app/processor

EXPOSE 80
Expand Down
32 changes: 0 additions & 32 deletions processor/archiver/types.go

This file was deleted.

2 changes: 1 addition & 1 deletion processor/buildDocker.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

docker build -t frontend-processor .
docker build -t qubic-stats-processor .
35 changes: 0 additions & 35 deletions processor/db/connection.go

This file was deleted.

24 changes: 0 additions & 24 deletions processor/docker-compose.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions processor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,26 @@ go 1.22.4
require (
github.com/ardanlabs/conf v1.5.0
github.com/pkg/errors v0.9.1
github.com/qubic/go-archiver v0.5.0
go.mongodb.org/mongo-driver v1.16.0
google.golang.org/grpc v1.64.0
)

require (
github.com/golang/snappy v0.0.4 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)
16 changes: 16 additions & 0 deletions processor/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
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/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw=
github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/qubic/go-archiver v0.5.0 h1:upbneSV4lUJPQdqFlc+7nLSf68r1Zb0UqmnBueluOt8=
github.com/qubic/go-archiver v0.5.0/go.mod h1:sIiFHG2lIseAV1dF6jHNyY2stV0x6n3aUp6azoubLUY=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
Expand All @@ -32,6 +36,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
Expand All @@ -41,6 +47,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -53,3 +61,11 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4=
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
Loading

0 comments on commit 5c42407

Please sign in to comment.