Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(image): add Dockerfile for agent carrier container image #390

Merged
merged 13 commits into from
Jul 12, 2024
2 changes: 2 additions & 0 deletions .containerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!target/*.jar
54 changes: 17 additions & 37 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ on:
env:
OPENSUSE_UNOFFICIAL_LIBCONTAINERS_KEY_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/Release.key"
OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04"
CI_USER: redhat-java-monitoring+github_ci
CI_REGISTRY: quay.io/redhat-java-monitoring
CI_IMG: quay.io/redhat-java-monitoring/quarkus-cryostat-agent
CARRIER_CI_USER: cryostat+bot
CARRIER_CI_REGISTRY: quay.io/cryostat
CARRIER_CI_IMG: quay.io/cryostat/cryostat-agent-carrier

jobs:
build-agent:
Expand All @@ -36,73 +36,53 @@ jobs:
echo "agent-version=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version)" >> $GITHUB_OUTPUT
- uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '11'
distribution: 'temurin'
- uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-build-${{ hashFiles('**/pom.xml') }}
- run: mvn -B -U clean install

build-quarkus-test-app:
build-carrier:
needs: [build-agent]
runs-on: ubuntu-latest
strategy:
matrix:
java: ['17']
outputs:
quay-image: ${{ steps.quarkus-test-image.outputs.image }}
env:
agent-version: ${{ needs.build-agent.outputs.image-version }}
name: Build Java ${{ matrix.java }}
name: Build carrier image
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Get date tag
run: echo "DATE_TAG=$(date -uI)" >> "$GITHUB_ENV"
- uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-build-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-
- uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
java-version: '11'
distribution: 'temurin'
cache: 'maven'
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
repository: ${{ github.repository_owner }}/test-applications
ref: main
submodules: true
fetch-depth: 0
- name: Build application
working-directory: quarkus-agent
run: ./mvnw -B -U -Dio.cryostat.agent.version=${{ env.agent-version }} clean verify
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
path: ~/.m2
key: ${{ runner.os }}-build-${{ hashFiles('**/pom.xml') }}
- run: mvn -B -U clean install
- name: Build container images and manifest
id: buildah-build
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.CI_IMG }}
image: ${{ env.CARRIER_CI_IMG }}
archs: amd64, arm64
tags: ${{ env.agent-version }} ${{env.DATE_TAG}} latest
context: quarkus-agent
containerfiles: |
./quarkus-agent/src/main/docker/Dockerfile.jvm
src/main/container/Containerfile
- name: Push to quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: quarkus-cryostat-agent
image: cryostat-agent-carrier
tags: ${{ steps.buildah-build.outputs.tags }}
registry: ${{ env.CI_REGISTRY }}
username: ${{ env.CI_USER }}
password: ${{ secrets.REPOSITORY_TOKEN }}
registry: ${{ env.CARRIER_CI_REGISTRY }}
username: ${{ env.CARRIER_CI_USER }}
password: ${{ secrets.CARRIER_REPOSITORY_TOKEN }}
- name: Print image URL
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
5 changes: 5 additions & 0 deletions src/main/container/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARG BASEIMAGE=docker.io/library/busybox:latest
andrewazores marked this conversation as resolved.
Show resolved Hide resolved
FROM ${BASEIMAGE}
ARG OUTDIR=/cryostat/agent
COPY target/cryostat-agent-*-shaded.jar ${OUTDIR}/
RUN ln -s ${OUTDIR}/cryostat-agent-*-shaded.jar ${OUTDIR}/cryostat-agent-shaded.jar
Loading