diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index aaa5c01..d5d0e0b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,6 @@ -on: push +on: + - push + - pull_request name: Lint check jobs: @@ -32,4 +34,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - run: cargo fmt -- --check \ No newline at end of file + - run: cargo fmt -- --check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6156872..6afa048 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: publish: - name: Publishing for ${{ matrix.job.os }} + name: Building ${{ matrix.job.target }} runs-on: ${{ matrix.job.os }} strategy: matrix: @@ -31,18 +31,18 @@ jobs: architecture: x86_64 binary-postfix: ".exe" use-cross: false -# - os: ubuntu-latest -# os-name: linux -# target: aarch64-unknown-linux-gnu -# architecture: arm64 -# binary-postfix: "" -# use-cross: true -# - os: ubuntu-latest -# os-name: linux -# target: i686-unknown-linux-gnu -# architecture: i686 -# binary-postfix: "" -# use-cross: true + - os: ubuntu-latest + os-name: linux-musl + target: x86_64-unknown-linux-musl + architecture: x86_64 + binary-postfix: "" + use-cross: true + - os: ubuntu-latest + os-name: linux + target: aarch64-unknown-linux-gnu + architecture: arm64 + binary-postfix: "" + use-cross: true steps: - name: Checkout repository @@ -124,4 +124,32 @@ jobs: context: . push: true file: deploy/Dockerfile - tags: s3rius/rustus:latest,s3rius/rustus:${{env.APP_VERSION}} \ No newline at end of file + tags: s3rius/rustus:latest,s3rius/rustus:${{env.APP_VERSION}} + + docker_build_alpine: + runs-on: ubuntu-latest + needs: + - publish + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Export version + run: echo "APP_VERSION=$(head -n 5 Cargo.toml | grep version | cut -d '"' -f2)" >> $GITHUB_ENV + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + file: deploy/alpine.Dockerfile + tags: s3rius/rustus:${{env.APP_VERSION}}-alpine + build-args: | + app_version=${{env.APP_VERSION}} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index f41f035..b1df24a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1846,6 +1846,15 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" +[[package]] +name = "openssl-src" +version = "111.17.0+1.1.1m" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d6a336abd10814198f66e2a91ccd7336611f30334119ca8ce300536666fcf4" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.72" @@ -1855,6 +1864,7 @@ dependencies = [ "autocfg 1.0.1", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -2455,7 +2465,7 @@ dependencies = [ [[package]] name = "rustus" -version = "0.1.0" +version = "0.2.0" dependencies = [ "actix-files", "actix-web", @@ -2471,6 +2481,7 @@ dependencies = [ "log", "mobc-lapin", "mobc-redis", + "openssl", "rbatis", "rbson", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index 074e674..a2e37c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,53 +1,110 @@ [package] name = "rustus" -version = "0.1.0" +version = "0.2.0" edition = "2021" description = "TUS protocol implementation written in Rust." -[profile.release] -lto = true -opt-level = "z" # Optimize for size. - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [[bin]] name = "rustus" [dependencies] -actix-web = { version = "^4.0.0-beta.15" } -actix-files = { version = "0.6.0-beta.13" } -tokio = { version = "1.4.0", features = ["time"] } -derive_more = { version = "^0.99.9", default-features = false, features = ["display", "from", "from_str"] } -thiserror = "^1.0" async-trait = "0.1.52" -structopt = { version = "^0.3" } -uuid = { version = "^1.0.0-alpha.1", features = ["v4"] } -async-std = { version = "^1.10.0", features = ["tokio1"] } +base64 = "^0.13.0" +lazy_static = "1.4.0" +log = "^0.4.14" serde = "1" -chrono = { version = "^0.4.19", features = ["serde"] } serde_json = "1" -log = "^0.4.14" -url = "2.2.2" -base64 = "^0.13.0" -fern = { version = "0.6.0", features = ["colored"] } strfmt = "^0.1.6" -lazy_static = "1.4.0" -strum = { version = "0.23", features = ["derive"] } -futures = { version = "^0.3.19", features = ["executor"] } -# Deps for info storages. -rbson = { version = "2.0", optional = true } -rbatis = { version = "^3.0", default-features = false, features = ["runtime-actix-rustls", "all-database"], optional = true } -mobc-redis = { version = "^0.7.0", optional = true } -# Deps for notifiers -lapin = { version = "^1.9.0", optional = true } -tokio-amqp = { version = "1.0.0", optional = true } -mobc-lapin = { version = "0.7.0", optional = true } -reqwest = { version = "^0.11.8", features = ["json"], optional = true } +thiserror = "^1.0" +url = "2.2.2" + +[dependencies.openssl] +version = "0.10.38" +features = ["vendored"] + +[dependencies.actix-files] +version = "0.6.0-beta.13" + +[dependencies.actix-web] +version = "^4.0.0-beta.15" + +[dependencies.async-std] +features = ["tokio1"] +version = "^1.10.0" + +[dependencies.chrono] +features = ["serde"] +version = "^0.4.19" + +[dependencies.derive_more] +default-features = false +features = ["display", "from", "from_str"] +version = "^0.99.9" + +[dependencies.fern] +features = ["colored"] +version = "0.6.0" + +[dependencies.futures] +features = ["executor"] +version = "^0.3.19" + +[dependencies.lapin] +optional = true +version = "^1.9.0" + +[dependencies.mobc-lapin] +optional = true +version = "0.7.0" + +[dependencies.mobc-redis] +optional = true +version = "^0.7.0" + +[dependencies.rbatis] +default-features = false +features = ["runtime-actix-rustls", "all-database"] +optional = true +version = "^3.0" + +[dependencies.rbson] +optional = true +version = "2.0" + +[dependencies.reqwest] +features = ["json"] +optional = true +version = "^0.11.8" + +[dependencies.structopt] +version = "^0.3" + +[dependencies.strum] +features = ["derive"] +version = "0.23" + +[dependencies.tokio] +features = ["time"] +version = "1.4.0" + +[dependencies.tokio-amqp] +optional = true +version = "1.0.0" + +[dependencies.uuid] +features = ["v4"] +version = "^1.0.0-alpha.1" [features] -default = [] all = ["redis_info_storage", "db_info_storage", "http_notifier", "amqp_notifier"] -redis_info_storage = ["mobc-redis"] -db_info_storage = ["rbatis", "rbson"] amqp_notifier = ["lapin", "tokio-amqp", "mobc-lapin"] +db_info_storage = ["rbatis", "rbson"] +default = [] +http_notifier = ["reqwest"] +redis_info_storage = ["mobc-redis"] -http_notifier = ["reqwest"] \ No newline at end of file +[profile] +[profile.release] +lto = true +opt-level = "z" +codegen-units = 1 \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6374165 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Pavel Kirilin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/deploy/alpine.Dockerfile b/deploy/alpine.Dockerfile new file mode 100644 index 0000000..be8e4df --- /dev/null +++ b/deploy/alpine.Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:3.15.0 + +ARG app_version + +ADD "https://github.com/s3rius/rustus/releases/download/${app_version}/rustus-${app_version}-linux-musl-x86_64.tar.gz" "." + +RUN tar xvf *.tar.gz +RUN rm *.tar.gz +RUN mv rustus /bin + +ENTRYPOINT ["/bin/rustus"] \ No newline at end of file