From 6188a9a38ff6ae663d63872774b0789a56490d28 Mon Sep 17 00:00:00 2001 From: foxikle Date: Mon, 17 Jun 2024 21:31:03 -0400 Subject: [PATCH 1/2] Dockering --- .github/workflows/docker.yml | 44 ++++++++++++++++++++++++++++++++++++ build.gradle.kts | 4 +++- docker/basic/Dockerfile | 14 ++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker.yml create mode 100644 docker/basic/Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..8efc6fe2 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,44 @@ +name: Build and push Docker Image +run-name: Deploy Docker image to GHCR by @${{ github.actor }} + +env: + GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + env: + GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '21' + + # - run: chmod +x gradlew + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Assemble Jar + run: ./gradlew -Dorg.gradle.jvmargs=--enable-preview assemble + env: + REPO_USERNAME: ${{ secrets.REPO_USERNAME }} + REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }} + + - name: Build Docker Image + run: | + docker build -t cytosis -f docker/basic/Dockerfile . + + - name: Push Docker Image + run: | + docker login ghcr.io -u CytonicMC -p $GHCR_TOKEN + docker push ghcr.io/CytonicMC/cytosis:latest + diff --git a/build.gradle.kts b/build.gradle.kts index 8f20ddb6..0b6a7b9e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,7 +62,9 @@ tasks { archiveFileName.set("cytosis.jar") archiveClassifier.set("") destinationDirectory.set( - file(providers.gradleProperty("server_dir").orElse(destinationDirectory.get().toString())) + file( + providers.gradleProperty("server_dir").orElse(destinationDirectory.get().toString()) + ) ) } } diff --git a/docker/basic/Dockerfile b/docker/basic/Dockerfile new file mode 100644 index 00000000..c0d88d99 --- /dev/null +++ b/docker/basic/Dockerfile @@ -0,0 +1,14 @@ +FROM eclipse-temurin:21-jre-jammy +LABEL authors="CytonicMC" + +# Set the working directory +WORKDIR /app + +# Copy cytosis Jar +COPY ../../build/libs/cytosis.jar . + +# Expose the port +EXPOSE 25565 + +# Run the java +CMD ["java", "-DSERVER_PORT=25565", "-jar", "--enable-preview", "cytosis.jar"] \ No newline at end of file From dfe115de89f54a70db29c4369a6b0ffa7f6cd3ce Mon Sep 17 00:00:00 2001 From: foxikle Date: Mon, 17 Jun 2024 21:38:38 -0400 Subject: [PATCH 2/2] update workflow file --- .github/workflows/docker.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8efc6fe2..d7afba7c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -34,11 +34,14 @@ jobs: REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }} - name: Build Docker Image - run: | - docker build -t cytosis -f docker/basic/Dockerfile . + run: docker build -t cytosis -f docker/basic/Dockerfile . + + - name: Tag Docker Image + run: docker tag cytosis ghcr.io/cytonicmc/cytosis:latest + + - name: Login to GHCR + run: echo $GHCR_TOKEN | docker login ghcr.io -u CytonicMC --password-stdin - name: Push Docker Image - run: | - docker login ghcr.io -u CytonicMC -p $GHCR_TOKEN - docker push ghcr.io/CytonicMC/cytosis:latest + run: docker push ghcr.io/cytonicmc/cytosis:latest