feat(deploy): Set Dockerfile according to official dioxus docs
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
48
Dockerfile
48
Dockerfile
@@ -1,21 +1,33 @@
|
|||||||
FROM rust:1.84.0 AS dioxus
|
FROM rust:1 AS chef
|
||||||
RUN cargo install dioxus-cli@^0.6
|
RUN cargo install cargo-chef
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
FROM dioxus AS builder
|
FROM chef AS planner
|
||||||
WORKDIR /athome/
|
COPY . .
|
||||||
RUN apt-get update && apt install libwebkit2gtk-4.1-dev build-essential curl npm \
|
RUN cargo chef prepare --recipe-path recipe.json
|
||||||
wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev -y\
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
FROM chef AS builder
|
||||||
RUN npm install -D tailwindcss
|
COPY --from=planner /app/recipe.json recipe.json
|
||||||
COPY ./Cargo.toml ./Cargo.toml
|
RUN cargo chef cook --release --recipe-path recipe.json
|
||||||
COPY ./Dioxus.toml ./Dioxus.toml
|
COPY . .
|
||||||
COPY ./input.css ./input.css
|
|
||||||
COPY ./tailwind.config.js ./tailwind.config.js
|
# Install `dx`
|
||||||
COPY ./src/ ./src/
|
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
||||||
COPY ./assets/ ./assets/
|
RUN cargo binstall dioxus-cli --root /.cargo -y --force
|
||||||
|
ENV PATH="/.cargo/bin:$PATH"
|
||||||
|
|
||||||
|
# Create the final bundle folder. Bundle always executes in release mode with optimizations enabled
|
||||||
RUN dx bundle --platform web
|
RUN dx bundle --platform web
|
||||||
|
|
||||||
FROM alpine:3 AS runner
|
FROM chef AS runtime
|
||||||
WORKDIR /app/
|
COPY --from=builder /app/target/dx/athome/release/web/ /usr/local/app
|
||||||
COPY --from=builder /athome/docs/ ./
|
|
||||||
CMD [ "./server" ]
|
# set our port and make sure to listen for all connections
|
||||||
|
ENV PORT=8080
|
||||||
|
ENV IP=0.0.0.0
|
||||||
|
|
||||||
|
# expose the port 8080
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
WORKDIR /usr/local/app
|
||||||
|
ENTRYPOINT [ "/usr/local/app/server" ]
|
||||||
|
|||||||
Reference in New Issue
Block a user