Skip to content

Commit

Permalink
formatting chaos
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Dec 28, 2023
1 parent 44fe4ec commit c77fe79
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 84 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Docker images

on:
workflow_dispatch:
inputs:
base_image_tags:
description: |
List of image tags of the mcdreforged/mcdreforged image for the workflow to build as the base images, separated with ",".
For example: "1.2.3,1.2.3-slim,1.2.3-py3.11,1.2.3-py3.11-slim"
type: string
required: true

jobs:
build_matrix:
name: Build matrix from input
runs-on: ubuntu-latest

steps:
- name: Build matrix
id: matrix
uses: actions/github-script@v7
with:
script: |
let matrix = {'include': []}
let summary = core.summary.addHeading('Input tags')
let tags = process.env.BASE_IMAGE_TAGS.split(',')
tags.filter(tag => tag !== '').forEach(tag => {
matrix.include.push({'base_image_tag': tag})
summary.addRaw(`- `\${tag}\``)
})
console.log(`matrix: ${JSON.stringify(matrix, null, 2)}`)
core.setOutput('matrix', JSON.stringify(matrix))
summary.write()
env:
BASE_IMAGE_TAGS: ${{ inputs.base_image_tags }}

outputs:
matrix: ${{ fromJson(needs.matrix_prep.outputs.matrix) }}

images:
needs: build_matrix
strategy:
matrix: ${{ fromJson(needs.build_matrix.outputs.matrix) }}

uses: ./.github/workflows/image_derivatives.yml
secrets: inherit
with:
source_tag: ${{ matrix.base_image_tag }}
35 changes: 0 additions & 35 deletions .github/workflows/image_all.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/image_derivatives.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: step.image_derivatives

# image input: "mcdreforged/mcdreforged:<source_tag>"
# These images will be built:
# mcdreforged/mcdreforged-extra:<source_tag>
# mcdreforged/mcdreforged-<jdk_distribution>:<source_tag>
# mcdreforged/mcdreforged-<jdk_distribution>:<source_tag>-extra
# mcdreforged/mcdreforged-<jdk_distribution>:<source_tag>-jdk<java>
# mcdreforged/mcdreforged-<jdk_distribution>:<source_tag>-jdk<java>-extra
on:
workflow_call:
inputs:
source_tag:
type: string
required: true

jobs:
extra:
uses: ./.github/workflows/image_one.yml
secrets: inherit
with:
dockerfile_name: Dockerfile-base
build_args: |-
BASE_IMAGE=mcdreforged/mcdreforged:${{ inputs.source_tag }}
image_name: mcdreforged/mcdreforged-extra
image_tags: ${{ inputs.source_tag }}

openjdk:
needs: extra
strategy:
matrix:
java: ['8', '11', '17', '21']
distribution: ['temurin', 'zulu', 'liberica']
extra: ['false', 'true']

uses: ./.github/workflows/image_one.yml
secrets: inherit
with:
dockerfile_name: Dockerfile-${{ matrix.distribution }}
build_args: |-
BASE_IMAGE=mcdreforged/${{ matrix.extra == 'true' && 'mcdreforged-extra' || 'mcdreforged' }}:${{ inputs.source_tag }}
JAVA=${{ matrix.java }}
image_name: mcdreforged/mcdreforged-${{ matrix.distribution }}
image_tags: |-
type=raw,value=${{ inputs.source_tag }},enable=${{ matrix.extra == 'false' && matrix.java == '17' }}
type=raw,value=${{ inputs.source_tag }}-extra,enable=${{ matrix.extra == 'true' && matrix.java == '17' }}
type=raw,value=${{ inputs.source_tag }}-jdk${{ matrix.java }},enable=${{ matrix.extra == 'false' }}
type=raw,value=${{ inputs.source_tag }}-jdk${{ matrix.java }}-extra,enable=${{ matrix.extra == 'true' }}
13 changes: 4 additions & 9 deletions .github/workflows/image_one.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
image_name:
type: string
required: true
tag_suffix:
image_tags:
type: string
required: true
outputs:
Expand Down Expand Up @@ -49,20 +49,15 @@ jobs:
uses: docker/metadata-action@v4
with:
images: ${{ inputs.image_name }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor:
suffix=${{ inputs.tag_suffix }},onlatest=false
tags: ${{ inputs.image_tags }}

- name: Build and push
id: build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
file: docker/${{ inputs.dockerfile_name }}
context: docker
file: src/${{ inputs.dockerfile_name }}
context: src
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,29 @@ Images with openjdk (`-extra` means with extra packages)

```bash
mcdreforged/mcdreforged-temurin:latest
mcdreforged/mcdreforged-temurin:latest-jdk17
mcdreforged/mcdreforged-temurin:latest-extra
mcdreforged/mcdreforged-temurin:latest-jdk17
mcdreforged/mcdreforged-temurin:latest-jdk17-extra
mcdreforged/mcdreforged-temurin:latest-slim
mcdreforged/mcdreforged-temurin:latest-slim-jdk17
mcdreforged/mcdreforged-temurin:latest-slim-extra
mcdreforged/mcdreforged-temurin:latest-slim-jdk17
mcdreforged/mcdreforged-temurin:latest-slim-jdk17-extra

mcdreforged/mcdreforged-temurin:2.13.0
mcdreforged/mcdreforged-temurin:2.13.0-extra
mcdreforged/mcdreforged-temurin:2.13.0-jdk17
mcdreforged/mcdreforged-temurin:2.13.0-jdk17-extra
mcdreforged/mcdreforged-temurin:2.13.0-slim
mcdreforged/mcdreforged-temurin:2.13.0-slim-extra
mcdreforged/mcdreforged-temurin:2.13.0-slim-jdk17
mcdreforged/mcdreforged-temurin:2.13.0-slim-jdk17-extra

mcdreforged/mcdreforged-temurin:2.13.0-py3.11
mcdreforged/mcdreforged-temurin:2.13.0-py3.11-jdk17
mcdreforged/mcdreforged-temurin:2.13.0-py3.11-slim
mcdreforged/mcdreforged-temurin:2.13.0-py3.11-slim-jdk17
mcdreforged/mcdreforged-temurin:2.13.0-py3.11-extra
mcdreforged/mcdreforged-temurin:2.13.0-py3.11-jdk17
mcdreforged/mcdreforged-temurin:2.13.0-py3.11-jdk17-extra
mcdreforged/mcdreforged-temurin:2.13.0-py3.11-slim
mcdreforged/mcdreforged-temurin:2.13.0-py3.11-slim-extra
mcdreforged/mcdreforged-temurin:2.13.0-py3.11-slim-jdk17
mcdreforged/mcdreforged-temurin:2.13.0-py3.11-slim-jdk17-extra
```
27 changes: 0 additions & 27 deletions build.sh

This file was deleted.

11 changes: 3 additions & 8 deletions src/Dockerfile-extra
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
ARG BASE_IMAGE_TAG
FROM mcdreforged/mcdreforged:${BASE_IMAGE_TAG}

ARG MCDR=latest
ARG SLIM=false
ARG FULL=false
ARG BASE_IMAGE
FROM ${BASE_IMAGE}

COPY requirements_common.txt /

# Python packages and and MCDR
RUN <<EOT
set -e
# disable the pip config temporary to install packages to the global storage
export PIP_CONFIG_FILE=/dev/null

pip freeze | grep mcdreforged >> /requirements_common.txt
pip3 install -r /requirements_common.txt
pip3 install mcdreforged==${MCDR_VERSION}

rm -f /requirements_common.txt
pip3 cache purge
Expand Down

0 comments on commit c77fe79

Please sign in to comment.