2021-06-30 14:54:33 +00:00
|
|
|
# Build image
|
2023-01-04 07:24:40 +00:00
|
|
|
FROM rust:alpine3.16 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
|
2023-03-05 11:45:30 +00:00
|
|
|
&& apk add openssl-dev musl-dev make perl curl gzip
|
2021-11-20 15:31:40 +00:00
|
|
|
|
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 \
|
|
|
|
&& 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 \
|
2021-12-08 09:20:18 +00:00
|
|
|
&& cargo chef cook --release -p lldap \
|
|
|
|
&& cargo chef cook --release -p migration-tool
|
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-12-08 09:20:18 +00:00
|
|
|
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
|
2023-01-04 07:24:40 +00:00
|
|
|
FROM alpine:3.16
|
2021-06-30 14:54:33 +00:00
|
|
|
|
2022-10-12 13:53:07 +00:00
|
|
|
ENV GOSU_VERSION 1.14
|
|
|
|
# Fetch gosu from git
|
|
|
|
RUN set -eux; \
|
|
|
|
\
|
|
|
|
apk add --no-cache --virtual .gosu-deps \
|
|
|
|
ca-certificates \
|
|
|
|
dpkg \
|
|
|
|
gnupg \
|
|
|
|
; \
|
|
|
|
\
|
|
|
|
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
|
|
|
|
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
|
|
|
|
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
|
|
|
|
\
|
|
|
|
# verify the signature
|
|
|
|
export GNUPGHOME="$(mktemp -d)"; \
|
|
|
|
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
|
|
|
|
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
|
|
|
|
command -v gpgconf && gpgconf --kill all || :; \
|
|
|
|
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
|
|
|
|
\
|
|
|
|
# clean up fetch dependencies
|
|
|
|
apk del --no-network .gosu-deps; \
|
|
|
|
\
|
|
|
|
chmod +x /usr/local/bin/gosu; \
|
|
|
|
# verify that the binary works
|
|
|
|
gosu --version; \
|
|
|
|
gosu nobody true
|
|
|
|
|
|
|
|
|
2021-06-30 14:54:33 +00:00
|
|
|
WORKDIR /app
|
2021-11-20 15:31:40 +00:00
|
|
|
|
2021-11-28 17:42:59 +00:00
|
|
|
COPY --from=builder /app/app/index_local.html app/index.html
|
|
|
|
COPY --from=builder /app/app/static app/static
|
2021-11-27 19:19:55 +00:00
|
|
|
COPY --from=builder /app/app/pkg app/pkg
|
2021-12-08 09:20:18 +00:00
|
|
|
COPY --from=builder /app/target/release/lldap /app/target/release/migration-tool ./
|
2021-11-27 19:19:55 +00:00
|
|
|
COPY docker-entrypoint.sh lldap_config.docker_template.toml ./
|
|
|
|
|
|
|
|
RUN set -x \
|
2022-11-01 11:57:49 +00:00
|
|
|
&& apk add --no-cache bash tzdata \
|
2021-11-28 17:42:59 +00:00
|
|
|
&& for file in $(cat app/static/libraries.txt); do wget -P app/static "$file"; done \
|
2021-11-29 00:11:15 +00:00
|
|
|
&& for file in $(cat app/static/fonts/fonts.txt); do wget -P app/static/fonts "$file"; done \
|
2021-11-27 19:19:55 +00:00
|
|
|
&& 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}
|
|
|
|
|
2021-11-25 06:43:49 +00:00
|
|
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
|
|
|
CMD ["run", "--config-file", "/data/lldap_config.toml"]
|
2023-02-15 08:51:47 +00:00
|
|
|
HEALTHCHECK CMD ["/app/lldap", "healthcheck", "--config-file", "/data/lldap_config.toml"]
|