Skip to content

Commit

Permalink
Updates to support running in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
galt-tr committed Dec 19, 2023
1 parent 16e27bd commit b29262f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ RUN CGO_ENABLED=1 go build -a -o $APP_ROOT/src/alert-system github.com/bitcoin-s
# Copy the controller-manager into a thin image
FROM registry.access.redhat.com/ubi9-minimal
WORKDIR /
RUN mkdir /.bitcoin
RUN touch /.bitcoin/alert_system_private_key
COPY --from=builder /opt/app-root/src/alert-system .
COPY example_settings_local.conf settings_local.conf
USER 65534:65534
CMD ["/alert-system"]
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ $ cp example_settings_local.conf settings_local.conf
$ go run cmd/main.go
```

TODO: Running with docker:
### Running with docker:
```
$ touch <db_file>
$ docker run -u root -e P2P_ALERT_SYSTEM_PROTOCOL_ID=/bitcoin/alert-system/0.0.1 -e P2P_BOOTSTRAP_PEER=/ip4/68.183.57.231/tcp/9906/p2p/12D3KooWQs6ptKvoKNHurCzqRaVp3uFs9731NQwS3AmVcNc2TGpb -e P2P_PORT=9906 -e P2P_IP=0.0.0.0 -v <database_file>:/alert_system_datastore.db docker.io/galtbv/alert-system:0.0.1
```

### Running with Podman
```
$ touch <db_file>
$ podman run -u root -e P2P_ALERT_SYSTEM_PROTOCOL_ID=/bitcoin/alert-system/0.0.1 -e P2P_BOOTSTRAP_PEER=/ip4/68.183.57.231/tcp/9906/p2p/12D3KooWQs6ptKvoKNHurCzqRaVp3uFs9731NQwS3AmVcNc2TGpb -e P2P_PORT=9906 -e P2P_IP=0.0.0.0 -v /git/alert-system/foo.db:/alert_system_datastore.db:Z docker.io/galtbv/alert-system:0.0.1
```
11 changes: 8 additions & 3 deletions app/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ import (
// LoadConfig will load the configuration and services
// models is a list of models to auto-migrate when the datastore is created
func LoadConfig(ctx context.Context, models []interface{}, isTesting bool) (_appConfig *Config, err error) {
var ok bool

dbPath := ""

Check failure on line 20 in app/config/load.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, ubuntu-latest)

assigned to dbPath, but reassigned without using the value (wastedassign)
// Load the database path
if dbPath, ok = gocore.Config().Get("ALERT_SYSTEM_DATABASE_PATH"); !ok {
dbPath = DatabasePathDefault
}

// Sync the configuration struct
_appConfig = &Config{
Expand All @@ -33,7 +40,7 @@ func LoadConfig(ctx context.Context, models []interface{}, isTesting bool) (_app
TablePrefix: DatabasePrefix,
},
Shared: false,
DatabasePath: DatabasePathDefault,
DatabasePath: dbPath,
},
},
WebServer: &WebServerConfig{
Expand All @@ -49,8 +56,6 @@ func LoadConfig(ctx context.Context, models []interface{}, isTesting bool) (_app
Logger: gocore.Log(ApplicationName),
}

var ok bool

// Load the RPC user
if _appConfig.RPCUser, ok = gocore.Config().Get("RPC_USER"); !ok {
return nil, ErrNoRPCUser
Expand Down
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main

import (
"context"
"log"
"os"
"os/signal"

Expand All @@ -19,7 +20,7 @@ func main() {
// Load the configuration and services
_appConfig, err := config.LoadConfig(context.Background(), models.BaseModels, false)
if err != nil {
_appConfig.Services.Log.Fatalf("error loading configuration: %s", err.Error())
log.Fatalf("error loading configuration: %s", err.Error())
}
defer func() {
_appConfig.CloseAll(context.Background())
Expand Down

0 comments on commit b29262f

Please sign in to comment.