はじめてのRust。Webアプリを作ってコンテナ化するところまでのメモ。
Rustのインストール
brew install rust
Webアプリの作成
Web FrameworkとしてActixを使用する。
Getting Startedを参考にHello Worldアプリを作成する。
雛形作成。
cargo new hello-rust
cd hello-rust
actix-webの追加。
echo 'actix-web = "4"' >> Cargo.toml
アプリケーションコードの追加。
cat <<EOF > src/main.rs
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
}
#[post("/echo")]
async fn echo(req_body: String) -> impl Responder {
HttpResponse::Ok().body(req_body)
}
async fn manual_hello() -> impl Responder {
HttpResponse::Ok().body("Hey there!")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(hello)
.service(echo)
.route("/hey", web::get().to(manual_hello))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
EOF
ビルド。
cargo build
実行。特にログは出ない。
./target/debug/hello-rust
動作確認。
$ curl localhost:8080
Hello world!
$ curl localhost:8080/echo -d 'Hello'
Hello
$ curl localhost:8080/hey
Hey there!
Buildpackでコンテナイメージ作成
Cloud Native Buildpacksを使い、pack
コマンドでコンテナイメージを作成する。
target以下がイメージに含まれないようにproject.toml
を作成。
cat <<EOF > project.toml
[build]
exclude = [
"/target"
]
EOF
Rust BuildpackはPaketo標準のBuilderに含まれていないので、--buildpack
で追加する必要がある。
Rustでビルドされたアプリはnative imageなのでtiny builderでビルドできるはず。
$ pack build hello-rust --buildpack docker.io/paketocommunity/rust --builder paketobuildpacks/builder:tiny
tiny: Pulling from paketobuildpacks/builder
Digest: sha256:3a189b8c05bdaffdbc7d5bdc3f0bf433fda36d76f4021ec7786bb0ef0b05bcb5
Status: Image is up to date for paketobuildpacks/builder:tiny
tiny-cnb: Pulling from paketobuildpacks/run
Digest: sha256:6b063a620413a678c4cf1c3ba1daf50951d25d6dd7961e84de373acf3b864197
Status: Image is up to date for paketobuildpacks/run:tiny-cnb
latest: Pulling from paketocommunity/rust
Digest: sha256:e3d15911deb569c190721d6ee6630b71e7c35ad3cd6f5068764d55707d770db8
Status: Image is up to date for paketocommunity/rust:latest
Previous image with name "hello-rust" not found
===> DETECTING
4 of 5 buildpacks participating
paketo-community/rustup 1.6.0
paketo-community/rust-dist 1.9.0
paketo-buildpacks/syft 1.16.0
paketo-community/cargo 0.7.0
===> RESTORING
===> BUILDING
Paketo Rustup Buildpack 1.6.0
https://github.com/paketo-community/rustup
Build Configuration:
$BP_RUSTUP_ENABLED true use rustup to install Rust
$BP_RUSTUP_INIT_LIBC gnu libc implementation: gnu or musl
$BP_RUSTUP_INIT_VERSION 1 the rustup version
$BP_RUST_PROFILE minimal the Rust profile to install
$BP_RUST_TARGET an additional Rust target to install
$BP_RUST_TOOLCHAIN stable the Rust toolchain or version number to install
Rustup (GNU libc) 1.25.1: Contributing to layer
Downloading from https://static.rust-lang.org/rustup/archive/1.25.1/x86_64-unknown-linux-gnu/rustup-init
Verifying checksum
Copying to /layers/paketo-community_rustup/rustup-init-gnu/bin
Cargo: Contributing to layer
Rustup: Contributing to layer
Installing Rustup
Rust: Contributing to layer
Installing Rust
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2022-08-11, rust version 1.63.0 (4b91a6ea7 2022-08-08)
info: downloading component 'cargo'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: installing component 'cargo'
info: installing component 'rust-std'
info: installing component 'rustc'
stable-x86_64-unknown-linux-gnu installed - rustc 1.63.0 (4b91a6ea7 2022-08-08)
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
info: checking for self-updates
info: downloading component 'rust-std' for 'x86_64-unknown-linux-musl'
info: installing component 'rust-std' for 'x86_64-unknown-linux-musl'
Rust Distribution Buildpack 1.9.0
https://github.com/paketo-community/rust-dist
Paketo Syft Buildpack 1.16.0
https://github.com/paketo-buildpacks/syft
Downloading from https://github.com/anchore/syft/releases/download/v0.53.4/syft_0.53.4_linux_amd64.tar.gz
Verifying checksum
Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
Rust Cargo Build Pack 0.7.0
https://github.com/paketo-community/cargo
Build Configuration:
$BP_CARGO_INSTALL_ARGS --locked additional arguments to pass to Cargo install
$BP_CARGO_INSTALL_TOOLS additional tools to be add with Cargo install
$BP_CARGO_INSTALL_TOOLS_ARGS additional arguments to pass to Cargo install for tools
$BP_CARGO_TINI_DISABLED false Skip installing tini
$BP_CARGO_WORKSPACE_MEMBERS the subset of workspace members for Cargo to install
$BP_DISABLE_SBOM false Skip running SBOM scan
$BP_EXCLUDE_FILES colon separated list of glob patterns, matched source files are removed
$BP_INCLUDE_FILES static/*:templates/*:public/*:html/* colon separated list of glob patterns, matched source files are included
Tini 0.19.0: Contributing to layer
Downloading from https://github.com/krallin/tini/releases/download/v0.19.0/tini-amd64
Verifying checksum
Copying to /layers/paketo-community_cargo/tini
Creating cached target directory /workspace/target
Rust Application: Contributing to layer
File modification times not restored
File modification times not restored
File modification times not restored
cargo install --locked --color=never --root=/layers/paketo-community_cargo/Cargo --path=. --target=x86_64-unknown-linux-musl
Installing hello-rust v0.1.0 (/workspace)
Updating crates.io index
Downloading crates ...
Downloaded actix-service v2.0.2
Downloaded actix-rt v2.7.0
Downloaded actix-macros v0.2.3
Downloaded actix-utils v3.0.0
Downloaded alloc-stdlib v0.2.2
Downloaded actix-web-codegen v4.1.0
Downloaded flate2 v1.0.24
Downloaded alloc-no-stdlib v2.0.4
Downloaded firestorm v0.5.1
Downloaded actix-http v3.2.2
Downloaded cookie v0.16.0
Downloaded ahash v0.7.6
Downloaded paste v1.0.9
Downloaded local-channel v0.1.3
Downloaded num_threads v0.1.6
Downloaded local-waker v0.1.3
Downloaded miniz_oxide v0.5.4
Downloaded actix-router v0.5.0
Downloaded actix-codec v0.5.0
Downloaded language-tags v0.3.2
Downloaded actix-web v4.2.1
Downloaded time-macros v0.2.4
Downloaded sha1 v0.10.4
Downloaded jobserver v0.1.24
Downloaded regex-syntax v0.6.27
Downloaded aho-corasick v0.7.19
Downloaded bytestring v1.1.0
Downloaded actix-server v2.1.1
Downloaded semver v1.0.13
Downloaded regex v1.6.0
Downloaded time v0.3.14
Downloaded zstd-safe v5.0.2+zstd.1.5.2
Downloaded zstd-sys v2.0.1+zstd.1.5.2
Downloaded crypto-common v0.1.6
Downloaded convert_case v0.4.0
Downloaded bytes v1.2.1
Downloaded fnv v1.0.7
Downloaded indexmap v1.9.1
Downloaded base64 v0.13.0
Downloaded futures-util v0.3.24
Downloaded hashbrown v0.12.3
Downloaded brotli-decompressor v2.3.2
Downloaded block-buffer v0.10.3
Downloaded bitflags v1.3.2
Downloaded digest v0.10.3
Downloaded crc32fast v1.3.2
Downloaded rand v0.8.5
Downloaded cfg-if v1.0.0
Downloaded httparse v1.8.0
Downloaded futures-core v0.3.24
Downloaded cpufeatures v0.2.5
Downloaded zstd v0.11.2+zstd.1.5.2
Downloaded httpdate v1.0.2
Downloaded log v0.4.17
Downloaded itoa v1.0.3
Downloaded getrandom v0.2.7
Downloaded smallvec v1.9.0
Downloaded parking_lot v0.12.1
Downloaded mio v0.8.4
Downloaded h2 v0.3.14
Downloaded once_cell v1.14.0
Downloaded cc v1.0.73
Downloaded syn v1.0.99
Downloaded http v0.2.8
Downloaded tracing-core v0.1.29
Downloaded pin-utils v0.1.0
Downloaded percent-encoding v2.2.0
Downloaded rand_chacha v0.3.1
Downloaded slab v0.4.7
Downloaded num_cpus v1.13.1
Downloaded serde v1.0.144
Downloaded socket2 v0.4.7
Downloaded proc-macro2 v1.0.43
Downloaded ppv-lite86 v0.2.16
Downloaded pin-project-lite v0.2.9
Downloaded serde_urlencoded v0.7.1
Downloaded rustc_version v0.4.0
Downloaded scopeguard v1.1.0
Downloaded mime v0.3.16
Downloaded serde_json v1.0.85
Downloaded memchr v2.5.0
Downloaded version_check v0.9.4
Downloaded parking_lot_core v0.9.3
Downloaded quote v1.0.21
Downloaded tracing v0.1.36
Downloaded tinyvec v1.6.0
Downloaded lock_api v0.4.8
Downloaded unicode-normalization v0.1.21
Downloaded unicode-bidi v0.3.8
Downloaded tinyvec_macros v0.1.0
Downloaded url v2.3.1
Downloaded rand_core v0.6.3
Downloaded adler v1.0.2
Downloaded unicode-ident v1.0.3
Downloaded ryu v1.0.11
Downloaded tokio-util v0.7.4
Downloaded idna v0.3.0
Downloaded form_urlencoded v1.1.0
Downloaded derive_more v0.99.17
Downloaded generic-array v0.14.6
Downloaded futures-task v0.3.24
Downloaded futures-sink v0.3.24
Downloaded signal-hook-registry v1.4.0
Downloaded autocfg v1.1.0
Downloaded typenum v1.15.0
Downloaded libc v0.2.132
Downloaded tokio v1.21.1
Downloaded encoding_rs v0.8.31
Downloaded brotli v3.3.4
Compiling libc v0.2.132
Compiling cfg-if v1.0.0
Compiling autocfg v1.1.0
Compiling memchr v2.5.0
Compiling log v0.4.17
Compiling version_check v0.9.4
Compiling pin-project-lite v0.2.9
Compiling futures-core v0.3.24
Compiling parking_lot_core v0.9.3
Compiling bytes v1.2.1
Compiling once_cell v1.14.0
Compiling smallvec v1.9.0
Compiling serde v1.0.144
Compiling scopeguard v1.1.0
Compiling proc-macro2 v1.0.43
Compiling typenum v1.15.0
Compiling itoa v1.0.3
Compiling futures-task v0.3.24
Compiling unicode-ident v1.0.3
Compiling quote v1.0.21
Compiling syn v1.0.99
Compiling futures-util v0.3.24
Compiling futures-sink v0.3.24
Compiling percent-encoding v2.2.0
Compiling pin-utils v0.1.0
Compiling alloc-no-stdlib v2.0.4
Compiling zstd-safe v5.0.2+zstd.1.5.2
Compiling crc32fast v1.3.2
Compiling fnv v1.0.7
Compiling tinyvec_macros v0.1.0
Compiling local-waker v0.1.3
Compiling hashbrown v0.12.3
Compiling ppv-lite86 v0.2.16
Compiling adler v1.0.2
Compiling paste v1.0.9
Compiling encoding_rs v0.8.31
Compiling regex-syntax v0.6.27
Compiling httparse v1.8.0
Compiling time-macros v0.2.4
Compiling serde_json v1.0.85
Compiling cpufeatures v0.2.5
Compiling firestorm v0.5.1
Compiling num_threads v0.1.6
Compiling ryu v1.0.11
Compiling unicode-bidi v0.3.8
Compiling bitflags v1.3.2
Compiling convert_case v0.4.0
Compiling base64 v0.13.0
Compiling mime v0.3.16
Compiling httpdate v1.0.2
Compiling language-tags v0.3.2
Compiling generic-array v0.14.6
Compiling ahash v0.7.6
Compiling cookie v0.16.0
Compiling tracing-core v0.1.29
Compiling lock_api v0.4.8
Compiling tokio v1.21.1
Compiling indexmap v1.9.1
Compiling slab v0.4.7
Compiling bytestring v1.1.0
Compiling form_urlencoded v1.1.0
Compiling alloc-stdlib v0.2.2
Compiling http v0.2.8
Compiling tinyvec v1.6.0
Compiling actix-utils v3.0.0
Compiling miniz_oxide v0.5.4
Compiling brotli-decompressor v2.3.2
Compiling unicode-normalization v0.1.21
Compiling actix-service v2.0.2
Compiling tracing v0.1.36
Compiling aho-corasick v0.7.19
Compiling socket2 v0.4.7
Compiling mio v0.8.4
Compiling signal-hook-registry v1.4.0
Compiling getrandom v0.2.7
Compiling num_cpus v1.13.1
Compiling time v0.3.14
Compiling jobserver v0.1.24
Compiling flate2 v1.0.24
Compiling brotli v3.3.4
Compiling idna v0.3.0
Compiling regex v1.6.0
Compiling serde_urlencoded v0.7.1
Compiling rand_core v0.6.3
Compiling cc v1.0.73
Compiling parking_lot v0.12.1
Compiling crypto-common v0.1.6
Compiling block-buffer v0.10.3
Compiling url v2.3.1
Compiling actix-router v0.5.0
Compiling local-channel v0.1.3
Compiling rand_chacha v0.3.1
Compiling zstd-sys v2.0.1+zstd.1.5.2
Compiling digest v0.10.3
Compiling rand v0.8.5
Compiling sha1 v0.10.4
error: failed to run custom build command for `zstd-sys v2.0.1+zstd.1.5.2`
Caused by:
process didn't exit successfully: `/workspace/target/release/build/zstd-sys-f1d67e3669a7d423/build-script-build` (exit status: 1)
--- stdout
TARGET = Some("x86_64-unknown-linux-musl")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-unknown-linux-musl = None
CC_x86_64_unknown_linux_musl = None
TARGET_CC = None
CC = None
CROSS_COMPILE = None
CFLAGS_x86_64-unknown-linux-musl = None
CFLAGS_x86_64_unknown_linux_musl = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
running: "musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-I" "zstd/lib/legacy" "-fvisibility=hidden" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZDICTLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-DZSTD_LEGACY_SUPPORT=1" "-o" "/workspace/target/x86_64-unknown-linux-musl/release/build/zstd-sys-3bf5b290af77d41b/out/zstd/lib/common/threading.o" "-c" "zstd/lib/common/threading.c"
running: "musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-I" "zstd/lib/legacy" "-fvisibility=hidden" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZDICTLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-DZSTD_LEGACY_SUPPORT=1" "-o" "/workspace/target/x86_64-unknown-linux-musl/release/build/zstd-sys-3bf5b290af77d41b/out/zstd/lib/common/error_private.o" "-c" "zstd/lib/common/error_private.c"
--- stderr
error occurred: Failed to find tool. Is `musl-gcc` installed?
warning: build failed, waiting for other jobs to finish...
error: failed to compile `hello-rust v0.1.0 (/workspace)`, intermediate artifacts can be found at `/workspace/target`
unable to invoke layer creator
unable to contribute application layer
unable to install single
unable to build
exit status 101
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51
error occurred: Failed to find tool. Is
musl-gcc installed?
というエラーが発生した。
このアプリでは依存ライブラリにzstd-sys v2.0.1+zstd.1.5.2
が含まれており、これをコンパイルするのに musl-gcc
が必要だけれど、tiny builderに含まれるstackにはこのパッケージが含まれていない。
ということで、base builderに変更して再ビルド。
$ pack build hello-rust --buildpack docker.io/paketocommunity/rust --builder paketobuildpacks/builder:base
base: Pulling from paketobuildpacks/builder
Digest: sha256:bc472ab18b177c3258e1dfa25c4f1472cd012eae4521b41ca330198f81b71d38
Status: Image is up to date for paketobuildpacks/builder:base
base-cnb: Pulling from paketobuildpacks/run
Digest: sha256:cfc9b596bedc7bead1b3714a69dffa1fb17fcb1f7bba5c3faadb40c0b6f5acbd
Status: Image is up to date for paketobuildpacks/run:base-cnb
latest: Pulling from paketocommunity/rust
Digest: sha256:e3d15911deb569c190721d6ee6630b71e7c35ad3cd6f5068764d55707d770db8
Status: Image is up to date for paketocommunity/rust:latest
Previous image with name "hello-rust" not found
===> DETECTING
4 of 5 buildpacks participating
paketo-community/rustup 1.6.0
paketo-community/rust-dist 1.9.0
paketo-buildpacks/syft 1.16.0
paketo-community/cargo 0.7.0
===> RESTORING
===> BUILDING
Paketo Rustup Buildpack 1.6.0
https://github.com/paketo-community/rustup
Build Configuration:
$BP_RUSTUP_ENABLED true use rustup to install Rust
$BP_RUSTUP_INIT_LIBC gnu libc implementation: gnu or musl
$BP_RUSTUP_INIT_VERSION 1 the rustup version
$BP_RUST_PROFILE minimal the Rust profile to install
$BP_RUST_TARGET an additional Rust target to install
$BP_RUST_TOOLCHAIN stable the Rust toolchain or version number to install
Rustup (GNU libc) 1.25.1: Contributing to layer
Downloading from https://static.rust-lang.org/rustup/archive/1.25.1/x86_64-unknown-linux-gnu/rustup-init
Verifying checksum
Copying to /layers/paketo-community_rustup/rustup-init-gnu/bin
Cargo: Contributing to layer
Rustup: Contributing to layer
Installing Rustup
Rust: Contributing to layer
Installing Rust
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2022-08-11, rust version 1.63.0 (4b91a6ea7 2022-08-08)
info: downloading component 'cargo'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: installing component 'cargo'
info: installing component 'rust-std'
info: installing component 'rustc'
stable-x86_64-unknown-linux-gnu installed - rustc 1.63.0 (4b91a6ea7 2022-08-08)
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
info: checking for self-updates
info: component 'rust-std' for target 'x86_64-unknown-linux-gnu' is up to date
Rust Distribution Buildpack 1.9.0
https://github.com/paketo-community/rust-dist
Paketo Syft Buildpack 1.16.0
https://github.com/paketo-buildpacks/syft
Downloading from https://github.com/anchore/syft/releases/download/v0.53.4/syft_0.53.4_linux_amd64.tar.gz
Verifying checksum
Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
Rust Cargo Build Pack 0.7.0
https://github.com/paketo-community/cargo
Build Configuration:
$BP_CARGO_INSTALL_ARGS --locked additional arguments to pass to Cargo install
$BP_CARGO_INSTALL_TOOLS additional tools to be add with Cargo install
$BP_CARGO_INSTALL_TOOLS_ARGS additional arguments to pass to Cargo install for tools
$BP_CARGO_TINI_DISABLED false Skip installing tini
$BP_CARGO_WORKSPACE_MEMBERS the subset of workspace members for Cargo to install
$BP_DISABLE_SBOM false Skip running SBOM scan
$BP_EXCLUDE_FILES colon separated list of glob patterns, matched source files are removed
$BP_INCLUDE_FILES static/*:templates/*:public/*:html/* colon separated list of glob patterns, matched source files are included
Tini 0.19.0: Contributing to layer
Downloading from https://github.com/krallin/tini/releases/download/v0.19.0/tini-amd64
Verifying checksum
Copying to /layers/paketo-community_cargo/tini
Creating cached target directory /workspace/target
Rust Application: Contributing to layer
File modification times not restored
File modification times not restored
File modification times not restored
cargo install --locked --color=never --root=/layers/paketo-community_cargo/Cargo --path=.
Installing hello-rust v0.1.0 (/workspace)
Updating crates.io index
Downloading crates ...
Downloaded percent-encoding v2.2.0
Downloaded base64 v0.13.0
Downloaded rand_chacha v0.3.1
Downloaded rand_core v0.6.3
Downloaded serde_urlencoded v0.7.1
Downloaded ryu v1.0.11
Downloaded tinyvec v1.6.0
Downloaded socket2 v0.4.7
Downloaded time-macros v0.2.4
Downloaded time v0.3.14
Downloaded slab v0.4.7
Downloaded scopeguard v1.1.0
Downloaded rustc_version v0.4.0
Downloaded bytestring v1.1.0
Downloaded syn v1.0.99
Downloaded bitflags v1.3.2
Downloaded alloc-stdlib v0.2.2
Downloaded alloc-no-stdlib v2.0.4
Downloaded ahash v0.7.6
Downloaded actix-web v4.2.1
Downloaded cookie v0.16.0
Downloaded quote v1.0.21
Downloaded memchr v2.5.0
Downloaded crc32fast v1.3.2
Downloaded flate2 v1.0.24
Downloaded futures-core v0.3.24
Downloaded tokio-util v0.7.4
Downloaded convert_case v0.4.0
Downloaded autocfg v1.1.0
Downloaded adler v1.0.2
Downloaded cpufeatures v0.2.5
Downloaded tracing v0.1.36
Downloaded form_urlencoded v1.1.0
Downloaded crypto-common v0.1.6
Downloaded aho-corasick v0.7.19
Downloaded futures-task v0.3.24
Downloaded futures-sink v0.3.24
Downloaded digest v0.10.3
Downloaded fnv v1.0.7
Downloaded cc v1.0.73
Downloaded bytes v1.2.1
Downloaded cfg-if v1.0.0
Downloaded generic-array v0.14.6
Downloaded futures-util v0.3.24
Downloaded h2 v0.3.14
Downloaded getrandom v0.2.7
Downloaded paste v1.0.9
Downloaded actix-macros v0.2.3
Downloaded actix-codec v0.5.0
Downloaded actix-router v0.5.0
Downloaded actix-utils v3.0.0
Downloaded lock_api v0.4.8
Downloaded actix-http v3.2.2
Downloaded derive_more v0.99.17
Downloaded brotli-decompressor v2.3.2
Downloaded httpdate v1.0.2
Downloaded pin-utils v0.1.0
Downloaded num_threads v0.1.6
Downloaded num_cpus v1.13.1
Downloaded once_cell v1.14.0
Downloaded mime v0.3.16
Downloaded block-buffer v0.10.3
Downloaded parking_lot_core v0.9.3
Downloaded ppv-lite86 v0.2.16
Downloaded typenum v1.15.0
Downloaded proc-macro2 v1.0.43
Downloaded parking_lot v0.12.1
Downloaded serde v1.0.144
Downloaded unicode-bidi v0.3.8
Downloaded http v0.2.8
Downloaded mio v0.8.4
Downloaded pin-project-lite v0.2.9
Downloaded rand v0.8.5
Downloaded zstd-safe v5.0.2+zstd.1.5.2
Downloaded unicode-normalization v0.1.21
Downloaded hashbrown v0.12.3
Downloaded serde_json v1.0.85
Downloaded regex-syntax v0.6.27
Downloaded zstd v0.11.2+zstd.1.5.2
Downloaded actix-server v2.1.1
Downloaded actix-web-codegen v4.1.0
Downloaded language-tags v0.3.2
Downloaded httparse v1.8.0
Downloaded firestorm v0.5.1
Downloaded idna v0.3.0
Downloaded url v2.3.1
Downloaded miniz_oxide v0.5.4
Downloaded sha1 v0.10.4
Downloaded actix-service v2.0.2
Downloaded local-channel v0.1.3
Downloaded local-waker v0.1.3
Downloaded actix-rt v2.7.0
Downloaded jobserver v0.1.24
Downloaded regex v1.6.0
Downloaded tracing-core v0.1.29
Downloaded unicode-ident v1.0.3
Downloaded indexmap v1.9.1
Downloaded semver v1.0.13
Downloaded itoa v1.0.3
Downloaded log v0.4.17
Downloaded signal-hook-registry v1.4.0
Downloaded smallvec v1.9.0
Downloaded tinyvec_macros v0.1.0
Downloaded version_check v0.9.4
Downloaded zstd-sys v2.0.1+zstd.1.5.2
Downloaded libc v0.2.132
Downloaded tokio v1.21.1
Downloaded encoding_rs v0.8.31
Downloaded brotli v3.3.4
Compiling libc v0.2.132
Compiling cfg-if v1.0.0
Compiling autocfg v1.1.0
Compiling memchr v2.5.0
Compiling log v0.4.17
Compiling version_check v0.9.4
Compiling pin-project-lite v0.2.9
Compiling futures-core v0.3.24
Compiling once_cell v1.14.0
Compiling bytes v1.2.1
Compiling parking_lot_core v0.9.3
Compiling smallvec v1.9.0
Compiling serde v1.0.144
Compiling scopeguard v1.1.0
Compiling proc-macro2 v1.0.43
Compiling typenum v1.15.0
Compiling itoa v1.0.3
Compiling quote v1.0.21
Compiling futures-task v0.3.24
Compiling unicode-ident v1.0.3
Compiling futures-util v0.3.24
Compiling syn v1.0.99
Compiling pin-utils v0.1.0
Compiling futures-sink v0.3.24
Compiling percent-encoding v2.2.0
Compiling local-waker v0.1.3
Compiling zstd-safe v5.0.2+zstd.1.5.2
Compiling tinyvec_macros v0.1.0
Compiling crc32fast v1.3.2
Compiling alloc-no-stdlib v2.0.4
Compiling fnv v1.0.7
Compiling paste v1.0.9
Compiling adler v1.0.2
Compiling ppv-lite86 v0.2.16
Compiling regex-syntax v0.6.27
Compiling encoding_rs v0.8.31
Compiling httparse v1.8.0
Compiling hashbrown v0.12.3
Compiling serde_json v1.0.85
Compiling cpufeatures v0.2.5
Compiling time-macros v0.2.4
Compiling bitflags v1.3.2
Compiling num_threads v0.1.6
Compiling firestorm v0.5.1
Compiling convert_case v0.4.0
Compiling unicode-bidi v0.3.8
Compiling ryu v1.0.11
Compiling language-tags v0.3.2
Compiling httpdate v1.0.2
Compiling mime v0.3.16
Compiling base64 v0.13.0
Compiling tracing-core v0.1.29
Compiling generic-array v0.14.6
Compiling ahash v0.7.6
Compiling cookie v0.16.0
Compiling bytestring v1.1.0
Compiling lock_api v0.4.8
Compiling tokio v1.21.1
Compiling indexmap v1.9.1
Compiling slab v0.4.7
Compiling actix-utils v3.0.0
Compiling form_urlencoded v1.1.0
Compiling tinyvec v1.6.0
Compiling alloc-stdlib v0.2.2
Compiling http v0.2.8
Compiling miniz_oxide v0.5.4
Compiling brotli-decompressor v2.3.2
Compiling tracing v0.1.36
Compiling actix-service v2.0.2
Compiling unicode-normalization v0.1.21
Compiling aho-corasick v0.7.19
Compiling socket2 v0.4.7
Compiling signal-hook-registry v1.4.0
Compiling mio v0.8.4
Compiling getrandom v0.2.7
Compiling time v0.3.14
Compiling num_cpus v1.13.1
Compiling jobserver v0.1.24
Compiling flate2 v1.0.24
Compiling brotli v3.3.4
Compiling idna v0.3.0
Compiling regex v1.6.0
Compiling serde_urlencoded v0.7.1
Compiling rand_core v0.6.3
Compiling cc v1.0.73
Compiling parking_lot v0.12.1
Compiling crypto-common v0.1.6
Compiling block-buffer v0.10.3
Compiling url v2.3.1
Compiling actix-router v0.5.0
Compiling local-channel v0.1.3
Compiling rand_chacha v0.3.1
Compiling zstd-sys v2.0.1+zstd.1.5.2
Compiling digest v0.10.3
Compiling rand v0.8.5
Compiling sha1 v0.10.4
Compiling tokio-util v0.7.4
Compiling actix-rt v2.7.0
Compiling derive_more v0.99.17
Compiling actix-web-codegen v4.1.0
Compiling actix-macros v0.2.3
Compiling actix-server v2.1.1
Compiling actix-codec v0.5.0
Compiling h2 v0.3.14
Compiling zstd v0.11.2+zstd.1.5.2
Compiling actix-http v3.2.2
Compiling actix-web v4.2.1
Compiling hello-rust v0.1.0 (/workspace)
Finished release [optimized] target(s) in 1m 38s
Installing /layers/paketo-community_cargo/Cargo/bin/hello-rust
Installed package `hello-rust v0.1.0 (/workspace)` (executable `hello-rust`)
Removing source code
===> EXPORTING
Adding layer 'paketo-community/cargo:Cargo'
Adding layer 'paketo-community/cargo:tini'
Adding layer 'launch.sbom'
Adding 1/1 app layer(s)
Adding layer 'launcher'
Adding layer 'config'
Adding layer 'process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Setting default process type 'hello-rust'
Saving hello-rust...
*** Images (7915948682dc):
hello-rust
Adding cache layer 'paketo-community/rustup:Cargo'
Adding cache layer 'paketo-community/rustup:Rust'
Adding cache layer 'paketo-community/rustup:Rustup'
Adding cache layer 'paketo-community/rustup:rustup-init-gnu'
Adding cache layer 'paketo-buildpacks/syft:syft'
Adding cache layer 'paketo-community/cargo:Cargo'
Adding cache layer 'paketo-community/cargo:Cargo Cache'
Adding cache layer 'cache.sbom'
Successfully built image hello-rust
今回はビルドが成功。
コンテナイメージを実行する。
docker run --rm -p 8080:8080 hello-rust
動作確認。
$ curl localhost:8080
Hello world!
$ curl localhost:8080/echo -d 'Hello'
Hello
$ curl localhost:8080/hey
Hey there!
できた。
最終的なソースコードはこちら