lldap/Dockerfile

67 lines
1.8 KiB
Text
Raw Normal View History

2021-06-30 14:54:33 +00:00
# Build image
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
&& 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-11-20 15:31:40 +00:00
# Build dependencies.
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 \
&& cargo chef cook --release -p migration-tool
2021-11-20 15:31:40 +00:00
# Copy the source and build the app and server.
COPY --chown=app:app . .
RUN cargo build --release -p lldap -p migration-tool \
2021-11-20 15:31:40 +00:00
# Build the frontend.
&& ./app/build.sh
2021-06-30 14:54:33 +00:00
# Final image
FROM alpine:3.14
2021-06-30 14:54:33 +00:00
WORKDIR /app
2021-11-20 15:31:40 +00:00
COPY --from=builder /app/app/index_local.html app/index.html
COPY --from=builder /app/app/static app/static
COPY --from=builder /app/app/pkg app/pkg
COPY --from=builder /app/target/release/lldap /app/target/release/migration-tool ./
COPY docker-entrypoint.sh lldap_config.docker_template.toml ./
RUN set -x \
&& apk add --no-cache bash \
&& for file in $(cat app/static/libraries.txt); do wget -P app/static "$file"; done \
&& for file in $(cat app/static/fonts/fonts.txt); do wget -P app/static/fonts "$file"; done \
&& chmod a+r -R .
2021-06-30 14:54:33 +00:00
ENV LDAP_PORT=3890
ENV HTTP_PORT=17170
EXPOSE ${LDAP_PORT} ${HTTP_PORT}
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["run", "--config-file", "/data/lldap_config.toml"]