Skip to content

Commit

Permalink
feat: fdp contracts option (#123)
Browse files Browse the repository at this point in the history
* feat: fdp contracts option

* feat: change blockchain image with fairos option

* fix: fdp-contracts-blockchain naming
  • Loading branch information
nugaon authored Mar 20, 2024
1 parent b148b83 commit 147d41d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ $ fdp-play start -d --bee-version 1.6.1
# This spins up the environment without Bee nodes
$ fdp-play start --without-bees

# Starts the blockchain with FDP Contracts
$ fdp-play start --fdp-contracts

# Or start a fairOS instance that will use the Queen Bee node.
$ fdp-play start --fairos

Expand Down
22 changes: 20 additions & 2 deletions src/command/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { waitForBlockchain, waitForQueen, waitForWorkers } from '../utils/wait'
import ora from 'ora'
import { VerbosityLevel } from './root-command/logging'
import { stripCommit } from '../utils/config-sources'
import { DEFAULT_BLOCKCHAIN_IMAGE, DEFAULT_FAIROS_IMAGE, ENV_ENV_PREFIX_KEY } from '../constants'
import { DEFAULT_BLOCKCHAIN_IMAGE, DEFAULT_FAIROS_IMAGE, ENV_ENV_PREFIX_KEY, FDP_BLOCKCHAIN_IMAGE } from '../constants'

const DEFAULT_BEE_REPO = 'fairdatasociety'
const ENV_IMAGE_PREFIX_KEY = 'FDP_PLAY_IMAGE_PREFIX'
Expand Down Expand Up @@ -78,10 +78,18 @@ export class Start extends RootCommand implements LeafCommand {
type: 'string',
description: 'Docker image name of the used blockchain',
envKey: 'FDP_PLAY_BLOCKCHAIN_IMAGE',
default: DEFAULT_BLOCKCHAIN_IMAGE,
})
public blockchainImageName!: string

@Option({
key: 'fdp-contracts',
type: 'boolean',
description: 'Blockchain includes FDP Contracts',
default: false,
conflicts: 'blockchain-image',
})
public fdpContracts!: boolean

@Option({
key: 'bee-image-prefix',
type: 'string',
Expand Down Expand Up @@ -138,6 +146,8 @@ export class Start extends RootCommand implements LeafCommand {

this.beeVersion = stripCommit(this.beeVersion)

this.setBlockchainImage()

const dockerOptions = this.buildDockerOptions()
const docker = new Docker({
console: this.console,
Expand Down Expand Up @@ -287,6 +297,14 @@ export class Start extends RootCommand implements LeafCommand {
}
}

private setBlockchainImage() {
if (this.fdpContracts || this.fairos) {
this.blockchainImageName = FDP_BLOCKCHAIN_IMAGE
} else {
this.blockchainImageName ||= DEFAULT_BLOCKCHAIN_IMAGE
}
}

private async stopDocker(docker: Docker) {
const dockerSpinner = ora({
text: 'Stopping all containers...',
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/**
* for base image that this project build use "fdp-play-blockchain:1.2.0"
* for base image that this project build use "fdp-play-blockchain"
* it will use the latest tag. on image upgrade, either delete the latest locally or force pull
*/
export const DEFAULT_BLOCKCHAIN_IMAGE = 'fairdatasociety/fdp-play-blockchain'
export const FDP_BLOCKCHAIN_IMAGE = 'fairdatasociety/fdp-contracts-blockchain'
export const DEFAULT_BLOCKCHAIN_CONTAINER = 'fdp-play-blockchain'
export const DEFAULT_FAIROS_IMAGE = 'fairdatasociety/fairos-dfs'
export const ENV_ENV_PREFIX_KEY = 'FDP_PLAY_ENV_PREFIX'
Expand Down

0 comments on commit 147d41d

Please sign in to comment.