Skip to content

Commit 179bb26

Browse files
authored
build: add alpine support to matrix builds (#1349)
1 parent 1458329 commit 179bb26

File tree

13 files changed

+126
-338
lines changed

13 files changed

+126
-338
lines changed

.github/workflows/build-multiarch.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,69 @@ on:
1313

1414
jobs:
1515
build:
16-
if: github.repository == 'itzg/docker-minecraft-server'
1716
strategy:
1817
fail-fast: false
1918
matrix:
2019
variant:
2120
- java17
2221
- java17-openj9
22+
- java17-alpine
23+
- java8
2324
- java8-multiarch
2425
- java8-openj9
2526
- java11
2627
- java11-openj9
2728
include:
2829
- variant: java17
2930
baseImage: eclipse-temurin:17
30-
tagPrefix: java17-
3131
platforms: linux/amd64,linux/arm/v7,linux/arm64
3232
mcVersion: LATEST
3333
- variant: java17-openj9
3434
baseImage: ibm-semeru-runtimes:open-17-jdk
35-
tagPrefix: java17-openj9-
3635
platforms: linux/amd64,linux/arm64
3736
mcVersion: LATEST
37+
- variant: java17-alpine
38+
baseImage: eclipse-temurin:17-jdk-alpine
39+
platforms: linux/amd64
40+
mcVersion: LATEST
41+
- variant: java8
42+
baseImage: openjdk:8-jdk-alpine3.8
43+
platforms: linux/amd64
44+
mcVersion: 1.12.2
3845
- variant: java8-multiarch
3946
baseImage: eclipse-temurin:8-jdk
40-
tagPrefix: java8-
4147
platforms: linux/amd64,linux/arm64
4248
mcVersion: 1.12.2
4349
- variant: java8-openj9
4450
baseImage: ibm-semeru-runtimes:open-8-jdk
45-
tagPrefix: java8-openj9-
4651
platforms: linux/amd64,linux/arm64
4752
mcVersion: 1.12.2
4853
- variant: java11
4954
baseImage: adoptopenjdk:11-jdk-hotspot
50-
tagPrefix: java11-
5155
platforms: linux/amd64,linux/arm/v7,linux/arm64
5256
mcVersion: 1.16.5
5357
- variant: java11-openj9
5458
baseImage: ibm-semeru-runtimes:open-11-jdk
55-
tagPrefix: java11-openj9-
5659
platforms: linux/amd64,linux/arm64
5760
mcVersion: 1.16.5
5861
env:
59-
IMAGE_TO_TEST: itzg/minecraft-server:test-${{ matrix.variant }}-${{ github.run_id }}
62+
IMAGE_TO_TEST: ${{ github.repository_owner }}/minecraft-server:test-${{ matrix.variant }}-${{ github.run_id }}
6063
runs-on: ubuntu-20.04
6164
steps:
6265
- name: Checkout
6366
uses: actions/[email protected]
67+
with:
68+
# for build-files step
69+
fetch-depth: 0
6470

6571
- name: Docker meta
6672
id: meta
6773
uses: docker/metadata-action@v3
6874
with:
75+
# NOTE for forks: if your Docker Hub organization doesn't match your Github repo's,
76+
# then the use of ${{ github.repository_owner }} will need to be replaced.
6977
images: |
70-
itzg/minecraft-server
78+
${{ github.repository_owner }}/minecraft-server
7179
tags: |
7280
type=ref,event=tag,enable=${{ matrix.variant == 'java17' }}
7381
type=ref,event=tag,suffix=-${{ matrix.variant }}
@@ -89,6 +97,11 @@ jobs:
8997
username: ${{ secrets.DOCKER_USER }}
9098
password: ${{ secrets.DOCKER_PASSWORD }}
9199

100+
- name: Calculate build files revision
101+
id: build-files
102+
run: |
103+
echo "::set-output name=REV::$(git log -1 --format=%H build)"
104+
92105
- name: Build for test
93106
uses: docker/[email protected]
94107
with:
@@ -101,6 +114,7 @@ jobs:
101114
push: false
102115
build-args: |
103116
BASE_IMAGE=${{ matrix.baseImage }}
117+
BUILD_FILES_REV=${{ steps.build-files.outputs.REV }}
104118
cache-from: type=gha,scope=${{ matrix.variant }}
105119
# no cache-to to avoid cross-cache update from next build step
106120

@@ -122,5 +136,6 @@ jobs:
122136
labels: ${{ steps.meta.outputs.labels }}
123137
build-args: |
124138
BASE_IMAGE=${{ matrix.baseImage }}
139+
BUILD_FILES_REV=${{ steps.build-files-rev.outputs.REV }}
125140
cache-from: type=gha,scope=${{ matrix.variant }}
126141
cache-to: type=gha,mode=max,scope=${{ matrix.variant }}

.github/workflows/main.yml

Lines changed: 0 additions & 97 deletions
This file was deleted.

DEVELOPMENT.md

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -83,57 +83,10 @@ Note the port that was selected by http-server and pass the build arguments, suc
8383

8484
Now the image can be built like normal and it will install mc-image-helper from the locally built copy.
8585

86-
## Multi-base-image variants
87-
88-
Several base-image variants are maintained in order to offer choices in JDK provider and version. The variants are maintained in their respective branches:
89-
- openj9
90-
- openj9-nightly
91-
- adopt11
92-
- adopt13
93-
- multiarch
94-
95-
The [docker-versions-create.sh](docker-versions-create.sh) script is configured with the branches to maintain and is used to merge changes from the master branch into the mulit-base variant branches. The script also manages git tagging the master branch along with the merged branches. So a typical use of the script would be like:
96-
97-
```shell script
98-
./docker-versions-create.sh -s -t 1.2.0
99-
```
100-
101-
> Most often the major version will be bumped unless a bug or hotfix needs to be published in which case the patch version should be incremented.
102-
103-
> The build and publishing of those branches and their tags is currently performed within Docker Hub.
104-
105-
## multiarch support
106-
107-
The [multiarch branch](https://github.com/itzg/docker-minecraft-server/tree/multiarch) supports running the image on amd64, arm64, and armv7 (aka RaspberryPi). Unlike the mainline branches, it is based on Ubuntu 18.04 since the openjdk package provided by Ubuntu includes full JIT support on all of the processor types.
108-
109-
The multiarch images are built and published by [a Github action](https://github.com/itzg/docker-minecraft-server/actions?query=workflow%3A%22Build+and+publish+multiarch%22), which [is configured in that branch](https://github.com/itzg/docker-minecraft-server/blob/multiarch/.github/workflows/build-multiarch.yml).
110-
11186
## Generating release notes
11287

11388
The following git command can be used to provide the bulk of release notes content:
11489

11590
```shell script
11691
git log --invert-grep --grep "^ci:" --grep "^misc:" --grep "^docs:" --pretty="* %s" 1.1.0..1.2.0
11792
```
118-
## Tracking changes from master without content
119-
120-
The following script uses the [ours](https://git-scm.com/docs/merge-strategies#Documentation/merge-strategies.txt-ours) merging strategy to track the history from master into the other branches without actually bringing the changes over. It is useful when a change is specific to master only, such as bumping the base Java version for the `latest` image tag.
121-
122-
```shell
123-
branches=(
124-
java8
125-
java8-multiarch
126-
java8-openj9
127-
java11
128-
java11-openj9
129-
java16
130-
java16-openj9
131-
java17
132-
)
133-
134-
for b in "${branches[@]}"; do
135-
git checkout "$b"
136-
git merge -s ours -m "Track latest from master" master
137-
git push origin
138-
done
139-
```

Dockerfile

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
1+
# syntax = docker/dockerfile:1.3
2+
13
ARG BASE_IMAGE=eclipse-temurin:17-jdk
24
FROM ${BASE_IMAGE}
35

4-
RUN apt-get update \
5-
&& DEBIAN_FRONTEND=noninteractive \
6-
apt-get install -y \
7-
imagemagick \
8-
file \
9-
gosu \
10-
sudo \
11-
net-tools \
12-
iputils-ping \
13-
curl \
14-
git \
15-
jq \
16-
dos2unix \
17-
mysql-client \
18-
tzdata \
19-
rsync \
20-
nano \
21-
unzip \
22-
zstd \
23-
knockd \
24-
ttf-dejavu \
25-
&& apt-get clean
26-
27-
RUN addgroup --gid 1000 minecraft \
28-
&& adduser --system --shell /bin/false --uid 1000 --ingroup minecraft --home /data minecraft
6+
# CI system should set this to a hash or git revision of the build directory and it's contents to
7+
# ensure consistent cache updates.
8+
ARG BUILD_FILES_REV=1
9+
RUN --mount=target=/build,source=build \
10+
REV=${BUILD_FILES_REV} /build/run.sh install-packages
11+
12+
RUN --mount=target=/build,source=build \
13+
REV=${BUILD_FILES_REV} /build/run.sh setup-user
2914

3015
COPY --chmod=644 files/sudoers* /etc/sudoers.d
3116

build/alpine/install-packages.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
apk add --no-cache -U \
6+
openssl \
7+
imagemagick \
8+
file \
9+
lsof \
10+
su-exec \
11+
coreutils \
12+
findutils \
13+
shadow \
14+
bash \
15+
curl iputils \
16+
git \
17+
jq \
18+
mysql-client \
19+
tzdata \
20+
rsync \
21+
nano \
22+
sudo \
23+
knock \
24+
ttf-dejavu \
25+
tar \
26+
zstd

build/alpine/setup-user.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
addgroup -g 1000 minecraft
6+
adduser -Ss /bin/false -u 1000 -G minecraft -h /home/minecraft minecraft

build/run.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
distro=$(cat /etc/os-release | grep -E "^ID=" | cut -d= -f2 | sed -e 's/"//g')
6+
7+
"$(dirname "$0")/${distro}/$1".sh

build/ubuntu/install-packages.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
apt-get update
6+
7+
DEBIAN_FRONTEND=noninteractive \
8+
apt-get install -y \
9+
imagemagick \
10+
file \
11+
gosu \
12+
sudo \
13+
net-tools \
14+
iputils-ping \
15+
curl \
16+
git \
17+
jq \
18+
dos2unix \
19+
mysql-client \
20+
tzdata \
21+
rsync \
22+
nano \
23+
unzip \
24+
zstd \
25+
knockd \
26+
ttf-dejavu
27+
28+
apt-get clean

build/ubuntu/setup-user.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
addgroup --gid 1000 minecraft
6+
adduser --system --shell /bin/false --uid 1000 --ingroup minecraft --home /data minecraft

0 commit comments

Comments
 (0)