Skip to content

Commit

Permalink
chore: Use multi-stage docker build to reuse keepup download logic
Browse files Browse the repository at this point in the history
chore: Bump keepup, use new configs feature
  • Loading branch information
0ffz committed May 28, 2024
1 parent 60e936b commit 8782260
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 104 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/publish-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ jobs:
strategy:
matrix:
include:
- image: minecraft
- target: minecraft
dockerfile: minecraft.Dockerfile
platforms: linux/amd64,linux/arm64
- image: proxy
- target: proxy
dockerfile: proxy.Dockerfile
platforms: linux/amd64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up QEMU for multi-platform support
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug

Expand All @@ -46,13 +46,14 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/mineinabyss/${{ matrix.image }}
images: ${{ env.REGISTRY }}/mineinabyss/${{ matrix.target }}

- name: Build and push ${{ matrix.image }}
uses: docker/build-push-action@v3
- name: Build and push ${{ matrix.target }}
uses: docker/build-push-action@v5
with:
file: ${{ matrix.dockerfile }}
platforms: ${{ matrix.platforms }}
push: true
target: ${{ matrix.target }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
61 changes: 41 additions & 20 deletions minecraft.Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
# Environment: Java
# Minimum Panel Version: 0.6.0
# ----------------------------------
FROM itzg/minecraft-server:java21-alpine
LABEL org.opencontainers.image.authors="Offz <[email protected]>"

RUN apk add --no-cache ansible-core rclone wget unzip jq openssh
FROM alpine as helper
ARG KEEPUP_VERSION='3.0.0-alpha.1'
RUN wget -nv -q -O keepup.zip https://github.com/MineInAbyss/Keepup/releases/download/v${KEEPUP_VERSION}/keepup-shadow-${KEEPUP_VERSION}.zip \
# unzip file inside hocon-to-json.zip into /usr/local \
&& unzip -q keepup.zip \
&& mv keepup-shadow-${KEEPUP_VERSION}/ keepup
# Install YourKit Java Profiler agents
#RUN wget -q https://www.yourkit.com/download/docker/YourKit-JavaProfiler-2023.9-docker.zip -P /tmp/ && \
# unzip /tmp/YourKit-JavaProfiler-2023.9-docker.zip -d /usr/local && \

ARG KEEPUP_VERSION=2.0.2

FROM itzg/minecraft-server:java21-alpine as minecraft
LABEL org.opencontainers.image.authors="Offz <[email protected]>"
RUN apk add --no-cache ansible-core rclone wget unzip jq openssh
COPY --from=helper /keepup /usr/local
ENV\
KEEPUP=true\
KEEPUP_ALLOW_OVERRIDES=true\
Expand All @@ -20,24 +28,37 @@ ENV\
HOME=/data\
ANSIBLE_CONFIG=/server-config/ansible.cfg

WORKDIR /opt/minecraft
# Install ansible collections
COPY config/ansible-requirements.yml /opt/ansible/requirements.yml
RUN ansible-galaxy collection install -r /opt/ansible/requirements.yml -p /opt/ansible/collections \
&& rm /opt/ansible/requirements.yml

# Install YourKit Java Profiler agents
#RUN wget -q https://www.yourkit.com/download/docker/YourKit-JavaProfiler-2023.9-docker.zip -P /tmp/ && \
# unzip /tmp/YourKit-JavaProfiler-2023.9-docker.zip -d /usr/local && \
# rm /tmp/YourKit-JavaProfiler-2023.9-docker.zip
# Copy over scripts
COPY scripts/dev /scripts/dev
RUN chmod +x /scripts/dev/*

# Install keepup
RUN wget -nv -q -O keepup.zip https://github.com/MineInAbyss/Keepup/releases/download/v${KEEPUP_VERSION}/keepup-shadow-${KEEPUP_VERSION}.zip \
# unzip file inside hocon-to-json.zip into /usr/local \
&& unzip -q keepup.zip \
&& rclone copy keepup-shadow-${KEEPUP_VERSION}/ /usr/local \
&& chmod +x /usr/local/bin/keepup \
&& rm -rf keepup.zip keepup-shadow-${KEEPUP_VERSION}
WORKDIR $HOME
ENTRYPOINT ["/scripts/dev/entrypoint"]

# Install ansible collections
COPY config/ansible-requirements.yml /opt/ansible/requirements.yml

FROM itzg/bungeecord as proxy
LABEL org.opencontainers.image.authors="Offz <[email protected]>"
RUN apt-get update -y \
&& apt-get install -y rsync rclone wget unzip git pipx python3-venv jq
COPY --from=helper /keepup /usr/local
ENV\
KEEPUP=true\
KEEPUP_ALLOW_OVERRIDES=true\
ANSIBLE=true\
ANSIBLE_PULL=true\
ANSIBLE_PULL_BRANCH=master\
SERVER_NAME=dev\
HOME=/server\
ANSIBLE_CONFIG=/server-config/ansible.cfg

# Install ansible & collections
RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install ansible-core
COPY config/ansible-requirements.yml /opt/ansible/requirements.yml
RUN ansible-galaxy collection install -r /opt/ansible/requirements.yml -p /opt/ansible/collections \
&& rm /opt/ansible/requirements.yml

Expand All @@ -46,5 +67,5 @@ COPY scripts/dev /scripts/dev
RUN chmod +x /scripts/dev/*

WORKDIR $HOME

RUN cp /usr/bin/run-bungeecord.sh /start
ENTRYPOINT ["/scripts/dev/entrypoint"]
50 changes: 0 additions & 50 deletions proxy.Dockerfile

This file was deleted.

31 changes: 5 additions & 26 deletions scripts/dev/keepup
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,18 @@ keepupDir=$HOME/keepupDir
keepupDownloadsDir=$keepupDir/downloads
keepupOverridesFile=$keepupDir/overrides.conf
pluginsDir=$HOME/plugins
pluginVersionsFile=/server-config/servers/plugin-versions.conf
configSource=/server-config/
pluginVersionsFile=/server-config/keepup/plugins.conf

mkdir -p "$keepupDir"
mkdir -p "$keepupDownloadsDir"
mkdir -p "$pluginsDir"

if [ "$KEEPUP" = "true" ]; then
echo "Keepup enabled"

if [ "$KEEPUP_ALLOW_OVERRIDES" = "true" ]; then
if [ ! -f "$keepupOverridesFile" ]; then
echo "Creating default keepup overrides file"
touch "$keepupOverridesFile"
fi

if [ ! -f "$pluginVersionsFile" ]; then
echo "Plugin versions file not found at $pluginVersionsFile, skipping keepup"
return
fi


if [ -z "$KEEPUP_JSON_PATH" ]; then
export KEEPUP_JSON_PATH=mineinabyss.servers.${SERVER_NAME}
fi

echo "Running keepup with overrides"
cat $pluginVersionsFile $keepupOverridesFile 2>/dev/null\
| keepup - $keepupDownloadsDir $pluginsDir --hide-progress-bar
else
echo "Running keepup without overrides"
keepup $pluginVersionsFile\
$keepupDownloadsDir $pluginsDir --hide-progress-bar
fi
keepup plugins $pluginVersionsFile $keepupDownloadsDir $pluginsDir --hide-progress-bar \
config --source $configSource --dest $HOME --inventory $keepupDir/keepup-configs.yml --template-cache $keepupDir/templates survival
# fi
else
echo "KEEPUP is not set to 'true', not running keepup"
fi

0 comments on commit 8782260

Please sign in to comment.