Comments (2)
I just hacked this, using https://github.com/emk/rust-musl-builder to cross-compile warp.
I'm building a F# project + dependency on https://github.com/Hopac/Hopac, so my assembly is quite a bit larger than what a C# hello-world would yield (published ~46M, packed ~20M).
Relevant .fsproj properties:
<PublishTrimmed>true</PublishTrimmed>
<PublishSingleFile>true</PublishSingleFile>
warp-musl.patch:
diff --git "a/warp-packer/src/main.rs" "b/warp-packer/src/main.rs"
index 616ae45..d361da4 100644
--- "a/warp-packer/src/main.rs"
+++ "b/warp-packer/src/main.rs"
@@ -27,16 +27,16 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
const RUNNER_MAGIC: &[u8] = b"tVQhhsFFlGGD3oWV4lEPST8I8FEPP54IM0q7daes4E1y3p2U2wlJRYmWmjPYfkhZ0PlT14Ls0j8fdDkoj33f2BlRJavLj3mWGibJsGt5uLAtrCDtvxikZ8UX2mQDCrgE\0";
-const RUNNER_LINUX_X64: &[u8] = include_bytes!("../../target/x86_64-unknown-linux-gnu/release/warp-runner");
-const RUNNER_MACOS_X64: &[u8] = include_bytes!("../../target/x86_64-apple-darwin/release/warp-runner");
-const RUNNER_WINDOWS_X64: &[u8] = include_bytes!("../../target/x86_64-pc-windows-gnu/release/warp-runner.exe");
+const RUNNER_LINUX_X64: &[u8] = include_bytes!("../../target/x86_64-unknown-linux-musl/release/warp-runner");
+//const RUNNER_MACOS_X64: &[u8] = include_bytes!("../../target/x86_64-apple-darwin/release/warp-runner");
+//const RUNNER_WINDOWS_X64: &[u8] = include_bytes!("../../target/x86_64-pc-windows-gnu/release/warp-runner.exe");
lazy_static! {
static ref RUNNER_BY_ARCH: HashMap<&'static str, &'static [u8]> = {
let mut m = HashMap::new();
m.insert("linux-x64", RUNNER_LINUX_X64);
- m.insert("macos-x64", RUNNER_MACOS_X64);
- m.insert("windows-x64", RUNNER_WINDOWS_X64);
+ //m.insert("macos-x64", RUNNER_MACOS_X64);
+ //m.insert("windows-x64", RUNNER_WINDOWS_X64);
m
};
}
Dockerfile:
ARG FRAMEWORK=netcoreapp3.1
ARG RUNTIME=linux-musl-x64
ARG RUST_TARGET=x86_64-unknown-linux-musl
ARG WARP_VERSION=0.3.0
ARG WARP_PATH=/usr/local/bin/warp-packer
#---
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine as dotnet
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
ENV PATH="/root/.dotnet/tools:${PATH}"
RUN dotnet tool install paket -g
#---
FROM dotnet as restore
WORKDIR /build
COPY paket.dependencies .
COPY paket.lock .
RUN paket restore
#---
FROM restore as build
COPY App.sln App.sln
COPY App/ App/
ARG RUNTIME
RUN dotnet publish -c Release -r ${RUNTIME}
#---
FROM ekidd/rust-musl-builder as packer-build
ARG WARP_VERSION
ARG RUST_TARGET
ARG PATCH_FILE=/tmp/warp-musl.patch
COPY warp-musl.patch ${PATCH_FILE}
RUN git clone -v --depth 1 --single-branch --branch v${WARP_VERSION} https://github.com/dgiagio/warp . \
&& patch ~/src/warp-packer/src/main.rs ${PATCH_FILE} \
&& cargo build --release --target=${RUST_TARGET}
#---
FROM alpine:3.11 as packer
ARG RUST_TARGET
ARG WARP_PATH
COPY --from=packer-build /home/rust/src/target/${RUST_TARGET}/release/warp-packer ${WARP_PATH}
ARG FRAMEWORK
ARG RUNTIME
COPY --from=build /build/App/bin/Release/${FRAMEWORK}/${RUNTIME}/publish /publish
WORKDIR /pack
RUN warp-packer \
--arch linux-x64 \
--input_dir /publish \
--exec App \
--output App
#---
FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-alpine as runtime-packed
COPY --from=packer /pack/App .
#---
FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-alpine as runtime-published
ARG FRAMEWORK
ARG RUNTIME
COPY --from=build /build/App/bin/Release/${FRAMEWORK}/${RUNTIME}/publish/App App
Comparing the image sizes:
REPOSITORY TAG IMAGE ID CREATED SIZE
runtime-published latest 0bb788223154 16 minutes ago 58.1MB
runtime-packed latest 591241270919 16 minutes ago 30.4MB
It took me a while to realize that just running the App (published or packed) will immediately increase the image to >100M.
from warp.
Awesome, I'll have to try that out--thanks!
Would still be nice to see it officially supported, so I'll leave the issue open.
from warp.
Related Issues (20)
- Is there a docker image available? HOT 7
- Is there a way to do inject the exe version? HOT 2
- A way to specify with version of glibc will be used?
- exclude app settings
- Warp does not work for no login shell users HOT 1
- single executable of a php application HOT 1
- 32 Bit support ? HOT 2
- Updating HOT 1
- can't find crate for `std`
- ARM Support
- Java only includes linux architecture in readme? HOT 1
- Export warp-packer as a library
- FYI Warp being considered for Deno executables HOT 1
- Provide a parameter to control expansion location for packed exe
- "Error: No tarball found inside binary" HOT 2
- Ability to choose compression level and algorithm
- Feature Request: Splash Screen or Small Bootstrap exe?
- Making a self-contained jq binary
- [Windows] Parenthesis in packaged filename causes "not recognized as ... command" error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from warp.