Skip to content

Commit

Permalink
Merge pull request #1 from book000/feat/improve-dockerfile
Browse files Browse the repository at this point in the history
feat: Dockerパッケージ処理の改善
  • Loading branch information
book000 authored Sep 30, 2023
2 parents 5ecdfb4 + d6718b4 commit 4b47d00
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 34 deletions.
133 changes: 102 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ on:
push:
branches:
- main
workflow_dispatch:

jobs:
Release:
bump-version:
name: 🔼 Bump version
runs-on: ubuntu-latest

outputs:
new_version: ${{ steps.version.outputs.new_version }}

steps:
- name: 🔼 Bump release version
id: version
Expand All @@ -16,57 +22,122 @@ jobs:
github_token: ${{ github.token }}
default_bump: "minor"
custom_release_rules: "breaking:major:💣 Breaking Changes,feat:minor:✨ Features,fix:patch:💣 Bug Fixes,docs:patch:📰 Docs,chore:patch:🎨 Chore,pref:patch:🎈 Performance improvements,refactor:patch:🧹 Refactoring,build:patch:🔍 Build,ci:patch:🔍 CI,revert:patch:⏪ Revert,style:patch:🧹 Style,test:patch:👀 Test"
- name: "☕ Setup Zulu JDK17"

build-docker:
name: 🏗️ Build Docker (${{ matrix.architecture }}})
runs-on: ubuntu-latest
needs: bump-version

strategy:
fail-fast: false
matrix:
architecture: [amd64, arm64]

steps:
- name: 📥 Checkout ${{ github.repository }}
uses: actions/checkout@v3

- name: 🐋 Setup QEMU
uses: docker/setup-qemu-action@v3

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

- name: 📥 Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 📝 Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}:${{ matrix.architecture }}
tags: |
type=raw,value=${{ needs.bump-version.outputs.new_version }}-${{ matrix.architecture }}
type=raw,value=latest-${{ matrix.architecture }}
- name: 🚀 Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/${{ matrix.architecture }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

merge-latest:
name: 📥 Merge latest
runs-on: ubuntu-latest
needs:
- bump-version
- build-docker

steps:
- name: 📥 Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push manifest images (latest)
uses: Noelware/[email protected]
with:
images: ghcr.io/${{ github.repository }}:latest
inputs: ghcr.io/${{ github.repository }}:latest-amd64,ghcr.io/${{ github.repository }}:latest-arm64
push: true

- name: Create and push manifest images (version)
uses: Noelware/[email protected]
with:
images: ghcr.io/${{ github.repository }}:${{ needs.bump-version.outputs.new_version }}
inputs: ghcr.io/${{ github.repository }}:${{ needs.bump-version.outputs.new_version }}-amd64,ghcr.io/${{ github.repository }}:${{ needs.bump-version.outputs.new_version }}-arm64
push: true

create-release:
name: 📦 Create Release
runs-on: ubuntu-latest
needs:
- bump-version
- build-docker
- merge-latest

steps:
- name: ☕ Setup Zulu JDK 17
uses: actions/[email protected]
with:
distribution: "zulu"
java-version: "17"
distribution: zulu
java-version: 17

- name: 🐘 Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: release-candidate

- name: 📥 Checkout ${{ github.repository }}
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
token: ${{ github.token }}
path: project

- name: ⌛ Restore caches
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: 🐘 Run Gradle command
run: |
cd project
gradle build
mv build/libs/*.jar build/libs/vcspeaker-kt.jar
- name: 🗃️ Publish Release on main
env:
project_version: ${{ steps.version.outputs.new_version }}
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
tag_name: ${{ env.project_version }}
tag_name: ${{ needs.bump-version.outputs.new_version }}
files: |
project/build/libs/vcspeaker-kt.jar
- name: 🏗️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 📥 Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🚀 Build Docker image
env:
project_version: ${{ steps.version.outputs.new_version }}
uses: docker/build-push-action@v5
with:
context: ./project
push: true
tags: |
ghcr.io/jaoafa/vcspeaker-kt:latest
ghcr.io/jaoafa/vcspeaker-kt:${{ env.project_version }}
18 changes: 15 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
FROM azul/zulu-openjdk-alpine:17-latest
FROM azul/zulu-openjdk-alpine:17-latest as builder

ENV APP_GIT_LINK https://github.com/jaoafa/VCSpeaker.kt
# hadolint ignore=DL3018
RUN apk add --no-cache git wget unzip

WORKDIR /build

COPY gradle gradle
COPY src src
COPY gradlew build.gradle.kts gradle.properties settings.gradle.kts ./

RUN chmod a+x gradlew && \
./gradlew build

FROM azul/zulu-openjdk-alpine:17-latest as runner

WORKDIR /app

RUN wget ${APP_GIT_LINK}/releases/latest/download/vcspeaker-kt.jar
COPY --from=builder /build/build/libs/vcspeaker-*.jar /app/vcspeaker-kt.jar

ENV VCSKT_CONFIG /data/config.yml
ENV VCSKT_STORE /data/store/
Expand Down
6 changes: 6 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
app:
build: .
volumes:
- ./data:/data
init: true

0 comments on commit 4b47d00

Please sign in to comment.