diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a29e649 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,22 @@ +image: docker:latest + +variables: + IMAGE_NAME: "ci.perditum.com/perditum/account" + 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: + - master + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6fc6d9d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM rust:1.85 as builder + +WORKDIR /app + +# this looks like being stupid, but docker cache is FIRE once you do this +COPY Cargo.toml Cargo.lock ./ +RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo fetch + +# there's the beauty +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/account /app/account + +# Set executable permissions +RUN chmod +x /app/eshop-rs + +# Command to run the application +CMD ["ls /app"] +CMD ["/app/account"]