diff --git a/.github/workflows/paladin-PR-build.yml b/.github/workflows/build.yaml similarity index 65% rename from .github/workflows/paladin-PR-build.yml rename to .github/workflows/build.yaml index e6f716e49..a7dc880c9 100644 --- a/.github/workflows/paladin-PR-build.yml +++ b/.github/workflows/build.yaml @@ -1,10 +1,12 @@ -name: Paladin CI build +name: build on: - push: - branches: [main] - pull_request: workflow_dispatch: + inputs: + ARTIFACTS_PATH: + required: false + type: string + default: build/libs jobs: build: @@ -38,6 +40,16 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + with: + add-job-summary-as-pr-comment: on-failure - name: Build with Gradle - run: ./gradlew -PcomposeLogs=true -PverboseTests=true -PjarVersion=v0.0.0 --no-daemon --parallel + run: ./gradlew -PcomposeLogs=true -PverboseTests=true --no-daemon --parallel + + - uses: actions/upload-artifact@v4 + name: Upload build artifacts + with: + name: paladin-libs + path: ${{ inputs.ARTIFACTS_PATH }} + if-no-files-found: error + \ No newline at end of file diff --git a/.github/workflows/image-build.yaml b/.github/workflows/image-build.yaml new file mode 100644 index 000000000..819eb8d64 --- /dev/null +++ b/.github/workflows/image-build.yaml @@ -0,0 +1,65 @@ +name: build + +on: + workflow_dispatch: + inputs: + IMAGE_REGISTRY: + required: false + description: 'image registry' + default: '' + IMAGE_NAME: + required: false + description: 'Name of the image to build' + default: 'paladin' + IMAGE_TAG: + required: false + description: 'Version of the image to build' + default: 'latest' + BUILD_PLATFORM: + required: false + description: 'Platform to build the image for' + default: 'linux/amd64' + # default: 'linux/amd64,linux/arm64' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - uses: actions/download-artifact@v4 + name: Download build artifacts + with: + name: paladin-libs + path: build/libs/ + if-no-files-found: error + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # TODO: Setup docker registry + # - name: Login to Docker registry + # if: ${{ inputs.IMAGE_REGISTRY != '' }} + # uses: docker/login-action@v3 + # with: + # registry: ${{ inputs.IMAGE_REGISTRY }} + # username: ${{ secrets.REGISTRY_USERNAME }} + # password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Build + uses: docker/build-push-action@v3 + with: + context: . + file: Dockerfile + tags: ${{ inputs.IMAGE_REGISTRY }}/${{ inputs.IMAGE_NAME }}:${{ inputs.IMAGE_TAG }} + build-args: image_version=${{ inputs.IMAGE_TAG }} + platforms: ${{ inputs.BUILD_PLATFORM }} + cache-from: type=gha + cache-to: type=gha,mode=max + push: false diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 000000000..80a6529f3 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,62 @@ +name: PR +permissions: read-all +on: + pull_request: + types: [opened, reopened, synchronize, ready_for_review] + paths-ignore: + - '**.sh' + - 'docs/*' + - 'build/*' + - '.github/*' + # - '**.md' // Uncomment this line to ignore all markdown files + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test-and-build: + permissions: + actions: read + checks: read + deployments: read + id-token: write + issues: read + discussions: read + packages: read + pages: read + pull-requests: write + repository-projects: read + security-events: read + statuses: read + attestations: read + contents: write + uses: ./.github/workflows/build.yaml + secrets: inherit + with: + ARTIFACTS_PATH: buils/libs + + build-image: + permissions: + actions: read + checks: read + contents: write + deployments: read + discussions: read + id-token: write + issues: read + packages: write + pages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read + attestations: read + uses: ./.github/workflows/image-build.yaml + with: + ARTIFACTS_PATH: buils/libs + IMAGE_NAME: paladin + IMAGE_TAG: pr-test + BUILD_PLATFORM: linux/amd64 + + secrets: inherit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..0a8bdc8ef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM ubuntu:24.04 + +# Install Java (JRE only) and other necessary dependencies +RUN apt-get update && \ + apt-get install --no-install-recommends -y openjdk-21-jre-headless && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Set the working directory +WORKDIR /app + +# Copy the JAR file and necessary libraries +COPY build/libs/ libs/ + +# placehoolder: expose ports +# EXPOSE + +# placehoolder: entrypoint +# ENTRYPOINT ["paladin"] + +# Run the JAR file +# Override this with `docker run --entrypoint` +ENTRYPOINT ["java", "-Djna.library.path=/app/libs", "-jar", "app/libs/paladin.jar"] + +# Default command-line arguments (config file and node name) +# Override this with docker run /app/other-config.yaml another-node + +CMD ["app/config.paladin.yaml", "node"] + +# Override the default command-line arguments +# docker run -d -p <>:<> \ +# -v : \ +# \ +# -Djna.library.path=/app \ +# -jar paladin.jar \ No newline at end of file diff --git a/build.gradle b/build.gradle index 09fe58979..fe3c8d50a 100644 --- a/build.gradle +++ b/build.gradle @@ -82,5 +82,5 @@ defaultTasks 'build', 'copyExecutables' // Clean task to clean all projects task clean { - delete 'build' + delete "${buildDir}" }