diff --git a/.woodpecker/build-rel.yml b/.woodpecker/build-rel.yml new file mode 100644 index 0000000..b4b7067 --- /dev/null +++ b/.woodpecker/build-rel.yml @@ -0,0 +1,42 @@ +matrix: + PLATFORM: + - 'linux/amd64' + +platform: ${PLATFORM} + +when: + branch: [main, dev] + event: [push, tag] + +steps: + build: + image: 'git.rustybever.be/chewing_bever/rieter-builder:1.79-alpine3.19' + commands: + - cargo build --verbose --release + - '[ "$(readelf -d target/release/rieterd | grep NEEDED | wc -l)" = 0 ]' + + publish-dev: + image: 'git.rustybever.be/chewing_bever/rieter-builder:1.79-alpine3.19' + commands: + - apk add --no-cache minio-client + - mcli alias set rb 'https://s3.rustybever.be' "$MINIO_ACCESS_KEY" "$MINIO_SECRET_KEY" + - mcli cp target/release/rieterd "rb/rieter/commits/$CI_COMMIT_SHA/rieterd-$(echo '${PLATFORM}' | sed 's:/:-:g')" + secrets: + - minio_access_key + - minio_secret_key + when: + branch: dev + event: push + + publish-rel: + image: 'curlimages/curl' + commands: + - > + curl -s --fail + --user "Chewing_Bever:$GITEA_PASSWORD" + --upload-file target/release/rieterd + https://git.rustybever.be/api/packages/Chewing_Bever/generic/rieter/"${CI_COMMIT_TAG}"/rieterd-"$(echo '${PLATFORM}' | sed 's:/:-:g')" + secrets: + - gitea_password + when: + event: tag diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index e302f64..f179f00 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -2,7 +2,7 @@ platform: 'linux/amd64' when: branch: - exclude: [main] + exclude: [dev, main] event: push steps: diff --git a/.woodpecker/docker.yml b/.woodpecker/docker.yml index 0bcdf4a..214df4b 100644 --- a/.woodpecker/docker.yml +++ b/.woodpecker/docker.yml @@ -1,11 +1,11 @@ platform: 'linux/amd64' when: - branch: dev - event: push + branch: [main, dev] + event: [push, tag] depends_on: - - build + - build-rel steps: dev: @@ -19,4 +19,9 @@ steps: tags: - 'dev' platforms: [ 'linux/amd64' ] + build_args_from_env: + - 'CI_COMMIT_SHA' mtu: 1300 + when: + branch: dev + event: push diff --git a/Dockerfile b/Dockerfile index 88b51a8..24031b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,16 @@ -FROM rust:1.70-alpine3.18 AS builder +FROM git.rustybever.be/chewing_bever/rieter-builder:1.79-alpine3.19 AS builder +ARG TARGETPLATFORM +ARG CI_COMMIT_SHA ARG DI_VER=1.2.5 WORKDIR /app RUN apk add --no-cache \ - build-base \ curl \ make \ unzip \ - pkgconf \ - libarchive libarchive-dev + pkgconf # Build dumb-init RUN curl -Lo - "https://github.com/Yelp/dumb-init/archive/refs/tags/v${DI_VER}.tar.gz" | tar -xzf - && \ @@ -21,33 +21,16 @@ RUN curl -Lo - "https://github.com/Yelp/dumb-init/archive/refs/tags/v${DI_VER}.t COPY . . -# ENV LIBARCHIVE_STATIC=1 \ -# LIBARCHIVE_LIB_DIR=/usr/lib \ -# LIBARCHIVE_INCLUDE_DIR=/usr/include \ -# LIBARCHIVE_LDFLAGS='-lssl -lcrypto -L/lib -lz -lbz2 -llzma -lexpat -lzstd -llz4' - # LIBARCHIVE_LDFLAGS='-L/usr/lib -lz -lbz2 -llzma -lexpat -lzstd -llz4 -lsqlite3' - -# https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172 -ENV RUSTFLAGS='-C target-feature=-crt-static' - -RUN cargo build --release && \ - du -h target/release/rieterd && \ - readelf -d target/release/rieterd && \ - chmod +x target/release/rieterd +RUN curl \ + --fail \ + -o rieterd \ + "https://s3.rustybever.be/rieter/commits/${CI_COMMIT_SHA}/rieterd-$(echo "${TARGETPLATFORM}" | sed 's:/:-:g')" -FROM alpine:3.18 - -RUN apk add --no-cache \ - libgcc \ - libarchive \ - openssl +FROM alpine:3.19 COPY --from=builder /app/dumb-init /bin/dumb-init -COPY --from=builder /app/target/release/rieterd /bin/rieterd - -ENV RIETER_PKG_DIR=/data/pkgs \ - RIETER_DATA_DIR=/data +COPY --from=builder /app/rieterd /bin/rieterd WORKDIR /data