WordGrid/Dockerfile

52 lines
1.4 KiB
Text
Raw Normal View History

2025-01-12 22:34:55 +00:00
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
RUN rustup default stable
RUN apt-get install --no-install-recommends -y gcc
RUN apt-get install --no-install-recommends -y gcc-multilib
RUN cargo install wasm-pack
RUN mkdir /build
WORKDIR /build/
COPY Cargo.toml Cargo.lock /build/
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/
2024-12-26 18:54:30 +00:00
# for some reason wasm-pack wasn't on the PATH
RUN cd wasm && ~/.cargo/bin/wasm-pack build --target=web
RUN cd ui && npm install
RUN cd ui && npm run build
RUN cd server && cargo build --release
2025-01-12 22:34:55 +00:00
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
2024-12-27 20:24:07 +00:00
RUN useradd -d /srv wordgrid && chown -R wordgrid:wordgrid /srv
USER wordgrid
2024-12-26 18:54:30 +00:00
# See https://rocket.rs/guide/v0.5/deploying/#containerization
ENV ROCKET_ADDRESS=0.0.0.0
ENV ROCKET_PORT=8000
ENTRYPOINT ["./server"]
EXPOSE 8000