Fix builder to multistep for small size
All checks were successful
Build Docker Image on Commit / build-and-publish (push) Successful in 1m53s

This commit is contained in:
Merith-TK 2025-04-21 17:30:59 +00:00
parent 9113b58c6a
commit 1ef69c170f

View file

@ -1,53 +1,40 @@
# Stage 1: Builder
FROM node:18-bullseye-slim as builder
FROM rust:slim-bookworm AS builder
RUN DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get upgrade -yqq \
&& apt-get install --no-install-recommends -y \
build-essential \
curl \
ca-certificates \
llvm-13 \
llvm-13-dev \
libclang-common-13-dev \
zlib1g-dev \
git \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/*
# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
clang \
llvm \
libclang-dev \
libssl-dev \
pkg-config \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ENV PATH="/usr/lib/llvm-13/bin/:${PATH}"
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup target add wasm32-unknown-unknown
# NodeJS/NPM Dependencies
RUN npx --package typescript tsc --init
RUN npm install --global webpack
RUN npm install --global webpack-cli
RUN npm install @msgpack/msgpack
RUN npm install bs58
# Clone and build freenet-core
# First clone without submodules
WORKDIR /src
RUN git clone https://github.com/freenet/freenet-core.git freenet
RUN git clone --depth 1 https://github.com/freenet/freenet-core.git freenet
# Change submodule URLs from SSH to HTTPS
WORKDIR /src/freenet
RUN sed -i 's|git@github.com:|https://github.com/|' .gitmodules && \
git submodule sync && \
git submodule update --init --recursive
# Build the core crate (correct package specification)
WORKDIR /src/freenet/crates/core
RUN cargo install --path .
RUN cargo build --release
# Stage 2: Runner
FROM debian:bullseye-slim
FROM debian:bookworm-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get upgrade -yqq \
&& apt-get install --no-install-recommends -y \
ca-certificates \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/*
# Copy the built binary from the builder stage
COPY --from=builder /root/.cargo/bin/freenet /usr/local/bin/freenet
# Copy the compiled binary
COPY --from=builder /src/freenet/target/release/freenet /usr/local/bin/freenet
CMD ["freenet", "-b", "0.0.0.0"]