emk / rust-musl-builder

Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.
Apache License 2.0
1.54k stars 193 forks source link

404 not found when using with rust-embeded #70

Closed GopherJ closed 5 years ago

GopherJ commented 5 years ago

Hello, I have a project with these dependencies

[package]
name = "acs_server"
version = "0.1.0"
authors = ["Cheng JIANG <cheng.jiang@outlook.fr>"]
license-file = "LICENSE"
description = "Access Control Server"
edition = "2018"
build = "build.rs"

[dependencies]
actix = "0.7.9"
actix-web = { version = "0.7.18", features = ["ssl"] }
diesel = { version = "1.4.2", features = ["r2d2", "postgres", "chrono", "uuid"] }
futures = "0.1.25"
env_logger = "0.6.0"
log = "0.4.6"
openssl = "0.10"
toml = "0.4.10"
failure = "0.1.5"
serde_derive = "1.0.85"
serde = "1.0.85"
serde_json = "1.0.37"
rust-embed = "4.3.0"
mime_guess = "2.0.0-alpha.6"
clap = { version = "2.32.0", features = ["yaml"] }
uuid = { version = "0.7", features = ["serde", "v4"] }
r2d2 = "0.8.3"
num_cpus = "1.0"
chrono = { version = "0.4", features = ["serde"] }
bcrypt = "0.2.0"
validator = "0.8.0"
validator_derive = "0.8.0"
exit = "0.1.0"
lazy_static = "1.2.0"
regex = "1"
jsonwebtoken = "^5.0.1"
md5 = "0.6.0"
ring = "0.13.5"
derive_builder = "0.5.1"
actix-web-httpauth = "0.1.0"
base64 = "^0.8.0"
askama = { version = "^0.8.0", features = ["with-actix-web"] }
percent-encoding = "1.0.1"
globset = "0.3"

[build-dependencies]
failure = "0.1.5"

I did this in Makefile to compile it into static, It works fine and I get a static binary, this binary can also work on my PC (ubuntu18.10), but when I upload it to a public server (ubuntu18.04).

        if [ ! "$(shell docker image ls | grep muslrust)" ]; then \
        docker pull clux/muslrust ;\
    fi ;\
    echo "$(GREEN)=> building...$(END)" && \
    docker run -v "$(shell pwd)":/volume -v cargo-cache:/root/.cargo/registry --rm -t clux/muslrust cargo build --manifest-path=server/Cargo.toml

It can start without error but it cannot load my VueJs client anymore, the client is compiled into this binary.

Then I switch to use cargo build --release and upload the new dynamic binary to my public server, it works and succeed to load static files (which has been embeded into the binary).

emk commented 5 years ago

This is the emk/rust-musl-builder repo, not the clux/muslrust repo mentioned in your Makefile.