Skip to content

Commit

Permalink
🌱 Add Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
nagdahimanshu committed Jun 18, 2024
1 parent f27d875 commit ec58713
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 11 deletions.
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

APP_NAME = lsk-faucet
PKGS=$(shell go list ./... | grep -v "/vendor/")
BLUE = \033[1;34m
GREEN = \033[1;32m
COLOR_END = \033[0;39m

build: build-backend build-frontend

build-backend: # Builds the application and create a binary at ./bin/
@echo "$(BLUE)» Building $(APP_NAME) application binary... $(COLOR_END)"
@go build -a -o bin/$(APP_NAME) .
@echo "$(GREEN) Binary successfully built$(COLOR_END)"

build-frontend: # Builds the frontned application
@echo "$(BLUE)» Building frontend... $(COLOR_END)"
@go generate
@echo "$(GREEN) Frontend successfully built$(COLOR_END)"

run: # Runs the application, use `make run FLAGS="--help"`
@./bin/${APP_NAME} ${FLAGS}

.PHONY: test
test: # Runs tests
@echo "Test packages"
@go test -race -shuffle=on -coverprofile=coverage.out -cover $(PKGS)

lint: # Runs golangci-lint on the repo
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run

format: # Runs gofmt on the repo
gofmt -s -w .

.PHONY: docker-build
build-image: # Builds docker image
@echo "$(BLUE) Building docker image...$(COLOR_END)"
@docker build -t $(APP_NAME) .

.PHONY: docker-run
docker-start: # Runs docker image
@echo "$(BLUE) Starting docker container $(APP_NAME)...$(COLOR_END)"
ifdef PRIVATE_KEY
@docker run --name $(APP_NAME) -p 8080:8080 -d -e WEB3_PROVIDER=$(WEB3_PROVIDER) -e PRIVATE_KEY=$(PRIVATE_KEY) $(APP_NAME)
else ifdef KEYSTORE
@docker run --name $(APP_NAME) -p 8080:8080 -d -e WEB3_PROVIDER=$(WEB3_PROVIDER) -e KEYSTORE=$(KEYSTORE) -v $(KEYSTORE)/keystore:/app/keystore -v $(KEYSTORE)/password.txt:/app/password.txt $(APP_NAME)
endif

docker-stop:
@echo "$(BLUE) Stopping and removing docker container $(APP_NAME)...$(COLOR_END)"
@docker rm -f $(APP_NAME)

.PHONY: help
help: # Show help for each of the Makefile recipes
@grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "$(GREEN)$$(echo $$l | cut -f 1 -d':')$(COLOR_END):$$(echo $$l | cut -f 2- -d'#')\n"; done
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,30 @@ cd lsk-faucet
```

2. Bundle Frontend web with Vite
Please make sure to replace token icon at `web/public/token.png` with the specific ERC20 token icon.

**NOTE**: Please make sure to replace token icon at `web/public/token.png` with the specific ERC20 token icon.

```bash
go generate
make build-frontend
```

1. Build Go project
3. Build Go project
```bash
go build -o lsk-faucet
make build-backend
```

## Usage

**Use private key to fund users**

```bash
./lsk-faucet -httpport 8080 -wallet.provider http://localhost:8545 -wallet.privkey privkey
make run FLAGS="-httpport 8080 -wallet.provider http://localhost:8545 -wallet.privkey privkey"
```

**Use keystore to fund users**

```bash
./lsk-faucet -httpport 8080 -wallet.provider http://localhost:8545 -wallet.keyjson keystore -wallet.keypass password.txt
make run FLAGS="-httpport 8080 -wallet.provider http://localhost:8545 -wallet.keyjson keystore -wallet.keypass password.txt"
```

### Configuration
Expand All @@ -81,7 +82,7 @@ echo "your keystore password" > `pwd`/password.txt

Then run the faucet application without the wallet command-line flags:
```bash
./lsk-faucet -httpport 8080
make run FLAGS="-httpport 8080"
```

**Optional Flags**
Expand All @@ -104,23 +105,22 @@ The following are the available command-line flags(excluding above wallet flags)
#### Build docker image
Run the following command to build docker image:
```bash
docker build -t liskhq/lsk-faucet .
make build
```


#### Run faucet
Run the following command to start the application:

```bash
docker run -d -p 8080:8080 -e WEB3_PROVIDER=<rpc-endpoint> -e PRIVATE_KEY=<hex-private-key> liskhq/lsk-faucet
make docker-start WEB3_PROVIDER=<rpc-endpoint> PRIVATE_KEY=<hex-private-key>

```
**NOTE**: Please replace `<rpc-endpoint>` and `<hex-private-key>` with appropriate values.

or

```bash
docker run -d -p 8080:8080 -e WEB3_PROVIDER=<rpc-endpoint> -e KEYSTORE=<keystore-path> -v `pwd`/keystore:/app/keystore -v `pwd`/password.txt:/app/password.txt liskhq/lsk-faucet
make docker-start WEB3_PROVIDER=<rpc-endpoint> KEYSTORE=<keystore-path>
```

**NOTE**: Please replace `<rpc-endpoint>` and `<keystore-path>` with appropriate values.
Expand Down

0 comments on commit ec58713

Please sign in to comment.