forked from terminusdb/terminusdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
81 lines (71 loc) · 2.86 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# syntax=docker/dockerfile:1.3
ARG DIST=community
# Install the SWI-Prolog pack dependencies.
FROM terminusdb/swipl:v9.0.3-bookworm AS pack_installer
RUN set -eux; \
BUILD_DEPS="git curl build-essential make libjwt-dev libssl-dev pkg-config"; \
apt-get update; \
apt-get install -y --no-install-recommends ${BUILD_DEPS}; \
rm -rf /var/lib/apt/lists/*
WORKDIR /app/pack
COPY distribution/Makefile.deps Makefile
RUN make
# Install Rust. Prepare to build the Rust code.
FROM terminusdb/swipl:v9.0.3-bookworm AS rust_builder_base
ARG CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN set -eux; \
BUILD_DEPS="git build-essential curl clang ca-certificates m4 libgmp-dev protobuf-compiler libprotobuf-dev"; \
apt-get update; \
apt-get install -y --no-install-recommends ${BUILD_DEPS}; \
rm -rf /var/lib/apt/lists/*
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --profile minimal
ENV PATH="/root/.cargo/bin:${PATH}"
# Initialize the crates.io index git repo to cache it.
RUN (cargo install lazy_static 2> /dev/null || true) && (cargo install cargo-swipl || true)
WORKDIR /app/rust
COPY distribution/Makefile.rust Makefile
COPY src/rust src/rust/
# Build the community dylib.
FROM rust_builder_base AS rust_builder_community
ARG CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN make DIST=community && cd src/rust && cargo swipl test --release
# Build the enterprise dylib.
FROM rust_builder_base AS rust_builder_enterprise
COPY terminusdb-enterprise/rust terminusdb-enterprise/rust/
RUN make DIST=enterprise
# Build the ${DIST} dylib.
FROM rust_builder_${DIST} AS rust_builder
# Copy the packs and dylib. Prepare to build the Prolog code.
FROM terminusdb/swipl:v9.0.3-bookworm AS base
RUN set -eux; \
RUNTIME_DEPS="libjwt0 make openssl binutils"; \
apt-get update; \
apt-get upgrade -y; \
apt-get install -y --no-install-recommends ${RUNTIME_DEPS}; \
rm -rf /var/cache/apt/*; \
rm -rf /var/lib/apt/lists/*
ARG TERMINUSDB_GIT_HASH=null
ENV TERMINUSDB_GIT_HASH=${TERMINUSDB_GIT_HASH}
ARG TERMINUSDB_JWT_ENABLED=true
ENV TERMINUSDB_JWT_ENABLED=${TERMINUSDB_JWT_ENABLED}
COPY --from=pack_installer /root/.local/share/swi-prolog/pack/ /usr/share/swi-prolog/pack
COPY --from=pack_installer /app/pack/dashboard /app/terminusdb/dashboard
WORKDIR /app/terminusdb
COPY distribution/init_docker.sh distribution/
COPY distribution/Makefile.prolog Makefile
COPY src src/
COPY --from=rust_builder /app/rust/src/rust/librust.so src/rust/
# Build the community executable.
FROM base AS base_community
RUN set -eux; \
touch src/rust/librust.so; \
make DIST=community
# Build the enterprise executable.
FROM base AS base_enterprise
COPY terminusdb-enterprise/prolog terminusdb-enterprise/prolog/
RUN set -eux; \
touch src/rust/librust.so; \
make DIST=enterprise
# Build the ${DIST} executable. Set the default command.
FROM base_${DIST}
CMD ["/app/terminusdb/distribution/init_docker.sh"]