Skip to content

Commit

Permalink
Merge pull request #14 from bloock/feature/EIT-3752
Browse files Browse the repository at this point in the history
  • Loading branch information
edutomesco committed May 14, 2024
2 parents b0c83cd + b8fed86 commit 75d2f6f
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 79 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:
- name: Set up go
uses: actions/setup-go@v3
with:
go-version: 1.20.0
go-version: 1.21.0
- name: Setup
run: |
go install github.com/golang/mock/mockgen@v1.6.0
go install entgo.io/ent/cmd/ent@v0.12.4
go install entgo.io/ent/cmd/ent@v0.13.1
make cache
make mocks
- name: Run tests
Expand Down
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ RUN CGO_ENABLED=1 go build -buildvcs=false -o /go/bin/managed-api cmd/main.go

FROM debian:buster-slim

RUN apt-get update && apt-get install -y ca-certificates
RUN apt-get update && \
apt-get install -y ca-certificates sudo && \
adduser --disabled-password nonroot && \
echo 'nonroot ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers \
RUN update-ca-certificates

WORKDIR /app
COPY --from=builder /go/bin/managed-api /app/managed-api
COPY --from=builder /go/bin/static /app/static
USER nonroot

ENTRYPOINT ["/app/managed-api"]
WORKDIR /home/nonroot/app
COPY --from=builder --chown=nonroot:nonroot /go/bin/managed-api /home/nonroot/app/managed-api
COPY --from=builder --chown=nonroot:nonroot /go/bin/static /home/nonroot/app/static

RUN chmod -R 755 /home/nonroot/app

ENTRYPOINT ["/home/nonroot/app/managed-api"]
9 changes: 4 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ import (
"github.com/bloock/bloock-managed-api/internal/platform/cron"
"github.com/bloock/bloock-managed-api/internal/platform/repository/sql/connection"
"github.com/bloock/bloock-managed-api/internal/platform/worker"
"os"
"github.com/bloock/bloock-managed-api/pkg"
"sync"

"github.com/bloock/bloock-managed-api/internal/config"
"github.com/bloock/bloock-managed-api/internal/platform/rest"
"github.com/rs/zerolog"
)

func main() {
logger := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).With().Timestamp().Logger()

_, err := config.InitConfig(logger)
_, err := config.InitConfig()
if err != nil {
panic(err)
}

logger := pkg.InitLogger(config.Configuration.Api.DebugMode)

wg := sync.WaitGroup{}
wg.Add(1)

Expand Down
4 changes: 2 additions & 2 deletions docker-compose-mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ services:
image: bloock/managed-api:latest
container_name: bloock-managed-api
volumes:
- ./config.yaml:/app/config.yaml:ro
- ./data:/app/data
- ./config.yaml:/home/nonroot/app/config.yaml:ro
- ./data:/home/nonroot/app/data
ports:
- 8080:8080
depends_on:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ services:
image: bloock/managed-api:latest
container_name: bloock-managed-api
volumes:
- ./config.yaml:/app/config.yaml:ro
- ./data:/app/data
- ./config.yaml:/home/nonroot/app/config.yaml:ro
- ./data:/home/nonroot/app/data
ports:
- 8080:8080
depends_on:
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
services:
bloock-managed-api:
image: bloock/managed-api:latest
platform: linux/amd64
container_name: bloock-managed-api
volumes:
- ./config.yaml:/app/config.yaml:ro
- ./data:/app/data
- ./config.yaml:/home/nonroot/app/config.yaml:ro
- ./data:/home/nonroot/app/data
ports:
- 8080:8080
environment:
Expand Down
31 changes: 18 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
module github.com/bloock/bloock-managed-api

go 1.20
go 1.21

require (
entgo.io/ent v0.12.4
github.com/bloock/bloock-sdk-go/v2 v2.8.7
github.com/bloock/bloock-sdk-go/v2 v2.8.9
github.com/cenkalti/backoff/v4 v4.2.1
github.com/gin-contrib/logger v0.2.6
github.com/gin-gonic/gin v1.9.1
github.com/go-co-op/gocron v1.37.0
github.com/go-pdf/fpdf v0.9.0
github.com/go-sql-driver/mysql v1.7.1
github.com/golang/mock v1.6.0
github.com/google/uuid v1.4.0
github.com/jackc/pgx/v5 v5.5.3
github.com/google/uuid v1.6.0
github.com/jackc/pgx/v5 v5.5.5
github.com/mattn/go-sqlite3 v1.14.16
github.com/mcuadros/go-defaults v1.2.0
github.com/prometheus/client_golang v1.19.1
github.com/rs/zerolog v1.29.1
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
github.com/txaty/go-merkletree v0.1.15
golang.org/x/crypto v0.17.0
golang.org/x/crypto v0.19.0
)

require (
ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935 // indirect
github.com/agext/levenshtein v1.2.1 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.9.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
Expand All @@ -38,8 +41,7 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.13.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
Expand All @@ -57,6 +59,9 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
Expand All @@ -70,13 +75,13 @@ require (
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/arch v0.4.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.55.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 75d2f6f

Please sign in to comment.