docker: Small improvements

This commit is contained in:
Valentin Tolmer 2021-11-20 16:31:40 +01:00 committed by nitnelave
parent 618e7e3585
commit 7b081fce61

View File

@ -9,12 +9,13 @@ RUN set -x \
--ingroup app \ --ingroup app \
--home /app \ --home /app \
--uid 10001 \ --uid 10001 \
app app \
RUN set -x \
# Install required packages # Install required packages
&& apk add npm openssl-dev musl-dev make perl && apk add npm openssl-dev musl-dev make perl curl
USER app USER app
WORKDIR /app WORKDIR /app
RUN set -x \ RUN set -x \
# Install build tools # Install build tools
&& RUSTFLAGS=-Ctarget-feature=-crt-static cargo install wasm-pack cargo-chef \ && RUSTFLAGS=-Ctarget-feature=-crt-static cargo install wasm-pack cargo-chef \
@ -24,20 +25,19 @@ RUN set -x \
# Prepare the dependency list. # Prepare the dependency list.
FROM chef AS planner FROM chef AS planner
COPY . . COPY . .
USER root RUN cargo chef prepare --recipe-path /tmp/recipe.json
RUN cargo chef prepare --recipe-path recipe.json
# Build dependencies # Build dependencies.
FROM chef AS builder FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json COPY --from=planner /tmp/recipe.json recipe.json
RUN cargo chef cook --release -p lldap --recipe-path recipe.json \ RUN cargo chef cook --release -p lldap_app --target wasm32-unknown-unknown \
&& cargo chef cook --release -p lldap_app --target wasm32-unknown-unknown && cargo chef cook --release -p lldap
# Copy the source and build the app. # Copy the source and build the app and server.
COPY --chown=app:app . . COPY --chown=app:app . .
RUN cargo build --release -p lldap RUN cargo build --release -p lldap \
# TODO: release mode. # Build the frontend.
RUN ./app/build.sh && ./app/build.sh
# Final image # Final image
FROM alpine FROM alpine
@ -50,14 +50,13 @@ RUN set -x \
--ingroup app \ --ingroup app \
--home /app \ --home /app \
--uid 10001 \ --uid 10001 \
app app \
&& mkdir /data && chown app:app /data
RUN mkdir /data && chown app:app /data
USER app USER app
WORKDIR /app WORKDIR /app
COPY --chown=app:app --from=builder /app/app/index.html app/index.html
COPY --chown=app:app --from=builder /app/app/main.js app/main.js COPY --chown=app:app --from=builder /app/app/index.html /app/app/main.js /app/app/pkg app/
COPY --chown=app:app --from=builder /app/app/pkg app/pkg
COPY --chown=app:app --from=builder /app/target/release/lldap lldap COPY --chown=app:app --from=builder /app/target/release/lldap lldap
ENV LDAP_PORT=3890 ENV LDAP_PORT=3890