From 235f1dfd6b65c9bf4f4031a2d09634fce2ac5c1d Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Thu, 6 Mar 2025 09:50:48 +0100 Subject: [PATCH] feat(ci): introduce ci --- .gitlab-ci.yml | 21 +++++++++++++++++++++ Dockerfile | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d1908a2 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,21 @@ +image: docker:latest + +variables: + IMAGE_NAME: "ci.perditum.com/perditum/rnex-splatoon" + IMAGE_TAG: "${CI_COMMIT_REF_SLUG}" + +before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" ci.perditum.com + +stages: + - build-and-push + +build-and-push: + stage: build-and-push + script: + - docker build -t "$IMAGE_NAME:$IMAGE_TAG" . + - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$IMAGE_NAME:latest" + - docker push "$IMAGE_NAME:$IMAGE_TAG" + - docker push "$IMAGE_NAME:latest" + only: + - main diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..55951b3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM rust:1.85 AS builder + +WORKDIR /app + +COPY . . + +RUN cargo build --release + +FROM rust:1.85 AS final + +WORKDIR /app + +# Copy the compiled binary from the builder stage +COPY --from=builder /app/target/release/splatoon-server-rust /app/splatoon-server-rust + +# Set executable permissions +RUN chmod +x /app/splatoon-server-rust + +# Command to run the application +CMD ["/app/splatoon-server-rust"]