diff options
| author | Martin Hafskjold Thoresen <martin@vind.ai> | 2025-01-11 15:23:11 +0100 |
|---|---|---|
| committer | Martin Hafskjold Thoresen <martin@vind.ai> | 2025-01-11 15:23:11 +0100 |
| commit | ec697c401e2d2c6c59c7aab7755ccf6620861ca8 (patch) | |
| tree | a52dc5aab7e06941928a0eed18cd8d945620c525 | |
| parent | 42fd8cd3560047c88a2167a4d5c5845dd81eb3ec (diff) | |
| download | musicgame-master.tar.gz musicgame-master.zip | |
| -rw-r--r-- | Dockerfile | 39 | ||||
| -rw-r--r-- | justfile | 7 | ||||
| -rw-r--r-- | static/main.js | 2 |
3 files changed, 47 insertions, 1 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..132af07 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +FROM messense/rust-musl-cross:aarch64-musl AS base +RUN cargo install cargo-chef --locked + +####################### +FROM base AS planner +WORKDIR /app +##### +COPY Cargo.toml Cargo.toml +COPY Cargo.lock Cargo.lock +COPY ./src ./src +##### +RUN cargo chef prepare --recipe-path recipe.json + +####################### +FROM base AS builder +COPY --from=planner /app/recipe.json recipe.json +RUN cargo chef cook --release --recipe-path recipe.json +##### +COPY Cargo.toml Cargo.toml +COPY Cargo.lock Cargo.lock +COPY ./src ./src +COPY ./static ./static +##### +RUN cargo build --release + +####################### +FROM --platform=linux/aarch64 alpine:3.20 + +RUN apk add --no-cache curl ca-certificates +COPY --from=builder /home/rust/src/target/aarch64-unknown-linux-musl/release/musicgame /app/server +COPY ./static /app/static + +ENV PATH="${PATH}:/app" +ENV STATIC_DIR="/app/static/" +ENV STAGE="prod" + +WORKDIR "/app" + +EXPOSE 4800 diff --git a/justfile b/justfile new file mode 100644 index 0000000..6bd8d71 --- /dev/null +++ b/justfile @@ -0,0 +1,7 @@ + +build-image: + docker build . -t musicgame --platform linux/aarch64 + +push-image: + docker save musicgame | bzip2 | ssh mhtwtf docker load + ssh mhtwtf "docker run --entrypoint '/app/server' -p 4001:4800 -dt musicgame" diff --git a/static/main.js b/static/main.js index 183b117..6b092fa 100644 --- a/static/main.js +++ b/static/main.js @@ -8,7 +8,7 @@ function getContext() { async function loadSample(url) { const res = await fetch(url); - const buffer = res.arrayBuffer(); + const buffer = await res.arrayBuffer(); return getContext().decodeAudioData(buffer); } |
