-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from pilksoc/ld-server-cicd
CICD: Game server pushes to github acr
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: "Build CosmicKube game server" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build-server: | ||
name: "Build Game Server" | ||
runs-on: ubuntu-20.04 | ||
permissions: | ||
packages: write | ||
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 | ||
|
||
|
||
- 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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 8000 | ||
|
||
CMD ["cosmic_kube"] |