FROM docker.io/library/ubuntu:24.04 as build-stage LABEL authors="joel" ENV DEBIAN_FRONTEND noninteractive RUN apt-get update RUN apt-get upgrade -y RUN apt-get install --no-install-recommends -y rustup npm gcc gcc-multilib RUN rustup default stable RUN cargo install wasm-pack RUN mkdir /build WORKDIR /build/ # for caching the dependencies downloads COPY Cargo.toml Cargo.lock /build/ COPY wasm/Cargo.toml /build/wasm/ COPY server/Cargo.toml /build/server/ COPY wordgrid/Cargo.toml /build/wordgrid/ RUN cargo fetch COPY ui/package.json ui/package-lock.json /build/ui/ RUN mkdir /build/wasm/pkg && echo "{}" > /build/wasm/pkg/package.json && cd ui && npm install COPY --exclude=*/target/* wordgrid /build/wordgrid/ COPY --exclude=*/target/* --exclude=*/pkg/* wasm /build/wasm/ COPY --exclude=*/target/* server /build/server/ COPY --exclude=*/node_modules/* --exclude=*/dist/* ui /build/ui/ COPY resources /build/resources/ # for some reason wasm-pack wasn't on the PATH RUN cd wasm && ~/.cargo/bin/wasm-pack build --target=web # We re-run install because wasm/pkg is now actually present and this needs to be reflected (node_modules copied the old pkg directory) RUN cd ui && npm install && npm run build RUN cd server && cargo build --release FROM docker.io/library/ubuntu:24.04 as final-image LABEL authors="joel" WORKDIR /srv/ COPY --from=build-stage /build/ui/dist /srv/static COPY --from=build-stage /build/target/release/server server RUN cp /srv/static/*.csv dictionary.csv RUN echo '{"dictionary_path": "dictionary.csv", "static_path": "static"}' > config.json RUN useradd -d /srv wordgrid && chown -R wordgrid:wordgrid /srv USER wordgrid # See https://rocket.rs/guide/v0.5/deploying/#containerization ENV ROCKET_ADDRESS=0.0.0.0 ENV ROCKET_PORT=8000 ENTRYPOINT ["./server"] EXPOSE 8000