Skip to content

Commit

Permalink
Add Github workflow to build and publish Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
ksenia-vazhdaeva committed Jul 8, 2024
1 parent 38c65d0 commit 7b2f2fe
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 16 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docker build & publish

on:
push:
branches:
- main
tags:
- "*"

env:
REGISTRY: ghcr.io

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Define metadata (tags) for Docker
id: meta
run: |
TAG="latest"
if [ "${{ github.ref_type }}" == "tag" ]; then
TAG=${{ github.ref_name }}
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Build and push Docker server image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/media-gateway-server:${{ steps.meta.outputs.tag}}
build-args: |
TYPE=server
- name: Build and push Docker client image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/media-gateway-client:${{ steps.meta.outputs.tag}}
build-args: |
TYPE=client
20 changes: 4 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,14 @@ Both server and client can be run as Docker containers.

### Server

To build Docker image for the server

```bash
docker build --build-arg="TYPE=server" -t media-gateway-server:latest .
```

To run the server with [the default configuration](samples/server/default_config.json) and to mount `/tmp` directory and
publish the port from the default configuration

```bash
docker run \
-v /tmp:/tmp \
-p 8080:8080 \
media-gateway-server:latest
ghcr.io/insight-platform/media-gateway-server:latest
```

To run the server with another configuration (`/home/user/server_config.json`)
Expand All @@ -65,25 +59,19 @@ To run the server with another configuration (`/home/user/server_config.json`)
docker run \
-v /home/user/server_config.json:/opt/etc/custom_config.json \
-p HOST_PORT:CONFIG_PORT \
media-gateway-server:latest \
ghcr.io/insight-platform/media-gateway-server:latest \
/opt/etc/custom_config.json
```

### Client

To build Docker image for the client

```bash
docker build --build-arg="TYPE=client" -t media-gateway-client:latest .
```

To run the client with [the default configuration](samples/client/default_config.json) and to mount `/tmp` directory

```bash
docker run \
-v /tmp:/tmp \
-e "GATEWAY_URL=<GATEWAY_URL>" \
media-gateway-client:latest
ghcr.io/insight-platform/media-gateway-client:latest
```

where `<GATEWAY_URL>` is the server URL, e.g. `http://192.168.0.100:8080`
Expand All @@ -93,6 +81,6 @@ To run the server with another configuration (`/home/user/client_config.json`)
```bash
docker run \
-v /home/user/client_config.json:/opt/etc/custom_config.json \
media-gateway-client:latest \
ghcr.io/insight-platform/media-gateway-client:latest \
/opt/etc/custom_config.json
```
20 changes: 20 additions & 0 deletions benches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Benchmarking

Benchmark tests use Docker images built locally from sources.

## Server

To build Docker image for the server

```bash
docker build --build-arg="TYPE=server" -t media-gateway-server:latest .
```

## Client

To build Docker image for the client

```bash
docker build --build-arg="TYPE=client" -t media-gateway-client:latest .
```

0 comments on commit 7b2f2fe

Please sign in to comment.