FROM alpine
RUN apk update && apk add \
	autoconf \
	automake \
	gettext \
	pkgconfig \
	make \
	gcc \
	musl-dev \
	wget
COPY --from=libopenssl:3.1.1-minimal /opt/spm/openssl-3.1.1/ /usr/local/
COPY --from=liblibretls:3.8.1 /opt/spm/libretls-3.8.1/ /usr/local/
COPY --from=libevent:2.1.12 /opt/spm/libevent-2.1.12/ /usr/local/
COPY --from=libncurses:6.3 /opt/spm/ncurses-6.3/ /usr/local/
COPY --from=libbison:3.8.2 /opt/spm/bison-3.8.2/ /usr/local/
RUN wget https://codeberg.org/op/telescope/archive/0.8.1.tar.gz
RUN tar -xf 0.8.1.tar.gz
WORKDIR /telescope
ARG PREFIX=/opt/spm/telescope-0.8.1
RUN ./autogen.sh
RUN ./configure \
    --prefix=$PREFIX \
    CFLAGS='-ffunction-sections -fdata-sections -Os' \
    LDFLAGS="-Wl,--gc-sections -static" \
    LIBS="-lssl -lcrypto"
RUN make -j$(nproc --all)
RUN make install
RUN strip $PREFIX/bin/telescope
