diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e3f6cab --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +target/ +.git/ +server/data/ +server/test.db/ diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml new file mode 100644 index 0000000..9094610 --- /dev/null +++ b/.woodpecker/build.yml @@ -0,0 +1,13 @@ +platform: 'linux/amd64' +branches: + exclude: [main] + +pipeline: + build: + image: 'rust:1.70-alpine3.18' + commands: + - apk add --no-cache build-base libarchive libarchive-dev + - cargo build --verbose + when: + event: [push] + diff --git a/.woodpecker/clippy.yml b/.woodpecker/clippy.yml new file mode 100644 index 0000000..5f4766c --- /dev/null +++ b/.woodpecker/clippy.yml @@ -0,0 +1,13 @@ +platform: 'linux/amd64' + +branches: + exclude: [main] + +pipeline: + clippy: + image: 'rust:1.70-alpine3.18' + commands: + - rustup component add clippy + - cargo clippy -- --no-deps -Dwarnings + when: + event: [push] diff --git a/.woodpecker/lint.yml b/.woodpecker/lint.yml new file mode 100644 index 0000000..82cca61 --- /dev/null +++ b/.woodpecker/lint.yml @@ -0,0 +1,13 @@ +platform: 'linux/amd64' + +branches: + exclude: [main] + +pipeline: + lint: + image: 'rust:1.70-alpine3.18' + commands: + - rustup component add rustfmt + - cargo fmt -- --check + when: + event: [push] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..df91d82 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,64 @@ +FROM rust:1.70-alpine3.18 AS builder + +ARG DI_VER=1.2.5 + +WORKDIR /app + +# RUN apk add --no-cache \ +# build-base \ +# curl \ +# make \ +# unzip \ +# pkgconf \ +# openssl openssl-libs-static openssl-dev \ +# libarchive-static libarchive-dev \ +# zlib-static zlib-dev \ +# bzip2-static bzip2-dev \ +# xz-static xz-dev \ +# expat-static expat-dev \ +# zstd-static zstd-dev \ +# lz4-static lz4-dev \ +# acl-static acl-dev +RUN apk add --no-cache \ + build-base \ + curl \ + make \ + unzip \ + pkgconf \ + libarchive libarchive-dev + +# Build dumb-init +RUN curl -Lo - "https://github.com/Yelp/dumb-init/archive/refs/tags/v${DI_VER}.tar.gz" | tar -xzf - && \ + cd "dumb-init-${DI_VER}" && \ + make SHELL=/bin/sh && \ + mv dumb-init .. && \ + cd .. + +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' + +RUN cargo build --release && \ + du -h target/release/rieterd && \ + readelf -d target/release/rieterd && \ + chmod +x target/release/rieterd + # [ "$(readelf -d target/debug/rieterd | grep NEEDED | wc -l)" = 0 ] && \ + # chmod +x target/debug/rieterd + + +FROM alpine:3.18 + +WORKDIR /app + +RUN apk add --no-cache \ + libarchive + +COPY --from=builder /app/dumb-init /bin/dumb-init +COPY --from=builder /app/target/debug/rieterd /bin/rieterd + +ENTRYPOINT ["/bin/dumb-init", "--"] +CMD ["/bin/rieterd"] diff --git a/server/Cargo.toml b/server/Cargo.toml index aeb0f48..68a7c6b 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -22,3 +22,9 @@ tower-http = { version = "0.4.1", features = ["fs", "trace"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } uuid = { version = "1.4.0", features = ["v4"] } + +[profile.release] +lto = "fat" +codegen-units = 1 +panic = "abort" +strip = true