FROM alpine:3.13

ENV LDFLAGS="-static-libgcc -static-libstdc++ -static"

RUN apk add --no-cache \
  build-base cmake git meson pkgconf doxygen graphviz zip \
  libarchive-static libarchive-dev \
  libressl-dev \
  tclap-dev \
  bzip2-static acl-static expat-static zstd-static lz4-static zlib-static xz-dev

WORKDIR /build/

RUN git clone --depth 1 --branch 7.1.3 https://github.com/fmtlib/fmt.git \
  && git clone --depth 1 --branch v1.8.2 https://github.com/gabime/spdlog.git

RUN cd fmt && mkdir build && cd build \
  && cmake -DFMT_DOC=FALSE -DFMT_TEST=FALSE -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE --target fmt .. && make -j && make install

RUN cd spdlog && mkdir build && cd build \
  && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE .. && make -j && make install

COPY ./entrypoint.sh /usr/local/bin
CMD ["entrypoint.sh"]