Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Docker Container

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: java-profiler-tools:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Test Docker image
run: |
docker run --rm java-profiler-tools:latest java -version
docker run --rm java-profiler-tools:latest ls -la /usr/local/async-profiler/
docker run --rm java-profiler-tools:latest ls -la /usr/local/flame-graph/
47 changes: 47 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish Docker Image

on:
push:
branches: [ main, master ]
tags: [ 'v*' ]
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_USERNAME }}/java-profiler-tools
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,31 @@ This container can be handy when you need to attach to some Java container and

Usage example can be found [here](https://ember.deltixlab.com/docs/kb/profiling/?_highlight=perf#profiling-ember-with-perf).

## CI/CD

This project uses GitHub Actions for continuous integration and deployment:

### Build Workflow
- **File**: `.github/workflows/docker-build.yml`
- **Triggers**: Push to main/master branch, pull requests, manual dispatch
- **Actions**: Builds the Docker image and runs basic tests
- **No external dependencies required**

### Publish Workflow (Optional)
- **File**: `.github/workflows/docker-publish.yml`
- **Triggers**: Push tags starting with 'v' (e.g., v1.0.0), manual dispatch
- **Actions**: Builds and publishes the Docker image to Docker Hub
- **Required secrets**: `DOCKER_USERNAME` and `DOCKER_PASSWORD`

### Setting up Docker Hub Publishing
If you want to publish to Docker Hub, add these secrets to your GitHub repository:
1. Go to your repository Settings → Secrets and variables → Actions
2. Add `DOCKER_USERNAME` with your Docker Hub username
3. Add `DOCKER_PASSWORD` with your Docker Hub access token

Then create a tag to trigger the publish workflow:
```bash
git tag v1.0.0
git push origin v1.0.0
```

Loading