Skip to content

Commit

Permalink
Merge pull request #3220 from Dr-Electron/docker/add-wasp-cli
Browse files Browse the repository at this point in the history
Add wasp-cli to docker
  • Loading branch information
lmoe authored Jan 25, 2024
2 parents 8f37a50 + 944a7f0 commit 0682f7e
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ snapshot
tools
wal
wasp
wasp-cli
!tools/wasp-cli
wasp-cluster
waspdb
42 changes: 41 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,26 @@ jobs:
type=match,pattern=v(\d+.\d+),suffix=-beta,group=1,enable=${{ contains(github.ref, '-beta') }}
type=match,pattern=v(\d+.\d+),suffix=-rc,group=1,enable=${{ contains(github.ref, '-rc') }}
- name: Extract CLI metadata (tags, labels) for Docker
id: meta-cli
uses: docker/metadata-action@v5
with:
images: iotaledger/sandbox-wasp-cli
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=match,pattern=v(\d+.\d+),suffix=-alpha,group=1,enable=${{ contains(github.ref, '-alpha') }}
type=match,pattern=v(\d+.\d+),suffix=-beta,group=1,enable=${{ contains(github.ref, '-beta') }}
type=match,pattern=v(\d+.\d+),suffix=-rc,group=1,enable=${{ contains(github.ref, '-rc') }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.IOTALEDGER_DOCKER_USERNAME }}
password: ${{ secrets.IOTALEDGER_DOCKER_PASSWORD }}

- name: Build and push to Dockerhub
- name: Build and push WASP to Dockerhub
uses: docker/build-push-action@v5
with:
context: .
Expand All @@ -114,6 +127,33 @@ jobs:
build-args: |
BUILD_LD_FLAGS=-X=github.com/iotaledger/wasp/components/app.Version=${{ steps.tagger.outputs.tag }}
- name: Build and push WASP CLI to Dockerhub
uses: docker/build-push-action@v5
with:
context: .
file: ./tools/wasp-cli/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-cli.outputs.tags }},iotaledger/sandbox-wasp-cli:latest
labels: ${{ steps.meta-cli.outputs.labels }}
build-args: |
BUILD_LD_FLAGS=-X=github.com/iotaledger/wasp/components/app.Version=${{ steps.tagger.outputs.tag }}
# Push wasp-cli README to Docker Hub
- name: git checkout
uses: actions/checkout@v3

- name: push README to Dockerhub
uses: christian-korneck/update-container-description-action@v1
env:
DOCKER_USER: ${{ secrets.IOTALEDGER_DOCKER_USERNAME }}
DOCKER_PASS: ${{ secrets.IOTALEDGER_DOCKER_PASSWORD }}
with:
destination_container_repo: iotaledger/sandbox-wasp-cli
provider: dockerhub
short_description: 'wasp-cli is a command line tool for interacting with IOTA Wasp and its smart contracts.'
readme_file: 'tools/wasp-cli/README.md'

release-iscmagic:
uses: ./.github/workflows/publish-iscmagic.yml
needs: release-docker
Expand Down
50 changes: 50 additions & 0 deletions tools/wasp-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# syntax=docker/dockerfile:1
ARG GOLANG_IMAGE_TAG=1.21-bullseye

# Build stage
FROM golang:${GOLANG_IMAGE_TAG} AS build
ARG BUILD_LD_FLAGS="--X=github.com/iotaledger/wasp/components/app.Version=v0.0.0-testing"

LABEL org.label-schema.description="Sandbox Wasp CLI"
LABEL org.label-schema.name="iotaledger/sandbox-wasp-cli"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.vcs-url="https://github.com/iotaledger/wasp"

# Ensure ca-certificates are up to date
RUN update-ca-certificates

# Set the current Working Directory inside the container
RUN mkdir /scratch
WORKDIR /scratch

# Prepare the folder where we are putting all the files
RUN mkdir /app

# Make sure that modules only get pulled when the module file has changed
COPY go.mod go.sum ./

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download

# Project build stage
COPY . .

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
cd ./tools/wasp-cli && go build -o /app/wasp-cli -a -ldflags=${BUILD_LD_FLAGS} .

############################
# Image
############################
# https://console.cloud.google.com/gcr/images/distroless/global/cc-debian11
# using distroless cc "nonroot" image, which includes everything in the base image (glibc, libssl and openssl)
FROM gcr.io/distroless/cc-debian11:nonroot

# Copy the app dir into distroless image
COPY --chown=nonroot:nonroot --from=build /app /app

WORKDIR /app
USER nonroot

ENTRYPOINT ["/app/wasp-cli"]
9 changes: 9 additions & 0 deletions tools/wasp-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Wasp Client tool

`wasp-cli` is a command line tool for interacting with Wasp and its smart
contracts. Find the documentation for it [here](https://wiki.iota.org/wasp-cli/how-tos/wasp-cli/).

## Docker

> [!WARNING]
> The `sandbox-wasp-cli` image is only meant to be used for development use cases like the sandbox. For everything else, download the binaries from the [releases](https://github.com/iotaledger/wasp/releases).

0 comments on commit 0682f7e

Please sign in to comment.