diff --git a/.env b/.env new file mode 100644 index 0000000..8eeaf35 --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +# options: stable, unstable +TERASOLOGY_BUILD=stable +# options: latest or any release tag +TERASOLOGY_TAG=latest diff --git a/.github/workflows/dockerpublish.yml b/.github/workflows/dockerpublish.yml index bb56242..b6f8242 100644 --- a/.github/workflows/dockerpublish.yml +++ b/.github/workflows/dockerpublish.yml @@ -56,7 +56,7 @@ jobs: - name: Push image run: | IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME - + # Change all uppercase to lowercase IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') @@ -71,16 +71,15 @@ jobs: echo IMAGE_ID=$IMAGE_ID echo VERSION=$VERSION - + rm versionInfo.properties* || true if [ " ${TERASOLOGY_PROPERTIES_URL}" == " " ]; then if [ " ${TERASOLOGY_BUILD}" == " " ]; then - source .env - TERASOLOGY_PROPERTIES_URL=http://jenkins.terasology.org/job/TerasologyStable/lastSuccessfulBuild/artifact/build/resources/main/org/terasology/version/versionInfo.properties + TERASOLOGY_PROPERTIES_URL=http://jenkins.terasology.org/job/TerasologyStable/lastSuccessfulBuild/artifact/build/resources/main/org/terasology/version/versionInfo.properties else if [ " ${TERASOLOGY_BUILD}" == " unstable" ]; then - TERASOLOGY_PROPERTIES_URL=http://jenkins.terasology.org/job/Terasology/lastSuccessfulBuild/artifact/build/resources/main/org/terasology/version/versionInfo.properties + TERASOLOGY_PROPERTIES_URL=http://jenkins.terasology.org/job/Terasology/lastSuccessfulBuild/artifact/build/resources/main/org/terasology/version/versionInfo.properties fi fi fi diff --git a/Dockerfile b/Dockerfile index 88dc0fa..c333e3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,27 @@ FROM ubuntu:18.04 MAINTAINER Marcel Otte -RUN apt-get update && apt-get install -y openjdk-11-jre wget unzip + +ARG TERASOLOGY_OMEGA_URL +ARG TERASOLOGY_BUILD + +RUN apt-get update \ + && apt-get install -y openjdk-11-jre wget unzip \ + && apt-get clean \ + && rm -rf /var/cache/apt/archives \ + && rm -rf /var/lib/apt/lists/* + RUN mkdir /terasology \ - && wget -P /terasology http://jenkins.terasology.org/job/DistroOmegaRelease/lastSuccessfulBuild/artifact/distros/omega/build/distributions/TerasologyOmega.zip \ + if [ " ${TERASOLOGY_OMEGA_URL}" == " " ]; then \ + if [ " ${TERASOLOGY_BUILD}" == " stable" ]; then \ + TERASOLOGY_OMEGA_URL=http://jenkins.terasology.org/job/DistroOmegaRelease/lastSuccessfulBuild/artifact/distros/omega/build/distributions/TerasologyOmega.zip \ + else \ + TERASOLOGY_OMEGA_URL=http://jenkins.terasology.org/job/DistroOmega/lastSuccessfulBuild/artifact/distros/omega/build/distributions/TerasologyOmega.zip \ + fi \ + fi \ + && wget -P /terasology ${TERASOLOGY_OMEGA_URL} \ && unzip /terasology/TerasologyOmega.zip -d /terasology \ && rm -f /terasology/TerasologyOmega.zip + ENTRYPOINT cd /terasology && java -jar /terasology/libs/Terasology.jar -headless -homedir=/terasology/server VOLUME /terasology/server EXPOSE 25777 diff --git a/build.sh b/build.sh index c64e01b..0c45ee2 100755 --- a/build.sh +++ b/build.sh @@ -2,19 +2,32 @@ rm versionInfo.properties* -wget http://jenkins.terasology.org/job/TerasologyStable/lastSuccessfulBuild/artifact/build/resources/main/org/terasology/version/versionInfo.properties + +if [ " ${TERASOLOGY_PROPERTIES_URL}" == " " ]; then + if [ " ${TERASOLOGY_BUILD}" == " " ]; then + source .env + TERASOLOGY_PROPERTIES_URL=http://jenkins.terasology.org/job/TerasologyStable/lastSuccessfulBuild/artifact/build/resources/main/org/terasology/version/versionInfo.properties + else + if [ " ${TERASOLOGY_BUILD}" == " unstable" ]; then + TERASOLOGY_PROPERTIES_URL=http://jenkins.terasology.org/job/Terasology/lastSuccessfulBuild/artifact/build/resources/main/org/terasology/version/versionInfo.properties + fi + fi +fi + +wget ${TERASOLOGY_PROPERTIES_URL} source versionInfo.properties - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD +# docker login -u $DOCKER_USER -p $DOCKER_PASSWORD TAGNAME=$engineVersion-$displayVersion docker build --no-cache -t qwick/terasology:$TAGNAME . -NEW_TAGNAME=latest - -docker tag qwick/terasology:$TAGNAME qwick/terasology:$NEW_TAGNAME - docker push qwick/terasology:$TAGNAME -docker push qwick/terasology:$NEW_TAGNAME +if [ " ${TERASOLOGY_TAG}" == " latest" ]; then + NEW_TAGNAME=latest + docker tag qwick/terasology:$TAGNAME qwick/terasology:$NEW_TAGNAME + + docker push qwick/terasology:$NEW_TAGNAME +fi diff --git a/docker-compose.yml b/docker-compose.yml index e83e708..f55d59c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,9 @@ -version: '2' +version: '3.7' services: terasology: - image: qwick/terasology:latest + build: + context: . + image: "qwick/terasology:${TERASOLOGY_TAG}" ports: - 25777:25777 volumes: