feat(ci): add ci
This commit is contained in:
parent
a40b1498e2
commit
75f6f0b763
2 changed files with 48 additions and 0 deletions
22
.gitlab-ci.yml
Normal file
22
.gitlab-ci.yml
Normal file
|
|
@ -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
|
||||||
|
|
||||||
26
Dockerfile
Normal file
26
Dockerfile
Normal file
|
|
@ -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"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue