You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.8 KiB
59 lines
1.8 KiB
# get the base image
|
|
FROM rust:1.69 AS build
|
|
|
|
# install build dependencies
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends lsb-release apt-transport-https \
|
|
build-essential curl wget pkg-config
|
|
|
|
# vars
|
|
ENV PERSEUS_VERSION=0.4.1 \
|
|
PERSEUS_SIZE_OPT_VERSION=0.1.9 \
|
|
ESBUILD_VERSION=0.15.18 \
|
|
BINARYEN_VERSION=112
|
|
|
|
# prepare root project dir
|
|
WORKDIR /app
|
|
|
|
# download the target for wasm
|
|
RUN rustup target add wasm32-unknown-unknown;\
|
|
cargo install wasm-pack # might not be a bad idea to fix the version of this in the future
|
|
|
|
# retrieve the src dir
|
|
COPY . .
|
|
|
|
# install perseus-cli
|
|
RUN cargo install perseus-cli --version $PERSEUS_VERSION;\
|
|
perseus clean
|
|
|
|
# deploy app
|
|
RUN perseus deploy
|
|
|
|
# download and unpack esbuild
|
|
RUN curl -O https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-${ESBUILD_VERSION}.tgz \
|
|
&& tar xf esbuild-linux-64-${ESBUILD_VERSION}.tgz \
|
|
&& ./package/bin/esbuild --version
|
|
|
|
# run esbuild against bundle.js
|
|
RUN ./package/bin/esbuild ./pkg/dist/pkg/perseus_engine.js --minify --target=es6 --outfile=./pkg/dist/pkg/perseus_engine.js --allow-overwrite \
|
|
&& ls -lha ./pkg/dist/pkg
|
|
|
|
# download and unpack binaryen
|
|
RUN wget -nv https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz \
|
|
&& tar xf binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz \
|
|
&& ./binaryen-version_${BINARYEN_VERSION}/bin/wasm-opt --version
|
|
|
|
# run wasm-opt against bundle.wasm
|
|
RUN ./binaryen-version_${BINARYEN_VERSION}/bin/wasm-opt -Os ./pkg/dist/pkg/perseus_engine_bg.wasm -o ./pkg/dist/pkg/perseus_engine_bg.wasm
|
|
|
|
# prepare deployment image
|
|
FROM debian:stable-slim
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=build /app/pkg /app/
|
|
|
|
ENV HOST=0.0.0.0
|
|
|
|
CMD ["./server"]
|