From 0f4c17035ede559289c9ab5a779e792394746b67 Mon Sep 17 00:00:00 2001 From: Xenira <1288524+Xenira@users.noreply.github.com> Date: Mon, 5 Jun 2023 20:53:08 +0200 Subject: [PATCH] ci(build): reduced container and wasm size --- Dockerfile | 14 ++++++++------ TODO | 6 ++++++ client/Cargo.toml | 11 +++++++++++ client/Trunk.toml | 3 +++ client/cleanup_assets.sh | 10 ++++++++++ client/index.html | 3 ++- 6 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 client/Trunk.toml create mode 100755 client/cleanup_assets.sh diff --git a/Dockerfile b/Dockerfile index 11d4f95..e1ddbb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,9 +23,9 @@ RUN cargo chef prepare --recipe-path recipe.json FROM trunk AS builder-client COPY --from=planner-client /client/recipe.json /client/recipe.json COPY ./protocol /protocol -RUN cargo chef cook --target wasm32-unknown-unknown --recipe-path recipe.json +RUN cargo chef cook --target wasm32-unknown-unknown --recipe-path recipe.json --release COPY ./client /client -RUN trunk build +RUN trunk build --release ################################################## # Server @@ -39,13 +39,15 @@ RUN cd /server && RUSTFLAGS="-C target-feature=-crt-static" cargo build --target ################################################## # Final Image ################################################## -FROM chef as server -WORKDIR /usr/local/bin -RUN apk add libgcc && addgroup -S serveruser && adduser -S serveruser -G serveruser +FROM chef as composer COPY --from=builder-server /server/target/x86_64-unknown-linux-musl/release/rog-server . COPY --from=builder-client /client/dist ./static -COPY --from=builder-client /client/assets ./static/assets COPY ./server/static ./static + +FROM alpine as server +WORKDIR /usr/local/bin +RUN apk update && apk add libgcc libpq-dev && addgroup -S serveruser && adduser -S serveruser -G serveruser +COPY --from=composer /app/ . USER root EXPOSE 8000/tcp CMD ["rog-server"] diff --git a/TODO b/TODO index 6ea5ecd..33384c7 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ Service: ☐ Validate display name + ☐ Opponents need to show player names + ☐ Reroll button not visible Lobby: ☐ Kick Player ☐ Promote Player @@ -98,6 +100,8 @@ Client: Shop: ☐ Attach shop to top of screen ☐ Attach bench to bottom of screen + ☐ Add glow to duplicate characters + ☐ Add glow to characters that can be upgraded Battle: ☐ Add battle UI ☐ Change target health on animation hit @@ -121,6 +125,8 @@ Client: Misc: ☐ Intro video + ☐ Generated art for web container build + Hosting: ☐ Add preview server diff --git a/client/Cargo.toml b/client/Cargo.toml index e2f507b..8d4dfd9 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -33,3 +33,14 @@ dotenv = "0.15.0" [build-dependencies] fs_extra = "1.3.0" + +# Enable only a small amount of optimization in debug mode +[profile.dev] +opt-level = 1 + +# Enable high optimizations for dependencies (incl. Bevy), but not for our code: +[profile.dev.package."*"] +opt-level = 3 + +[profile.release] +lto = "thin" \ No newline at end of file diff --git a/client/Trunk.toml b/client/Trunk.toml new file mode 100644 index 0000000..eb3da58 --- /dev/null +++ b/client/Trunk.toml @@ -0,0 +1,3 @@ +[[hooks]] +stage = "post_build" +command = "./cleanup_assets.sh" \ No newline at end of file diff --git a/client/cleanup_assets.sh b/client/cleanup_assets.sh new file mode 100755 index 0000000..8acb8c8 --- /dev/null +++ b/client/cleanup_assets.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "Removing .txt files from $TRUNK_STAGING_DIR" +find $TRUNK_STAGING_DIR -name "*.txt" -type f -delete + +echo "Removing .aseprite files from $TRUNK_STAGING_DIR" +find $TRUNK_STAGING_DIR -name "*.aseprite" -type f -delete + +echo "Removing .xcf files from $TRUNK_STAGING_DIR" +find $TRUNK_STAGING_DIR -name "*.xcf" -type f -delete \ No newline at end of file diff --git a/client/index.html b/client/index.html index d4cea18..ac56906 100644 --- a/client/index.html +++ b/client/index.html @@ -6,6 +6,7 @@ + space_3 @@ -25,7 +26,7 @@ - + \ No newline at end of file