|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 | # |
15 | | -FROM ubuntu:22.04 |
16 | 15 |
|
17 | | -COPY ../target/release/tangle /usr/local/bin/ |
| 16 | +# Build stage |
| 17 | +FROM ubuntu:22.04 AS builder |
| 18 | + |
| 19 | +LABEL maintainer="Webb Developers <dev@webb.tools>" |
| 20 | +LABEL description="Tangle Network Builder" |
| 21 | + |
| 22 | +# Install dependencies required for building |
| 23 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 24 | + curl ca-certificates git build-essential \ |
| 25 | + clang cmake pkg-config libssl-dev libc6 zlib1g-dev libtinfo-dev \ |
| 26 | + && rm -rf /var/lib/apt/lists/* |
| 27 | + |
| 28 | +# Install Rust |
| 29 | +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 30 | +ENV PATH="/root/.cargo/bin:${PATH}" |
| 31 | + |
| 32 | +# Copy the source code |
| 33 | +WORKDIR /build |
| 34 | +COPY . /build |
| 35 | + |
| 36 | +# Build the Tangle binary |
| 37 | +RUN cargo build --release |
| 38 | + |
| 39 | +# Verify the binary works in this environment |
| 40 | +RUN /build/target/release/tangle --version |
| 41 | + |
| 42 | +# Run stage - using the same Ubuntu 22.04 to ensure binary compatibility |
| 43 | +FROM ubuntu:22.04 |
18 | 44 |
|
19 | 45 | LABEL maintainer="Webb Developers <dev@webb.tools>" |
20 | 46 | LABEL description="Tangle Network Node" |
21 | 47 |
|
| 48 | +# Install minimal runtime dependencies |
22 | 49 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
23 | | - curl \ |
24 | | - ca-certificates libc6 \ |
| 50 | + ca-certificates libc6 zlib1g-dev libtinfo-dev \ |
25 | 51 | && rm -rf /var/lib/apt/lists/* |
26 | 52 |
|
| 53 | +# Copy the binary from builder stage |
| 54 | +COPY --from=builder /build/target/release/tangle /usr/local/bin/ |
| 55 | + |
| 56 | +# Create user and set up directories |
27 | 57 | RUN useradd -m -u 5000 -U -s /bin/sh -d /tangle tangle && \ |
28 | 58 | mkdir -p /data /tangle/.local/share && \ |
29 | 59 | chown -R tangle:tangle /data && \ |
30 | 60 | ln -s /data /tangle/.local/share/tangle && \ |
31 | 61 | # unclutter and minimize the attack surface |
32 | 62 | rm -rf /usr/bin /usr/sbin && \ |
33 | | - # check if executable works in this container |
| 63 | + # Verify the binary works in the final container |
34 | 64 | /usr/local/bin/tangle --version |
35 | 65 |
|
36 | 66 | USER tangle |
|
0 commit comments