Skip to content

Commit

Permalink
build them images
Browse files Browse the repository at this point in the history
  • Loading branch information
pschichtel committed Oct 2, 2023
1 parent 44fe22e commit fff5778
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 116 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea/
.git/
.gitignore
*-versions.jar
Dockerfile*
8 changes: 0 additions & 8 deletions .github/workflows/pushDocker.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# This is a basic workflow to help you get started with Actions

name: Build Image

# Controls when the action will run.
on:
push:
branches:
Expand All @@ -14,14 +11,9 @@ on:
- build-images.sh
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- name: Build and push
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
/tmp/
*.iml
*.iml
*.jar
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ RUN cd /tmp \

FROM $JAVA_BASE_IMAGE

ARG SPONGE_VERSION="1.16.5-8.2.0"
# "rc" or "release"
ARG SPONGE_TYPE="rc"
ENV MINECRAFT_DIR="/minecraft"

RUN addgroup -g 1000 "minecraft" && adduser -u 1000 -D -G "minecraft" -h "${MINECRAFT_DIR}" "minecraft"
Expand All @@ -32,7 +29,7 @@ ENV SPONGE_JAR="${MINECRAFT_DIR}/sponge.jar" \
# gettext: envsubst
RUN apk add --update --no-cache curl bash gettext

RUN curl -s -L -o "/sponge.jar" "https://repo.spongepowered.org/service/rest/v1/search/assets/download?sort=version&repository=maven-releases&maven.groupId=org.spongepowered&maven.artifactId=spongevanilla&maven.extension=jar&maven.classifier=universal&maven.baseVersion=${SPONGE_VERSION}"
COPY sponge.jar /sponge.jar

COPY --from=mcrcon /mcrcon /opt/mcrcon
COPY mcrcon.sh /usr/local/bin/mcrcon
Expand Down
100 changes: 0 additions & 100 deletions Dockerfile.local

This file was deleted.

26 changes: 23 additions & 3 deletions build-images.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
#!/usr/bin/env bash

set -euo pipefail

build_image() {
local kind="${1?no kind}"
local version="${2?no version}"
local asset="${3?no asset}"

local sponge_jar_file="sponge.jar"
local download_url="$(curl -s "https://dl-api.spongepowered.org/v2/groups/org.spongepowered/artifacts/spongevanilla/versions/$asset" | jq -r '.assets | map(select(.classifier == "universal")) | first | .downloadUrl')"
curl -s -L -o "$sponge_jar_file" "$download_url"

local repo_name="ghcr.io/cubeengine/sponge"
local cache_repo="${repo_name}/cache"
local image_name="${repo_name}:latest"
podman build -t "$image_name" --layers --cache-from="$cache_repo" --cache-to="$cache_repo" --timestamp 0 .
podman build \
-t "$image_name" \
--layers \
--cache-from="$cache_repo" \
--cache-to="$cache_repo" \
--timestamp 0 \
.
rm "$sponge_jar_file"

local tags=("$kind-$version" "$kind-$asset"
for t in "${tags}"
local tags=("$kind-$version" "$kind-$asset")
for t in "${tags[@]}"
do
local name="$repo_name:$t"
podman tag "$image_name" "$name"
Expand All @@ -22,7 +35,14 @@ build_image() {
build_images() {
local kind="${1?no kind}"

local file="$kind-versions.json"

readarray -t versions <<< "$(jq -r 'to_entries | map(.key) | .[]' < $file)"
for version in "${versions[@]}"
do
local asset="$(jq -r --arg version "$version" '.[$version]' < $file)"
build_image "$kind" "$version" "$asset"
done
}

build_images minecraft
Expand Down

0 comments on commit fff5778

Please sign in to comment.