diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2f96273..945bbf7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,28 +1,10 @@ variables: DOCKER_HOST: tcp://docker:2375 -bin: +docker: + image: docker:20 stage: build needs: [] - image: rust:alpine - cache: - - key: - files: - - Cargo.toml - - Cargo.lock - paths: - - vendor/ - script: - - mkdir ~/.cargo && mv config/cargo.toml ~/.cargo/config.toml - - cargo vendor - - cargo build --release - artifacts: - paths: - - target/release/stream-proxy - -build: - image: docker:20 - stage: deploy services: - name: docker:20-dind command: ["--experimental"] @@ -36,4 +18,21 @@ build: - docker context create mybuilder - docker buildx create --use --name mybuilder mybuilder - docker pull $CI_REGISTRY_IMAGE:latest || true - - docker buildx build --cache-from $CI_REGISTRY_IMAGE:latest --platform linux/amd64 --push -t $CI_REGISTRY_IMAGE:latest . \ No newline at end of file + - docker buildx build --cache-from $CI_REGISTRY_IMAGE:latest --platform linux/amd64 --push -t $CI_REGISTRY_IMAGE:latest . + - docker run --rm $CI_REGISTRY_IMAGE:latest cat /app/stream-proxy > stream-proxy + artifacts: + paths: + - stream-proxy + +deploy: + image: alpine:latest + stage: deploy + needs: + - docker + before_script: + - apk update && apk --no-cache add curl git + - wget -O - https://fly.io/install.sh | sh + - git clone https://codeberg.org/video-prize-ranch/fly-cfg + - cd fly-cfg/librarian + script: + - /root/.fly/bin/flyctl deploy --no-cache --detach \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 674da84..ae0a9ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,21 @@ -FROM rust:alpine AS build - +FROM lukemathwalker/cargo-chef:latest-rust-alpine AS chef WORKDIR /src -RUN apk --no-cache add musl-dev git ca-certificates -RUN git clone https://codeberg.org/librarian/stream-proxy . -RUN mkdir ~/.cargo && mv config/cargo.toml ~/.cargo/config.toml -RUN cargo vendor -RUN cargo build --release +FROM chef AS planner +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef AS builder +COPY --from=planner /src/recipe.json recipe.json +RUN cargo chef cook --release --recipe-path recipe.json +COPY . . +ENV CARGO_INCREMENTAL=0 +RUN cargo build --release --bin stream-proxy FROM alpine:latest as bin WORKDIR /app -COPY --from=build /src/target/release/stream-proxy . +COPY --from=builder /src/target/release/stream-proxy . EXPOSE 3001 diff --git a/config/cargo.toml b/config/cargo.toml deleted file mode 100644 index a476f35..0000000 --- a/config/cargo.toml +++ /dev/null @@ -1,5 +0,0 @@ -[source.crates-io] -replace-with = "vendored-sources" - -[source.vendored-sources] -directory = "vendor" \ No newline at end of file