-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
49 lines (39 loc) · 1.79 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
# Stage 1: Builder
# Using the latest Rust image to set up the build environment
FROM rust:1.84 AS builder
SHELL ["/bin/bash", "-c"]
# Copy and set permissions for the entrypoint script
COPY entrypoint.sh /usr/src/scout/entrypoint.sh
# Copy local cargo-scout-audit project files
COPY / /usr/src/scout-audit
# Install cargo-scout-audit from the local path
WORKDIR /usr/src/scout-audit/apps/cargo-scout-audit
RUN cargo install --features docker_container --path . --locked
WORKDIR /usr/src/scout-audit/detectors/ink
RUN cargo +nightly-2024-07-11 build --release
WORKDIR /usr/src/scout-audit/detectors/rust
RUN cargo +nightly-2024-07-11 build --release
WORKDIR /usr/src/scout-audit/detectors/soroban
RUN cargo +nightly-2024-07-11 build --release
WORKDIR /usr/src/scout-audit/detectors/substrate-pallets
RUN cargo +nightly-2024-07-11 build --release
# Stage 2: Final
# Base image with Rust slim version for the runtime environment
FROM rust:1.84 AS final
# Install only necessary runtime dependencies
RUN apt-get update && apt-get install -y libcurl4 libssl-dev pkg-config && \
rm -rf /var/lib/apt/lists/*
# Copy the .rustup directory from the builder stage
COPY --from=builder /usr/local/rustup /usr/local/rustup
ENV PATH="/usr/local/rustup/bin:$PATH"
# Copy necessary binaries from the builder stage
COPY --from=builder /usr/local/cargo/bin/cargo-scout-audit /usr/local/cargo/bin/
COPY --from=builder /usr/local/cargo/bin/dylint-link /usr/local/cargo/bin/
COPY --from=builder /usr/src/scout/entrypoint.sh /usr/local/bin/
COPY --from=builder /usr/src/scout-audit /scout-audit
# Ensure the script and binaries are executable
RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/cargo/bin/*
# Define volume for application data
VOLUME /scoutme
# Set the entrypoint to the script
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]