build: fix the Dockerfiles

This commit is contained in:
Matouš Volf 2024-12-29 19:11:21 +01:00
parent 028f833cae
commit c095a98c5b
Signed by: matous-volf
GPG Key ID: A23C7E16096933BE
2 changed files with 26 additions and 14 deletions

View File

@ -1,8 +1,12 @@
FROM rust:1.83-bookworm
RUN rustup target add wasm32-unknown-unknown && \
cargo install dioxus-cli diesel_cli && \
apt-get update && apt-get install -y nodejs=18.19.0+dfsg-6~deb12u2 npm=9.2.0~ds1-1 supervisor=4.2.5-1
RUN cargo install dioxus-cli diesel_cli \
&& apt-get update && apt-get install -y --no-install-recommends \
nodejs=18.19.0+dfsg-6~deb12u2 \
npm=9.2.0~ds1-1 \
supervisor=4.2.5-1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY . /srv/app
WORKDIR /srv/app
@ -11,10 +15,10 @@ RUN npm install
COPY docker/dev/app/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN chown -R 1000:1000 /srv/app && \
chown -R 1000:1000 /usr/local/cargo && \
mkdir -p /.local/share/dioxus && \
chown -R 1000:1000 /.local/share/dioxus
RUN chown -R 1000:1000 /srv/app \
&& chown -R 1000:1000 /usr/local/cargo \
&& mkdir -p /.local/share/dioxus \
&& chown -R 1000:1000 /.local/share/dioxus
HEALTHCHECK CMD curl --fail -H "Accept: text/html" http://localhost:8000 || exit 1

View File

@ -1,19 +1,27 @@
FROM rust:1.83-bookworm AS builder
RUN rustup target add wasm32-unknown-unknown && \
cargo install dioxus-cli diesel_cli && \
apt-get update && apt-get install -y nodejs=18.19.0+dfsg-6~deb12u2 npm=9.2.0~ds1-1 supervisor=4.2.5-1
RUN rustup target add wasm32-unknown-unknown \
&& cargo install dioxus-cli diesel_cli \
&& apt-get update && apt-get install -y --no-install-recommends \
nodejs=18.19.0+dfsg-6~deb12u2 \
npm=9.2.0~ds1-1 \
supervisor=4.2.5-1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY . /srv/app
WORKDIR /srv/app
RUN npm install && \
npm run build && \
dx build --release
RUN npm install \
&& npm run build \
&& dx build --release
FROM debian:bookworm-slim AS runner
RUN apt-get update && apt-get install -y libpq5=15.8-0+deb12u1
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq5=15.8-0+deb12u1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /srv/app/target/dx/todo-baggins/release/web /srv/app
COPY .env /srv/app/.env