diff --git a/Dockerfile b/Dockerfile index 9be5cfb9..1fba2044 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,16 @@ -# Built by Akito -# npub1wprtv89px7z2ut04vvquscpmyfuzvcxttwy2csvla5lvwyj807qqz5aqle - -FROM alpine:3.18.3 AS build - -ENV TZ=Europe/London - -WORKDIR /build - -COPY . . +# Runtime dependencies +FROM alpine:3.18.3 AS runtime-deps +RUN apk --no-cache update && apk --no-cache add \ + lmdb \ + flatbuffers \ + libsecp256k1 \ + libb2 \ + zstd \ + libressl -RUN \ - apk --no-cache add \ +# Build dependencies +FROM runtime-deps AS build-deps +RUN apk update && apk add \ linux-headers \ git \ g++ \ @@ -24,25 +24,24 @@ RUN \ lmdb-dev \ flatbuffers-dev \ libsecp256k1-dev \ - zstd-dev \ - && rm -rf /var/cache/apk/* \ - && git submodule update --init \ - && make setup-golpe \ - && make -j4 + zstd-dev -FROM alpine:3.18.3 +# Stage 1: Build the application using the build-deps base image +FROM build-deps AS build -WORKDIR /app +WORKDIR /build -RUN \ - apk --no-cache add \ - lmdb \ - flatbuffers \ - libsecp256k1 \ - libb2 \ - zstd \ - libressl \ - && rm -rf /var/cache/apk/* +COPY . . + +RUN make clean \ + && git submodule update --init \ + && make setup-golpe \ + && make -j4 + +# Stage 2: Create the final runtime image using the runtime-deps base image +FROM runtime-deps AS runtime + +WORKDIR /app COPY --from=build /build/strfry strfry diff --git a/README.md b/README.md index 0e1b451e..1ff0cc5c 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ A C++20 compiler is required, along with a few other common dependencies. On Deb git clone https://github.com/hoytech/strfry && cd strfry/ git submodule update --init make setup-golpe - make -j4 + make -j$(nproc) #### FreeBSD @@ -43,7 +43,7 @@ A C++20 compiler is required, along with a few other common dependencies. On Deb git clone https://github.com/hoytech/strfry && cd strfry/ git submodule update --init gmake setup-golpe - gmake -j4 + gmake -j$(sysctl -n hw.ncpu) ### Running a relay diff --git a/ubuntu.Dockerfile b/ubuntu.Dockerfile index 8783e3e2..892c5765 100644 --- a/ubuntu.Dockerfile +++ b/ubuntu.Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:jammy as build +FROM ubuntu:jammy AS build ENV TZ=Europe/London WORKDIR /build RUN apt update && apt install -y --no-install-recommends \ @@ -12,7 +12,7 @@ RUN make setup-golpe RUN make clean RUN make -j4 -FROM ubuntu:jammy as runner +FROM ubuntu:jammy AS runner WORKDIR /app RUN apt update && apt install -y --no-install-recommends \