Skip to content

Commit

Permalink
Update dockerfile, docker-compose
Browse files Browse the repository at this point in the history
* Updates Dockerfile, docker-compose
* Updates the copy_proto script
* Updates the README, proto/README
* Adds additional database up/down functions to maintain the existing volume
* Adds a workflow to publish a docker to dockerhub

closes: #10
  • Loading branch information
Carolyn Russell committed Mar 18, 2021
1 parent fe2320d commit aadeb45
Show file tree
Hide file tree
Showing 20 changed files with 246 additions and 335 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
build
scripts
gradle
.idea
.gradle
.github
service/docker
.dockerignore
.gitignore
gradlew
gradlew.bat
.DS_STORE
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
target: run
file: service/docker/Dockerfile
context: .
push: true
tags: provenanceio/explorer-service:latest
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Added support for multisig on transactions, accounts, and validators (limited) #9
* Added Validator-specific APIs #15
* Added Account-specific transaction API #11
* Added working docker-compose script #10

### Improvements
* Added templates and build workflow
Expand All @@ -51,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Updated native queries to use exposed query-building instead
* Updated transaction queries to return same objects as other similar queries #14
* Upgraded Exposed library from 0.17.1 to 0.29.1
* Updated the copy_proto script to be more intuitive

### Bug Fixes
* Translated the signatures back to usable addresses
Expand Down
42 changes: 35 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ The purpose of this api backend is to provide a single API for the Provenance Bl
aggregate and cache information needed by the front end (e.g. simplify multiple block/transaction calls into a
single call), and provide Provenance Blockchain specific endpoints.

### Table of Contents
- [Provenance Explorer](#provenance-explorer)
* [How to run testnet and explorer locally](#how-to-run-testnet-and-explorer-locally)
+ [To get testnet up](#to-get-testnet-up)
- [To start a local isolated cluster](#to-start-a-local-isolated-cluster)
- [To start a node on the public chain](#to-start-a-node-on-the-public-chain)
+ [To get Explorer up](#to-get-explorer-up)
- [Manually - in terminals](#manually---in-terminals)
+ [To get the explorer database up FIRST](#to-get-the-explorer-database-up-first)
+ [To get the explorer API up SECOND](#to-get-the-explorer-api-up-second)
+ [To get the explorer UI up THIRD](#to-get-the-explorer-ui-up-third)
- [Via Docker and Docker-compose](#via-docker-and-docker-compose)
+ [Swagger URLs](#swagger-urls)

## How to run testnet and explorer locally

Expand All @@ -13,11 +26,14 @@ Necessary tools
- LevelDB
- NPM
- Docker
- Docker-compose


### To get testnet up
- Clone provenance public repo -> https://github.com/provenance-io/provenance
- Navigate to the repo folder

#### To start a local isolated cluster
- Run `make clean ; make build; make localnet-start`
- This allows you to stand up 4 nodes in a local cluster
</br></br>
Expand All @@ -32,37 +48,49 @@ Necessary tools
</br></br>
- To stop the cluster, run `make localnet-stop`
#### To start a node on the public chain
- Run `git fetch --all; git checkout {tag_you_want}; make clean install;`
- TODO: Fill in the rest
### To get Explorer up
- Clone explorer-service public repo -> https://github.com/provenance-io/explorer-service
- Navigate to the repo folder
#### To get the explorer database up FIRST
- Run `./dc.sh up`
#### Manually - in terminals
###### To get the explorer database up FIRST
- Run `./scripts/dc.sh up`
- To get an existing database up again, run `./scripts/dc.sh up-cached`
#### To get the explorer API up SECOND
###### To get the explorer API up SECOND
- Go to `service/src/main/resources/application.properties`
- Make sure the following properties are as follows:
```
provenance-explorer.mainnet=false
provenance-explorer.pb-url=http://localhost:9090
explorer.mainnet=false
explorer.pb-url=http://localhost:9090
```
- Run from command line
```
sh ./gradlew -------------> Installs the gradlew stuff
./gradlew clean
./gradlew build
./gradlew bootRun -Dspring.profiles.active=development
```
#### To get the explorer UI up THIRD
###### To get the explorer UI up THIRD
- Clone explorer-frontend public repo -> https://github.com/provenance-io/explorer-frontend
- Navigate to the repo folder
- Run `npm install`
- Run `npm run local`
- Navigate to http://localhost:3000/explorer
#### Via Docker and Docker-compose
- Run `docker-compose -f docker/docker-compose.yml up`
- To build the images, add `--build -d`
- Follow [this](#to-get-the-explorer-ui-up-third) for frontend piece
### Swagger URLs
Useful to hit the respective APIs directly
Swagger for Explorer : http://localhost:8612/swagger-ui/index.html# <br/>
Swagger for Explorer : http://localhost:8612/swagger-ui/index.html <br/>
Swagger for Testnet: http://localhost:1317/swagger/
19 changes: 0 additions & 19 deletions dc.sh

This file was deleted.

31 changes: 31 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM gradle:6.8.3-jdk11 AS build
RUN gradle --version && java -version
WORKDIR /app

# Only copy dependency-related files
COPY build.gradle.kts gradle.properties settings.gradle.kts proto/build.gradle.kts buildSrc/build.gradle.kts /app/

# Only download dependencies
# Eat the expected build failure since no source code has been copied yet
RUN gradle clean build --no-daemon > /dev/null 2>&1 || true

# Copy all files
COPY service /app/service/
COPY database /app/database/
COPY buildSrc /app/buildSrc/
COPY proto /app/proto/
COPY third_party /app/third_party/
COPY .git /app/.git/
COPY build.gradle.kts gradle.properties settings.gradle.kts /app/
COPY CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md LICENSE README.md /app/

# Do the actual build
RUN gradle clean build --no-daemon

FROM openjdk:11-jre

COPY --from=build /app/service/build/libs/*.jar /service.jar

EXPOSE 8612/tcp

CMD java -jar /service.jar
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3.5'
services:
postgres:
image: postgres:9.6.5
image: postgres:13.2
container_name: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password1
ports:
- 5432:5432
volumes:
- ./db-init:/docker-entrypoint-initdb.d/
- ./db-init:/docker-entrypoint-initdb.d/
38 changes: 38 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: '3.9'
services:
postgres:
image: postgres:13.2
container_name: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password1
ports:
- 5432:5432
volumes:
- ./db-init:/docker-entrypoint-initdb.d/

explorer-service:
image: explorer:latest
build:
context: ../
dockerfile: docker/Dockerfile
container_name: explorer
ports:
- 8612:8612
environment:
- SPRING_PROFILES_ACTIVE=container
- DB_USER=postgres
- DB_PASS=password1
- DB_HOST=postgres
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/explorer
- DB_PORT=5432
- DB_NAME=explorer
- DB_SCHEMA=explorer
- DB_CONNECTION_POOL_SIZE=5
- SPOTLIGHT_TTL_MS=5000
- INITIAL_HIST_DAY_COUNT=14
- EXPLORER_MAINNET=false
# Hits the locally running node
- EXPLORER_PB_URL=http://host.docker.internal:9090
depends_on:
- postgres
15 changes: 10 additions & 5 deletions proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

The protos that get built come from the third_party folder.

To populate the folder with the most up to date protos, run `./scripts/copy_proto.sh`.
To populate the folder with the most up to date protos, run `./scripts/copy_proto_v2.sh {prov_version} {cosmos_version}`.

This does not need to be run very often, but only when you feel the protos should be updated.

In addition, for any new client endpoints, please consider copying in the associated proto from the source of the api.
~~In addition, for any new client endpoints, please consider copying in the associated proto from the source of the api.
This will provide you with the exact response object rather than have to create your own. Exceptions do occur where proto
is not used.
is not used.~~

* To add new protos to be copied, update `/scripts/copy_proto.sh` with the appropriate pathing. The target location
must match the package path in the proto file itself.
~~* To add new protos to be copied, update `/scripts/copy_proto.sh` with the appropriate pathing. The target location
must match the package path in the proto file itself.~~ Unnecessary as of 2021/03/12ish

This script will pull in appropriate protos from the given release version. Please verify that the copied protos are
correct for your purposes.

To build the protos for use, run `./gradlew proto:build`.
Loading

0 comments on commit aadeb45

Please sign in to comment.