feat(docker): gradle-8

This commit is contained in:
tiennm99 committed 2025-10-06 21:12:34 +07:00
1 parent cde575bd7e
commit 8b27ca039f
2 files changed
+76

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
name: Publish Gradle 8 Docker Image
on:
push:
branches: [main]
paths:
- 'gradle-8/**'
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}/gradle-8
tags: |
type=raw,value=latest
type=raw,value=8.14.3
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: gradle-8
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+33
View File
@@ -0,0 +1,33 @@
FROM ghcr.io/tiennm99/docker-images/oraclejdk-8:8u201
# Set environment variables
ENV GRADLE_HOME /opt/gradle
ENV PATH $GRADLE_HOME/bin:$PATH
ENV GRADLE_VERSION 8.14.3
# Install dependencies
RUN apt-get update && \
apt-get install -y wget unzip && \
rm -rf /var/lib/apt/lists/*
# Download and install Gradle
RUN wget -O gradle.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" && \
mkdir -p /opt && \
unzip -d /opt gradle.zip && \
mv /opt/gradle-${GRADLE_VERSION} /opt/gradle && \
rm gradle.zip
# Create a non-root user
RUN groupadd -r gradle && useradd -r -g gradle gradle
# Set ownership
RUN chown -R gradle:gradle /opt/gradle
# Switch to the gradle user
USER gradle
# Set working directory
WORKDIR /home/gradle
# Default command
CMD ["gradle", "--version"]