From 28f40dc87cb9c8f3890c9b37185e433dc118b1aa Mon Sep 17 00:00:00 2001 From: Leo Durrant Date: Sat, 2 Mar 2024 18:06:55 +0000 Subject: [PATCH 1/8] feat: added build game server --- .github/workflows/build-game-server.yml | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/build-game-server.yml diff --git a/.github/workflows/build-game-server.yml b/.github/workflows/build-game-server.yml new file mode 100644 index 0000000..ff8372a --- /dev/null +++ b/.github/workflows/build-game-server.yml @@ -0,0 +1,32 @@ +name: "Build CosmicKube game server" +on: + push: + branches: + - main + +jobs: + build-server: + name: "Build Game Server" + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + default: true + override: true + + - name: Build + run: | + cd backend + cargo build --all --release && strip target/release/cosmic_kube && mv target/release/cosmic_kube target/release/cosmic_kube_amd64 + + - name: Upload Artifact + uses: actions/upload-artifact@v1 + with: + name: server + path: backend/target/release/cosmic_kube_amd64 + \ No newline at end of file From 63fcb9a496fd3e85ea2388b160752f430568b54a Mon Sep 17 00:00:00 2001 From: Leo Durrant Date: Sat, 2 Mar 2024 18:09:28 +0000 Subject: [PATCH 2/8] feat: pushing on any branch for now --- .github/workflows/build-game-server.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build-game-server.yml b/.github/workflows/build-game-server.yml index ff8372a..71477ca 100644 --- a/.github/workflows/build-game-server.yml +++ b/.github/workflows/build-game-server.yml @@ -1,8 +1,5 @@ name: "Build CosmicKube game server" -on: - push: - branches: - - main +on: [push] jobs: build-server: From 09f5b854a425121a15c80323cbad10182f7bda25 Mon Sep 17 00:00:00 2001 From: Leo Durrant Date: Sat, 2 Mar 2024 20:49:19 +0000 Subject: [PATCH 3/8] feat: added server dockerfile for k8s --- server.Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 server.Dockerfile diff --git a/server.Dockerfile b/server.Dockerfile new file mode 100644 index 0000000..00deb71 --- /dev/null +++ b/server.Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:3.19.1 + +RUN apk update && apk add ca-certificates && apk cache clean +WORKDIR /usr/local/cosmic_kube +COPY backend/target/release/cosmic_kube_amd64 /usr/local/bin/cosmic_kube + +EXPOSE 443 + +CMD ["cosmic_kube"] \ No newline at end of file From 98329109026413ea6e075c80e226b0e252896472 Mon Sep 17 00:00:00 2001 From: Leo Durrant Date: Sat, 2 Mar 2024 20:49:36 +0000 Subject: [PATCH 4/8] feat: updated build file to build docker file --- .github/workflows/build-game-server.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-game-server.yml b/.github/workflows/build-game-server.yml index 71477ca..df5f0cc 100644 --- a/.github/workflows/build-game-server.yml +++ b/.github/workflows/build-game-server.yml @@ -26,4 +26,26 @@ jobs: with: name: server path: backend/target/release/cosmic_kube_amd64 - \ No newline at end of file + + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # this will push the docker images to the github container registry + # you will need to give actions permission to push there first + - name: Build and push + id: docker_build + uses: docker/build-push-action@v3 + with: + context: . + file: server.Dockerfile + push: true + tags: | + ghcr.io/pilksoc/CosmicKube:dev-latest + ghcr.io/pilksoc/CosmicKube:dev-${{ github.run_number }} \ No newline at end of file From 690090322083b405af4dff3c43206db2ef6de7a2 Mon Sep 17 00:00:00 2001 From: Leo Durrant Date: Sat, 2 Mar 2024 20:51:29 +0000 Subject: [PATCH 5/8] fix: tags for container --- .github/workflows/build-game-server.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-game-server.yml b/.github/workflows/build-game-server.yml index df5f0cc..51000e3 100644 --- a/.github/workflows/build-game-server.yml +++ b/.github/workflows/build-game-server.yml @@ -47,5 +47,5 @@ jobs: file: server.Dockerfile push: true tags: | - ghcr.io/pilksoc/CosmicKube:dev-latest - ghcr.io/pilksoc/CosmicKube:dev-${{ github.run_number }} \ No newline at end of file + ghcr.io/pilksoc/cosmickube:dev-latest + ghcr.io/pilksoc/cosmickube:dev-${{ github.run_number }} \ No newline at end of file From a1019741a8b7d1a43672219881b4af1f7809896a Mon Sep 17 00:00:00 2001 From: Leo Durrant Date: Sat, 2 Mar 2024 21:02:07 +0000 Subject: [PATCH 6/8] fix: added permissions for packages --- .github/workflows/build-game-server.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-game-server.yml b/.github/workflows/build-game-server.yml index 51000e3..755e574 100644 --- a/.github/workflows/build-game-server.yml +++ b/.github/workflows/build-game-server.yml @@ -5,6 +5,8 @@ jobs: build-server: name: "Build Game Server" runs-on: ubuntu-20.04 + permissions: + packages: write steps: - name: Checkout uses: actions/checkout@v4 From 64c64d232245f9500bc7a190030e7b3588f8bb64 Mon Sep 17 00:00:00 2001 From: Leo Durrant Date: Sun, 3 Mar 2024 00:01:31 +0000 Subject: [PATCH 7/8] feat: push on main --- .github/workflows/build-game-server.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-game-server.yml b/.github/workflows/build-game-server.yml index 755e574..d97d216 100644 --- a/.github/workflows/build-game-server.yml +++ b/.github/workflows/build-game-server.yml @@ -1,6 +1,8 @@ name: "Build CosmicKube game server" -on: [push] - +on: + push: + branches: + - main jobs: build-server: name: "Build Game Server" From af4fd7e9a42ca2bdead84da968c658401694e198 Mon Sep 17 00:00:00 2001 From: Leo Durrant Date: Sun, 3 Mar 2024 00:06:10 +0000 Subject: [PATCH 8/8] fix: server port --- server.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.Dockerfile b/server.Dockerfile index 00deb71..4d39d78 100644 --- a/server.Dockerfile +++ b/server.Dockerfile @@ -4,6 +4,6 @@ RUN apk update && apk add ca-certificates && apk cache clean WORKDIR /usr/local/cosmic_kube COPY backend/target/release/cosmic_kube_amd64 /usr/local/bin/cosmic_kube -EXPOSE 443 +EXPOSE 8000 CMD ["cosmic_kube"] \ No newline at end of file