81 lines
2.4 KiB
Docker
81 lines
2.4 KiB
Docker
FROM alpine:3.21.3 AS build
|
|
|
|
# Build type used by conan. "Debug" and "Release" are supported.
|
|
ARG BUILD_TYPE=Release
|
|
|
|
RUN mkdir -p /root/.local/bin
|
|
ENV PATH="${PATH}:/root/.local/bin"
|
|
|
|
# Install packages needed in both building and running.
|
|
RUN apk update && \
|
|
apk add --no-cache \
|
|
libstdc++
|
|
|
|
# Install tools required for building.
|
|
RUN apk add --no-cache \
|
|
autoconf \
|
|
bash \
|
|
build-base \
|
|
cmake \
|
|
clang \
|
|
clang-extra-tools \
|
|
gdb \
|
|
git \
|
|
libtool \
|
|
linux-headers \
|
|
ninja \
|
|
m4 \
|
|
perl \
|
|
python3 \
|
|
pipx && \
|
|
pipx ensurepath
|
|
RUN pipx install conan && \
|
|
conan profile detect
|
|
|
|
# Pre-build some conan packages we require and take a lot of time to build. This to
|
|
# avoid expensive rebuilding everytime we need a fresh dev container..
|
|
RUN mkdir -p /workspaces/tmp
|
|
WORKDIR /workspaces/tmp
|
|
RUN conan install -s build_type=${BUILD_TYPE} -b=* --requires=boost/1.89.0
|
|
RUN conan install -s build_type=${BUILD_TYPE} -b=* --requires=libmagic/5.45
|
|
RUN conan install -s build_type=${BUILD_TYPE} -b=* --requires=freetype/2.14.1
|
|
RUN conan install -s build_type=${BUILD_TYPE} -b=missing --requires=gtest/1.14.0
|
|
RUN conan install -s build_type=${BUILD_TYPE} -b=missing --requires=libjpeg/9f
|
|
WORKDIR /workspaces
|
|
RUN rm -rf tmp
|
|
|
|
# Remove the temporary workspace, build results for the conan packages remain cached.
|
|
WORKDIR /workspaces
|
|
RUN rm -rf tmp && \
|
|
mkdir network-experiment && \
|
|
mkdir build && \
|
|
mkdir install
|
|
|
|
# Build and install
|
|
WORKDIR /workspaces/network-experiment
|
|
ADD . .
|
|
RUN conan install /workspaces/network-experiment -of /workspaces/build -s build_type=${BUILD_TYPE}
|
|
RUN cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -S . -B /workspaces/build --install-prefix=/workspaces/install
|
|
RUN cmake --build /workspaces/build --parallel
|
|
RUN cmake --install /workspaces/build
|
|
|
|
|
|
|
|
FROM alpine:3.21.3
|
|
|
|
RUN apk update && \
|
|
apk add --no-cache \
|
|
libstdc++
|
|
|
|
RUN mkdir -p /workspaces/network-experiment/applications/http-mandelbrot/html
|
|
|
|
COPY --from=build /workspaces/install/bin/http-mandelbrot /bin
|
|
COPY --from=build /workspaces/install/bin/magic.mgc /bin
|
|
COPY --from=build /workspaces/network-experiment/applications/http-mandelbrot/html /workspaces/network-experiment/applications/http-mandelbrot/html
|
|
|
|
WORKDIR /bin
|
|
ENTRYPOINT ["http-mandelbrot"]
|
|
EXPOSE 9800/tcp
|
|
|
|
|