Skip to content

Commit

Permalink
fix: add wizer cmd in server image
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitea committed Mar 17, 2024
1 parent f6fab7d commit f27d686
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/wit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ fn find_cmd(cmd: &str) -> Result<PathBuf> {
let c = match which::which(cmd) {
Ok(c) => c,
Err(_) => {
// find wasm-opt binary in current exe directroy ./wasm-opt-bin/wasm
// find xxx binary in current exe directroy ./xxx/xxx
let exe_path = std::env::current_exe()?;
let file = exe_path
.parent()
.unwrap()
.join(format!("{}-bin/{}", cmd, cmd));
.join(format!("{}/{}", cmd, cmd));

#[cfg(target_os = "windows")]
let file = file.with_extension("exe");
Expand Down
42 changes: 42 additions & 0 deletions deploy/deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

# Print in colors - 1=green, 2=red, other=neutral
# e.g. log_print 0 "All is great"
log_print() {
if [[ $1 == 1 ]]; then
echo -e "${GREEN}${2}${NC}"
elif [[ $1 == 2 ]]; then
echo -e "${RED}${2}${NC}"
else
echo -e "${2}"
fi
}

set -e
set -o pipefail

# Function used to check if utilities are available
require() {
if ! hash "$1" &>/dev/null; then
log_print 2 "'$1' not found in PATH. This is required for this script to work."
exit 1
fi
}

require curl
require tar

download_wizer_binary() {
log_print 0 "Downloading wizer"
local archive_url="https://github.com/bytecodealliance/wizer/releases/download/v5.0.0/wizer-v5.0.0-x86_64-linux.tar.xz"
log_print 1 "Downloading wizer: $archive_url"
curl --progress-bar --show-error --location --fail $archive_url --output "wizer-v5.0.0.tar.xz"
tar -xvf "wizer-v5.0.0.tar.xz"
}

download_wizer_binary
2 changes: 2 additions & 0 deletions land-server.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ FROM rust:1.76.0 as build
WORKDIR /usr/src/land-server
COPY . .
RUN rustup component add rustfmt
RUN bash /usr/src/land-server/deploy/deps.sh
RUN cargo build -p land-server --release

FROM debian:stable-slim
WORKDIR /opt/bin/
COPY --from=build /usr/src/land-server/target/release/land-server /opt/bin/land-server
COPY --from=build /usr/src/land-server/wizer-v5.0.0-x86_64-linux /opt/bin/wizer
EXPOSE 8840
CMD ["/opt/bin/land-server","--verbose"]

0 comments on commit f27d686

Please sign in to comment.