Skip to content

Commit

Permalink
Add CLI image (#67)
Browse files Browse the repository at this point in the history
* Add cli image job, update docs, and move the docker folder to outside project-template

* Update docs

* Update docker registry path and fix unifyVersions script

* Update publish image ci

* Update Docker file to trigger the CI

* Update docker path

* Change tag to latest

* Change tag to latest and remove extract metadata

* Use registry in lowercase

* Modify docker file to trigger ci

* Use repository name as lowercase

* Add windows docker setup ci

* Remove container operation because it only work on linux runners

* Remove non supported privileged mode

* Remove windows setup job

* Add Troubleshooting section to docs and increase the version to 1.0.16
  • Loading branch information
felipe.fuerback authored Feb 29, 2024
1 parent 4da9c9f commit f1e1ee0
Show file tree
Hide file tree
Showing 19 changed files with 193 additions and 148 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,36 +121,6 @@ jobs:
exit 1
fi
windows-init-command:
name: Init Command on Windows
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm install
- name: Build CLI for windows and link it
run: |
cd chain-cli
npm install
npm run build-win
npm link --force
- name: Initialize a project and validate the package.json
run: galachain init test-project
- name: Check if the package.json contains '@gala-chain/test-project' using windows command
run: |
$package = Get-Content -Path test-project/package.json -Raw
if ($package -match '@gala-chain/test-project') {
Write-Host "package.json contains '@gala-chain/test-project'"
} else {
Write-Host "package.json does not contain '@gala-chain/test-project'"
exit 1
}
chaincode-template-lint:
name: Chaincode Template Lint
runs-on: ubuntu-22.04
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/publish-cli-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish CLI Docker image
on:
push:
paths:
- 'chain-cli/docker/Dockerfile'

env:
REGISTRY: ghcr.io
IMAGE_NAME: galachain/sdk

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Make the repository name lowercase
id: lower-repo
shell: pwsh
run: |
"::set-output name=repository::$($env:GITHUB_REPOSITORY.ToLowerInvariant())"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./chain-cli/docker
push: true
tags: ghcr.io/${{ steps.lower-repo.outputs.repository }}:latest
2 changes: 1 addition & 1 deletion chain-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gala-chain/api",
"version": "1.0.15",
"version": "1.0.16",
"description": "Common types, DTOs (Data Transfer Objects), APIs, signatures, and utils for GalaChain.",
"license": "Apache-2.0",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion chain-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @gala-chain/cli
$ galachain COMMAND
running command...
$ galachain (--version)
@gala-chain/cli/1.0.15 linux-x64 node-v18.17.0
@gala-chain/cli/1.0.16 linux-x64 node-v18.17.0
$ galachain --help [COMMAND]
USAGE
$ galachain COMMAND
Expand Down
51 changes: 0 additions & 51 deletions chain-cli/chaincode-template/docker/README.md

This file was deleted.

12 changes: 6 additions & 6 deletions chain-cli/chaincode-template/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galachain/product",
"version": "1.0.15",
"version": "1.0.16",
"description": "Product Chaincode",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
Expand All @@ -21,16 +21,16 @@
"update-snapshot": "jest --updateSnapshot"
},
"dependencies": {
"@gala-chain/api": "1.0.15",
"@gala-chain/chaincode": "1.0.15",
"@gala-chain/api": "1.0.16",
"@gala-chain/chaincode": "1.0.16",
"dotenv": "^16.0.1",
"fabric-contract-api": "2.4.2",
"fabric-shim": "2.4.2"
},
"devDependencies": {
"@gala-chain/cli": "1.0.15",
"@gala-chain/client": "1.0.15",
"@gala-chain/test": "1.0.15",
"@gala-chain/cli": "1.0.16",
"@gala-chain/client": "1.0.16",
"@gala-chain/test": "1.0.16",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/axios": "^0.14.0",
"@types/jest": "^29.5.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,14 @@ RUN npm install -g @gala-chain/cli
# Install Nodemon globally
RUN npm install -g nodemon

# Define the build-time argument for the project name with a default value
ARG PROJECT_NAME=proj-galachain

# Initialize a project with galachain
RUN galachain init "$PROJECT_NAME"
RUN galachain init chaincode-template

# Change working directory to the project directory
WORKDIR /$PROJECT_NAME
WORKDIR /chaincode-template

# Install project dependencies
RUN npm install

# Expose port 3010
EXPOSE 3010

# Start the Docker daemon as a background process and tail its log file
CMD dockerd > /var/log/dockerd.log 2>&1 & tail -f /var/log/dockerd.log
52 changes: 52 additions & 0 deletions chain-cli/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Dockerized Galachain Dev Environment

## Base requirement

- Docker Desktop or Docker CLI.
- [Optional] VS Code with [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension.

## Run a container
Run a container from the built image:

$ docker run --privileged -d -p 3010:3010 -it --name <container_name> ghcr.io/galachain/sdk:latest

Make sure the container is up and running.
The Docker image initializes a new project with the name `chaincode-template` by default.

## Open the running container

### Open the container with bash

```
docker exec -ti <container_name> /bin/bash
```

### Open the container with VSCode (Requires VSCode and Dev Containers Extension)

Open VSCode and press F1 to open the Command Palette and search for `Dev Containers: Attach to Running Container`

After attach the container you may have to open the project folder manually.

## Start the network

Once the terminal is open, start the network

```
npm run network:start
```

The network is going to start in dev mode and the prompt will be left showing the logs, so don't close the prompt and open new ones to proceed with the following commands.

## Run integration tests

Now you can run integration tests with:

```
npm run test:e2e
```

## Verify changes in block browser and GraphQL

Navigate to [http://localhost:3010/blocks](http://localhost:3010/blocks) to see our block browser which allows you to see what's saved on your local GalaChain network.

Navigate to [http://localhost:3010/graphiql](http://localhost:3010/graphiql) to interact with GraphQL and execute queries.
2 changes: 1 addition & 1 deletion chain-cli/oclif.manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.15",
"version": "1.0.16",
"commands": {
"connect": {
"id": "connect",
Expand Down
4 changes: 2 additions & 2 deletions chain-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gala-chain/cli",
"version": "1.0.15",
"version": "1.0.16",
"description": "CLI for GalaChain to manage and deploy chaincodes",
"license": "Apache-2.0",
"bin": {
Expand All @@ -14,7 +14,7 @@
"/oclif.manifest.json"
],
"dependencies": {
"@gala-chain/api": "1.0.15",
"@gala-chain/api": "1.0.16",
"@noble/secp256k1": "^1.7.1",
"@oclif/core": "^2",
"@oclif/plugin-help": "^2",
Expand Down
5 changes: 0 additions & 5 deletions chain-cli/src/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ export default class Init extends BaseCommand<typeof Init> {
}

copyChaincodeTemplate(destinationPath: string): void {
if (process.platform === "win32") {
const sourceTemplateDir = path.resolve(__dirname, "..", "..", "..", "chaincode-template");
execSync(`xcopy ${sourceTemplateDir} ${destinationPath} /E /I`);
return;
}
const sourceTemplateDir = path.resolve(require.resolve("."), "../../../chaincode-template");
execSync(`cp -R ${sourceTemplateDir} ${destinationPath}`);
}
Expand Down
4 changes: 2 additions & 2 deletions chain-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gala-chain/client",
"version": "1.0.15",
"version": "1.0.16",
"description": "GalaChain client library",
"license": "Apache-2.0",
"scripts": {
Expand All @@ -21,7 +21,7 @@
"lib"
],
"dependencies": {
"@gala-chain/api": "1.0.15",
"@gala-chain/api": "1.0.16",
"axios": "^1.6.0",
"jsonschema": "^1.4.1",
"tslib": "^2.6.2",
Expand Down
6 changes: 3 additions & 3 deletions chain-test/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@gala-chain/test",
"version": "1.0.15",
"version": "1.0.16",
"description": "Unit testing and integration testing for GalaChain",
"license": "Apache-2.0",
"dependencies": {
"@gala-chain/client": "1.0.15",
"@gala-chain/client": "1.0.16",
"nanoid": "^3.3.6",
"tslib": "^2.6.2",
"path": "0.12.7",
"process": "0.11.10",
"@jest/globals": "29.7.0"
},
"peerDependencies": {
"@gala-chain/api": "1.0.15",
"@gala-chain/api": "1.0.16",
"bignumber.js": "*",
"class-transformer": "*",
"elliptic": "*",
Expand Down
4 changes: 2 additions & 2 deletions chaincode/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gala-chain/chaincode",
"version": "1.0.15",
"version": "1.0.16",
"description": "Framework for building chaincodes on GalaChain",
"license": "Apache-2.0",
"type": "commonjs",
Expand All @@ -21,7 +21,7 @@
"test": "jest"
},
"dependencies": {
"@gala-chain/api": "1.0.15",
"@gala-chain/api": "1.0.16",
"fabric-contract-api": "2.4.2",
"fabric-shim": "2.4.2",
"nanoid": "^3.3.6",
Expand Down
Loading

0 comments on commit f1e1ee0

Please sign in to comment.