Skip to content

Commit

Permalink
Add GitHub action to publish release (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaykeren authored Nov 15, 2023
2 parents f4bc25b + d4ee3c6 commit 4b7cbec
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 35 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

# permissions are needed if pushing to ghcr.io
permissions:
packages: write

jobs:
install:
name: Test installation
runs-on: ubuntu-latest-m

steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Desktop
id: start_desktop
uses: docker/desktop-action/start@v0.3.1

- name: Validate metadata
run: docker extension validate ./metadata.json

- name: Build extension
run: docker build -t digma-docker-extension .

- name: Install extension
run: docker extension install digma-docker-extension -f

build:
name: Build
needs: [install]
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build multi-platform image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
79 changes: 79 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Publish release

# Controls when the workflow will run
on:
workflow_dispatch:
release:
types: [released]

# permissions are needed if pushing to ghcr.io
permissions:
packages: write

jobs:
install:
name: Test the installation
runs-on: ubuntu-latest-m

steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Desktop
id: start_desktop
uses: docker/desktop-action/start@v0.3.1

- name: Validate metadata
run: docker extension validate ./metadata.json

- name: Build extension
run: docker build -t digma-docker-extension .

- name: Install extension
run: docker extension install digma-docker-extension -f

build-and-push:
name: Build and push to the DockerHub
needs: [install]
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_DIGMAAI_USERNAME }}
password: ${{ secrets.DOCKERHUB_DIGMAAI_TOKEN }}

- name: Docker meta
id: metadata # you'll use this in the next step
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: digmaai/digma-docker-extension
# Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
40 changes: 5 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
# Digma Continuous Feedback

This repository defines an example of a Docker extension. The files in this repository have been automatically generated as a result of running `docker extension init`.

This extension is composed of:

- A [frontend](./ui) app in React that makes a request to the `/hello` endpoint and displays the payload in Docker Desktop.
- A [backend](./backend) container that runs an API in Go. It exposes the `/hello` endpoint which returns a JSON payload.

> You can build your Docker Extension using your fav tech stack:
>
> - Frontend: React, Angular, Vue, Svelte, etc.
> Basically, any frontend framework you can bundle in an `index.html` file with CSS, and JS assets.
> - Backend (optional): anything that can run in a container.
<details>
<summary>Looking for more templates?</summary>

1. [React + NodeJS](https://github.com/benja-M-1/node-backend-extension).
2. [React + .NET 6 WebAPI](https://github.com/felipecruz91/dotnet-api-docker-extension).

Request one or submit yours [here](https://github.com/docker/extensions-sdk/issues).

</details>
- A [frontend](./ui) React app that communicates with the [backend](./backend) container and displays data in Docker Desktop.
- A [backend](./backend) container that runs an Digma API gateway in Node.js.

## Local development

You can use `docker` to build, install and push your extension. Also, we provide an opinionated [Makefile](Makefile) that could be convenient for you. There isn't a strong preference of using one over the other, so just use the one you're most comfortable with.
You can use `docker` to build, install and push your extension. Also, there is opinionated [Makefile](Makefile) that could be convenient for you. There isn't a strong preference of using one over the other, so just use the one you're most comfortable with.

To build the extension, use `make build-extension` **or**:

Expand Down Expand Up @@ -74,11 +54,9 @@ Each subsequent click on the extension tab will also open Chrome Dev Tools. To s
docker extension dev reset digma-ai/digma-docker-extension:latest
```

### Backend development (optional)

This example defines an API in Go that is deployed as a backend container when the extension is installed. This backend could be implemented in any language, as it runs inside a container. The extension frameworks provides connectivity from the extension UI to a socket that the backend has to connect to on the server side.
### Backend development

Note that an extension doesn't necessarily need a backend container, but in this example we include one for teaching purposes.
Digma extension defines an API in Node.js that is deployed as a backend container when the extension is installed. The extension frameworks provides connectivity from the extension UI to a socket that the backend has to connect to on the server side.

Whenever you make changes in the [backend](./backend) source code, you will need to compile them and re-deploy a new version of your backend container.
Use the `docker extension update` command to remove and re-install the extension automatically:
Expand All @@ -88,7 +66,6 @@ docker extension update digma-ai/digma-docker-extension:latest
```

> If you want to automate this command, use the `-f` or `--force` flag to accept the warning message.
> Extension containers are hidden from the Docker Dashboard by default. You can change this in Settings > Extensions > Show Docker Extensions system containers.
### Clean up
Expand All @@ -98,10 +75,3 @@ To remove the extension:
```shell
docker extension rm digma-ai/digma-docker-extension:latest
```

## What's next?

- To learn more about how to build your extension refer to the Extension SDK docs at https://docs.docker.com/desktop/extensions-sdk/.
- To publish your extension in the Marketplace visit https://www.docker.com/products/extensions/submissions/.
- To report issues and feedback visit https://github.com/docker/extensions-sdk/issues.
- To look for other ideas of new extensions, or propose new ideas of extensions you would like to see, visit https://github.com/docker/extension-ideas/discussions.

0 comments on commit 4b7cbec

Please sign in to comment.