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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This image installs the JDK and copies no files from the build context.
**
!Dockerfile
152 changes: 99 additions & 53 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,119 @@
name: Docker Image

on:
schedule:
- cron: "0 11 * * *" # everyday at 11am
pull_request:
branches: [latest]
push:
branches: ["**"]
tags: ["v*.*.*"]
branches: [latest]
tags: ['v*.*.*']
schedule:
- cron: '0 11 * * *'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7
IMAGE: beevelop/java

jobs:
main:
runs-on: ubuntu-latest
validate:
runs-on: ubuntu-24.04
timeout-minutes: 30
env:
# Docker Hub credentials are not available for pull requests and Dependabot runs
publish: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
steps:
- name: Check out the repo
uses: actions/checkout@v7
- name: Set imageName based on the repository name
id: step_one
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1

- name: Build test image
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
load: true
platforms: linux/amd64
tags: winter-clean:test
cache-from: type=gha,scope=test
cache-to: type=gha,scope=test,mode=max,ignore-error=true
no-cache-filters: ${{ github.event_name == 'schedule' && 'java' || '' }}
- name: Test the image
run: |
imageName="${GITHUB_REPOSITORY/docker-/}"
echo $imageName
echo "imageName=$imageName" >> $GITHUB_ENV
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v6
docker run --rm winter-clean:test sh -ec '
"$JAVA_HOME/bin/java" -version
"$JAVA_HOME/bin/javac" -version
javac -version 2>&1 | grep -E "^javac 17([.]|$)"
'

publish:
needs: validate
if: >-
github.actor != 'dependabot[bot]' &&
github.event_name != 'pull_request' &&
(github.ref == 'refs/heads/latest' ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')))
runs-on: ubuntu-24.04
timeout-minutes: 40
permissions:
security-events: write
contents: read
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Generate labels and tags
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.imageName }}
images: ${{ env.IMAGE }}
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/latest' }}
type=ref,event=tag
type=schedule,pattern=nightly
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
with:
platforms: arm64,arm
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
if: env.publish == 'true'
uses: docker/login-action@v4.8.0
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Log in to Docker Hub
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Buildx cache
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/cache
key: ${{ runner.os }}-docker-${{ hashfiles('cache/**') }}
restore-keys: |
${{ runner.os }}-docker
- name: Build and push
id: docker_build
uses: docker/build-push-action@v7
- name: Build and publish
id: build
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
platforms: ${{ env.publish == 'true' && env.platforms || 'linux/amd64' }}
push: ${{ env.publish == 'true' }}
load: ${{ env.publish != 'true' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=local,src=${{ github.workspace }}/cache
cache-to: type=local,dest=${{ github.workspace }}/cache
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@v0.36.0
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
sbom: true
provenance: mode=max
cache-from: |
type=gha,scope=test
type=gha,scope=publish
cache-to: type=gha,scope=publish,mode=max,ignore-error=true
no-cache-filters: ${{ github.event_name == 'schedule' && 'java' || '' }}

- name: Scan the published digest
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: ${{ env.imageName }}:${{ steps.docker_meta.outputs.version }}
format: "template"
template: "@/contrib/sarif.tpl"
output: "trivy-results.sarif"
- name: Upload Trivy scan results to GitHub Security tab
if: env.publish == 'true'
uses: github/codeql-action/upload-sarif@v4.39.3
image-ref: ${{ env.IMAGE }}@${{ steps.build.outputs.digest }}
format: sarif
output: scan.sarif

- name: Upload scan results
uses: github/codeql-action/upload-sarif@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
with:
sarif_file: "trivy-results.sarif"
sarif_file: scan.sarif
23 changes: 14 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
FROM beevelop/base
# syntax=docker/dockerfile:1
# check=error=true
ARG BASE_IMAGE=beevelop-base

# Install OpenJDK 17 and clean up in a single layer
RUN apt-get update && \
apt-get install -y --no-install-recommends \
openjdk-17-jdk-headless && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
java -version
FROM beevelop/base:latest@sha256:cf2a1aa182183e5992ea71ddb238b150c7bdd7d52f3a671559a45e0ae25fef18 AS beevelop-base

ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
FROM ${BASE_IMAGE} AS java
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends openjdk-17-jdk-headless \
&& ln -s "$(dirname "$(dirname "$(readlink -f "$(command -v javac)")")")" /opt/java \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ENV JAVA_HOME=/opt/java

HEALTHCHECK NONE
Loading