|
| 1 | +FROM ubuntu:24.04 AS build |
| 2 | + |
| 3 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 4 | + gcc make cmake git ca-certificates pkg-config \ |
| 5 | + libmicrohttpd-dev libjansson-dev libcurl4-openssl-dev \ |
| 6 | + libgnutls28-dev libsqlite3-dev zlib1g-dev \ |
| 7 | + && rm -rf /var/lib/apt/lists/* |
| 8 | + |
| 9 | +# Build ulfius and its dependency orcania/yder from source |
| 10 | +WORKDIR /tmp |
| 11 | +RUN git clone --depth 1 --branch v2.3.3 https://github.com/babelouest/orcania.git && \ |
| 12 | + cd orcania && cmake -B build -DCMAKE_BUILD_TYPE=Release -S . && \ |
| 13 | + cmake --build build -j$(nproc) && cmake --install build |
| 14 | + |
| 15 | +RUN git clone --depth 1 --branch v1.4.20 https://github.com/babelouest/yder.git && \ |
| 16 | + cd yder && cmake -B build -DCMAKE_BUILD_TYPE=Release -DWITH_JOURNALD=OFF -S . && \ |
| 17 | + cmake --build build -j$(nproc) && cmake --install build |
| 18 | + |
| 19 | +RUN git clone --depth 1 --branch v2.7.15 https://github.com/babelouest/ulfius.git && \ |
| 20 | + cd ulfius && cmake -B build -DCMAKE_BUILD_TYPE=Release \ |
| 21 | + -DWITH_WEBSOCKET=OFF -DWITH_CURL=OFF \ |
| 22 | + -DCMAKE_C_FLAGS="-O3 -flto" \ |
| 23 | + -S . && \ |
| 24 | + cmake --build build -j$(nproc) && cmake --install build |
| 25 | + |
| 26 | +RUN ldconfig |
| 27 | + |
| 28 | +# Build our server |
| 29 | +WORKDIR /app |
| 30 | +COPY src/server.c ./ |
| 31 | +RUN gcc -O3 -flto -march=native -o server server.c \ |
| 32 | + $(pkg-config --cflags --libs libulfius) \ |
| 33 | + -ljansson -lsqlite3 -lz -lm -lpthread |
| 34 | + |
| 35 | +FROM ubuntu:24.04 |
| 36 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 37 | + libmicrohttpd12t64 libjansson4 libgnutls30t64 libsqlite3-0 zlib1g && \ |
| 38 | + rm -rf /var/lib/apt/lists/* |
| 39 | +COPY --from=build /usr/local/lib/libulfius.so* /usr/local/lib/ |
| 40 | +COPY --from=build /usr/local/lib/liborcania.so* /usr/local/lib/ |
| 41 | +COPY --from=build /usr/local/lib/libyder.so* /usr/local/lib/ |
| 42 | +COPY --from=build /app/server /server |
| 43 | +RUN ldconfig |
| 44 | + |
| 45 | +EXPOSE 8080 8443 |
| 46 | +CMD ["/server"] |
0 commit comments