forked from trustification/trustify-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.server
51 lines (43 loc) · 2.24 KB
/
Dockerfile.server
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
######################################################################
# UI
######################################################################
FROM registry.access.redhat.com/ubi9/nodejs-20:latest AS ui-source
USER 1001
COPY --chown=1001 . .
RUN npm install -g npm@9
RUN npm clean-install --ignore-scripts && npm run build && npm run dist
######################################################################
# Prepare server
######################################################################
FROM registry.access.redhat.com/ubi9/ubi:latest AS server-source
ARG server_branch="main"
ARG server_commit
RUN dnf install git -y
RUN git clone https://github.com/trustification/trustify.git --branch ${server_branch} /trustify/
RUN cd /trustify/ && if [ -n "${commit}" ]; then git checkout -b commit-branch ${server_commit}; fi
RUN sed -i 's/trustify-ui = { git = "https:\/\/github.com\/trustification\/trustify-ui.git", branch = "publish\/main" }/trustify-ui = { path = "..\/trustify-ui\/crate" }/g' /trustify/Cargo.toml
######################################################################
# Build server
######################################################################
FROM registry.access.redhat.com/ubi9/ubi:latest AS server-builder
# Dependencies
RUN dnf install -y openssl-devel gcc
RUN mkdir /stage/ && \
dnf install --installroot /stage/ --setop install_weak_deps=false --nodocs -y zlib openssl && \
dnf clean all --installroot /stage/
# Setup Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH=${PATH}:/root/.cargo/bin
RUN rustup target add $(uname -m)-unknown-linux-gnu
# Build source code
COPY --from=ui-source /opt/app-root/src/ /code/trustify-ui/
COPY --from=server-source /trustify/ /code/trustify/
RUN cd /code/trustify/ && \
cargo build --no-default-features --release --target=$(uname -m)-unknown-linux-gnu && \
find /code/trustify/target/ -name "trustd" -exec cp -av {} /stage/usr/local/bin \;
######################################################################
# Builder runner
######################################################################
FROM registry.access.redhat.com/ubi9/ubi-micro:latest AS server-runner
COPY --from=server-builder /stage/ .
ENTRYPOINT ["/usr/local/bin/trustd"]