2021-06-30 14:54:33 +00:00
|
|
|
# Build image
|
2021-11-25 06:43:49 +00:00
|
|
|
FROM rust:alpine3.14 AS chef
|
2021-06-30 14:54:33 +00:00
|
|
|
|
|
|
|
RUN set -x \
|
|
|
|
# Add user
|
|
|
|
&& addgroup --gid 10001 app \
|
|
|
|
&& adduser --disabled-password \
|
|
|
|
--gecos '' \
|
|
|
|
--ingroup app \
|
|
|
|
--home /app \
|
|
|
|
--uid 10001 \
|
2021-11-20 15:31:40 +00:00
|
|
|
app \
|
2021-06-30 14:54:33 +00:00
|
|
|
# Install required packages
|
2021-11-20 15:31:40 +00:00
|
|
|
&& apk add npm openssl-dev musl-dev make perl curl
|
|
|
|
|
2021-06-30 14:54:33 +00:00
|
|
|
USER app
|
|
|
|
WORKDIR /app
|
2021-11-20 15:31:40 +00:00
|
|
|
|
2021-06-30 14:54:33 +00:00
|
|
|
RUN set -x \
|
|
|
|
# Install build tools
|
2021-09-24 07:07:55 +00:00
|
|
|
&& RUSTFLAGS=-Ctarget-feature=-crt-static cargo install wasm-pack cargo-chef \
|
|
|
|
&& npm install rollup \
|
|
|
|
&& rustup target add wasm32-unknown-unknown
|
|
|
|
|
|
|
|
# Prepare the dependency list.
|
|
|
|
FROM chef AS planner
|
|
|
|
COPY . .
|
2021-11-20 15:31:40 +00:00
|
|
|
RUN cargo chef prepare --recipe-path /tmp/recipe.json
|
2021-09-24 07:07:55 +00:00
|
|
|
|
2021-11-20 15:31:40 +00:00
|
|
|
# Build dependencies.
|
2021-09-24 07:07:55 +00:00
|
|
|
FROM chef AS builder
|
2021-11-20 15:31:40 +00:00
|
|
|
COPY --from=planner /tmp/recipe.json recipe.json
|
|
|
|
RUN cargo chef cook --release -p lldap_app --target wasm32-unknown-unknown \
|
|
|
|
&& cargo chef cook --release -p lldap
|
2021-09-24 07:07:55 +00:00
|
|
|
|
2021-11-20 15:31:40 +00:00
|
|
|
# Copy the source and build the app and server.
|
2021-09-24 07:07:55 +00:00
|
|
|
COPY --chown=app:app . .
|
2021-11-20 15:31:40 +00:00
|
|
|
RUN cargo build --release -p lldap \
|
|
|
|
# Build the frontend.
|
|
|
|
&& ./app/build.sh
|
2021-06-30 14:54:33 +00:00
|
|
|
|
|
|
|
# Final image
|
2021-11-25 06:43:49 +00:00
|
|
|
FROM alpine:3.14
|
2021-06-30 14:54:33 +00:00
|
|
|
|
|
|
|
RUN set -x \
|
|
|
|
# Add user
|
|
|
|
&& addgroup --gid 10001 app \
|
|
|
|
&& adduser --disabled-password \
|
|
|
|
--gecos '' \
|
|
|
|
--ingroup app \
|
|
|
|
--home /app \
|
|
|
|
--uid 10001 \
|
2021-11-20 15:31:40 +00:00
|
|
|
app \
|
2021-11-23 10:03:42 +00:00
|
|
|
# Create the /data folder
|
2021-11-25 19:03:55 +00:00
|
|
|
&& mkdir /data && chown app:app /data \
|
|
|
|
&& apk add --no-cache bash
|
2021-11-25 06:43:49 +00:00
|
|
|
|
2021-06-30 14:54:33 +00:00
|
|
|
USER app
|
|
|
|
WORKDIR /app
|
2021-11-20 15:31:40 +00:00
|
|
|
|
2021-11-26 04:31:32 +00:00
|
|
|
COPY --chown=app:app --from=builder /app/app/index.html /app/app/main.js /app/app/style.css app/
|
2021-11-25 09:03:21 +00:00
|
|
|
COPY --chown=app:app --from=builder /app/app/pkg app/pkg
|
2021-06-30 14:54:33 +00:00
|
|
|
COPY --chown=app:app --from=builder /app/target/release/lldap lldap
|
2021-11-25 06:43:49 +00:00
|
|
|
COPY docker-entrypoint.sh .
|
2021-06-30 14:54:33 +00:00
|
|
|
|
|
|
|
ENV LDAP_PORT=3890
|
|
|
|
ENV HTTP_PORT=17170
|
|
|
|
|
|
|
|
EXPOSE ${LDAP_PORT} ${HTTP_PORT}
|
|
|
|
|
2021-11-25 06:43:49 +00:00
|
|
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
|
|
|
CMD ["run", "--config-file", "/data/lldap_config.toml"]
|