Skip to content

Commit

Permalink
Merge pull request #15 from Xenira/dev
Browse files Browse the repository at this point in the history
ci(build): reduced container and wasm size
  • Loading branch information
Xenira authored Jun 5, 2023
2 parents 323f898 + 0f4c170 commit 3327226
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
6 changes: 6 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Service:
☐ Validate display name
☐ Opponents need to show player names
☐ Reroll button not visible
Lobby:
☐ Kick Player
☐ Promote Player
Expand Down Expand Up @@ -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
Expand All @@ -121,6 +125,8 @@ Client:

Misc:
☐ Intro video
☐ Generated art for web container build


Hosting:
☐ Add preview server
Expand Down
11 changes: 11 additions & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 3 additions & 0 deletions client/Trunk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[[hooks]]
stage = "post_build"
command = "./cleanup_assets.sh"
10 changes: 10 additions & 0 deletions client/cleanup_assets.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link data-trunk rel="copy-dir" href="assets" />
<link rel="icon" href="data:,">
<title>space_3</title>

Expand All @@ -25,7 +26,7 @@
</head>

<body>

<link data-trunk rel="rust" data-wasm-opt="s" />
</body>

</html>

0 comments on commit 3327226

Please sign in to comment.