Skip to content

Commit

Permalink
Merge branch 'main' into stack-state
Browse files Browse the repository at this point in the history
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
  • Loading branch information
nguyer committed Apr 13, 2022
2 parents b8e0eca + 3f63e26 commit 489b081
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func init() {
initCmd.Flags().StringVarP(&initOptions.ManifestPath, "manifest", "m", "", "Path to a manifest.json file containing the versions of each FireFly microservice to use. Overrides the --release flag.")
initCmd.Flags().BoolVar(&promptNames, "prompt-names", false, "Prompt for org and node names instead of using the defaults")
initCmd.Flags().BoolVar(&initOptions.PrometheusEnabled, "prometheus-enabled", false, "Enables Prometheus metrics exposition and aggregation to a shared Prometheus server")
initCmd.Flags().BoolVar(&initOptions.SandboxEnabled, "sandbox-enabled", true, "Enables the FireFly Sandbox to be started with your FireFly stack")
initCmd.Flags().IntVar(&initOptions.PrometheusPort, "prometheus-port", 9090, "Port for the shared Prometheus server")
initCmd.Flags().StringVarP(&initOptions.ExtraCoreConfigPath, "core-config", "", "", "The path to a yaml file containing extra config for FireFly Core")
initCmd.Flags().StringVarP(&initOptions.ExtraEthconnectConfigPath, "ethconnect-config", "", "", "The path to a yaml file containing extra config for Ethconnect")
Expand Down
3 changes: 3 additions & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ This command will start a stack and run it in the background.
fmt.Print("\n\n")
for _, member := range stackManager.Stack.Members {
fmt.Printf("Web UI for member '%v': http://127.0.0.1:%v/ui\n", member.ID, member.ExposedFireflyPort)
if stackManager.Stack.SandboxEnabled {
fmt.Printf("Sandbox UI for member '%v': http://127.0.0.1:%v\n\n", member.ID, member.ExposedSandboxPort)
}
}

if stackManager.Stack.PrometheusEnabled {
Expand Down
10 changes: 10 additions & 0 deletions internal/docker/docker_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ func CreateDockerCompose(s *types.Stack) *DockerComposeConfig {
Logging: StandardLogOptions,
}
compose.Volumes[fmt.Sprintf("dataexchange_%s", member.ID)] = struct{}{}
if s.SandboxEnabled {
compose.Services["sandbox_"+member.ID] = &Service{
Image: "ghcr.io/hyperledger/firefly-sandbox:latest",
ContainerName: fmt.Sprintf("%s_sandbox_%s", s.Name, member.ID),
Ports: []string{fmt.Sprintf("%d:3001", member.ExposedSandboxPort)},
Environment: map[string]string{
"FF_ENDPOINT": fmt.Sprintf("http://firefly_core_%d:%d", *member.Index, member.ExposedFireflyPort),
},
}
}
}

if s.PrometheusEnabled {
Expand Down
9 changes: 9 additions & 0 deletions internal/stacks/stack_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (s *StackManager) InitStack(stackName string, memberCount int, options *typ
DeployedContracts: make([]*types.DeployedContract, 0),
Accounts: make([]interface{}, memberCount),
},
SandboxEnabled: options.SandboxEnabled,
}

if options.PrometheusEnabled {
Expand Down Expand Up @@ -479,6 +480,10 @@ func createMember(id string, index int, options *types.InitOptions, external boo
case types.HyperledgerFabric:
// This will be filled in by the Fabric blockchain provider
}
if options.SandboxEnabled {
member.ExposedSandboxPort = nextPort
nextPort++
}
return member
}

Expand Down Expand Up @@ -646,6 +651,10 @@ func (s *StackManager) checkPortsAvailable() error {
ports = append(ports, member.ExposedDatabasePort)
ports = append(ports, member.ExposedUIPort)
ports = append(ports, member.ExposedTokensPorts...)

if s.Stack.SandboxEnabled {
ports = append(ports, member.ExposedSandboxPort)
}
}

if s.Stack.PrometheusEnabled {
Expand Down
1 change: 1 addition & 0 deletions pkg/types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type InitOptions struct {
ManifestPath string
PrometheusEnabled bool
PrometheusPort int
SandboxEnabled bool
ExtraCoreConfigPath string
ExtraEthconnectConfigPath string
BlockPeriod int
Expand Down
4 changes: 3 additions & 1 deletion pkg/types/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Stack struct {
TokenProviders TokenProviders `json:"tokenProviders"`
VersionManifest *VersionManifest `json:"versionManifest,omitempty"`
PrometheusEnabled bool `json:"prometheusEnabled,omitempty"`
SandboxEnabled bool `json:"sandboxEnabled,omitempty"`
ExposedPrometheusPort int `json:"exposedPrometheusPort,omitempty"`
ContractAddress string `json:"contractAddress,omitempty"`
InitDir string `json:"-"`
Expand All @@ -42,11 +43,12 @@ type Member struct {
ExposedFireflyAdminPort int `json:"exposedFireflyAdminPort,omitempty"`
ExposedFireflyMetricsPort int `json:"exposedFireflyMetricsPort,omitempty"`
ExposedConnectorPort int `json:"exposedConnectorPort,omitempty"`
ExposedDatabasePort int `json:"exposedDatabasePort,omitempty"`
ExposedDatabasePort int `json:"exposedPostgresPort,omitempty"`
ExposedDataexchangePort int `json:"exposedDataexchangePort,omitempty"`
ExposedIPFSApiPort int `json:"exposedIPFSApiPort,omitempty"`
ExposedIPFSGWPort int `json:"exposedIPFSGWPort,omitempty"`
ExposedUIPort int `json:"exposedUiPort,omitempty"`
ExposedSandboxPort int `json:"exposedSandboxPort,omitempty"`
ExposedTokensPorts []int `json:"exposedTokensPorts,omitempty"`
External bool `json:"external,omitempty"`
OrgName string `json:"orgName,omitempty"`
Expand Down

0 comments on commit 489b081

Please sign in to comment.