FROM golang:1.19-alpine AS builder WORKDIR /src ENV CFLAGS="-march=native -Ofast -flto" ENV CXXFLAGS="-march=native -Ofast -flto" ENV LDFLAGS="-flto" ENV CGO_CFLAGS="-march=native -Ofast" RUN apk update && apk add --no-cache \ git gcc g++ musl-dev bash autoconf automake cmake make libtool gettext \ openssl-dev RUN git clone --depth 1 --branch v1.2.6 https://github.com/jiixyj/libebur128.git && cd libebur128 && \ mkdir build && cd build && \ cmake .. -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX:PATH=/usr && \ make -j$(nproc) && \ make install && \ cd ../.. RUN git clone --depth 1 --branch 0.2.2 https://github.com/libsndfile/libsamplerate.git && cd libsamplerate && \ ./autogen.sh && \ ./configure --prefix /usr && \ make -j$(nproc) && \ make install && \ cd .. RUN wget https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz -O lame-3.100.tar.gz && \ tar -xzvf lame-3.100.tar.gz && \ cd lame-3.100 && \ ./configure --prefix /usr && \ make -j$(nproc) && \ make install && \ cd .. RUN git clone --depth 1 --branch v1.3.5 https://gitlab.xiph.org/xiph/ogg.git && cd ogg && \ ./autogen.sh && \ ./configure --prefix /usr && \ make -j$(nproc) && \ make install && \ cd .. RUN git clone --branch master https://gitlab.xiph.org/xiph/opus.git && cd opus && \ ./autogen.sh && \ ./configure --enable-float-approx --prefix /usr && \ make -j$(nproc) && \ make install && \ cd .. RUN git clone --depth 1 --branch v0.12 https://gitlab.xiph.org/xiph/opusfile.git && cd opusfile && \ ./autogen.sh && \ ./configure --prefix /usr && \ make -j$(nproc) && \ make install && \ cd .. RUN git clone --depth 1 --branch master https://gitlab.xiph.org/xiph/libopusenc.git && cd libopusenc && \ ./autogen.sh && \ ./configure --prefix /usr && \ make -j$(nproc) && \ make install && \ cd .. RUN git clone --depth 1 --branch v1.3.7 https://gitlab.xiph.org/xiph/vorbis.git && cd vorbis && \ ./autogen.sh && \ ./configure --prefix /usr && \ make -j$(nproc) && \ make install && \ cd .. RUN git clone --depth 1 --branch 1.3.4 https://gitlab.xiph.org/xiph/flac.git && cd flac && \ ./autogen.sh && \ ./configure --prefix /usr && \ make -j$(nproc) && \ make install && \ cd .. RUN git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git && cd fdk-aac && \ ./autogen.sh && \ ./configure --prefix /usr && \ make -j$(nproc) && \ make install && \ cd .. RUN git clone --depth 1 https://git.gammaspectra.live/S.O.N.G/alac.git && cd alac && \ autoreconf -fi && \ ./configure --prefix /usr && \ make -j$(nproc) && \ make install && \ cd .. RUN rm -rf /src/libebur128 /src/libsamplerate /src/lame-3.100 /src/ogg /src/opus /src/opusfile /src/vorbis /src/flac /src/libopusenc /src/fdk-aac /src/alac COPY . /code WORKDIR /code RUN go build -v -o /usr/bin/MeteorLight . && rm -rf /code FROM alpine:latest COPY --from=builder /usr/lib/libmp3lame* /usr/lib/ COPY --from=builder /usr/lib/libsamplerate* /usr/lib/ COPY --from=builder /usr/lib/libfdk* /usr/lib/ COPY --from=builder /usr/lib/libFLAC* /usr/lib/ COPY --from=builder /usr/lib/libopus* /usr/lib/ COPY --from=builder /usr/lib/libogg* /usr/lib/ COPY --from=builder /usr/lib/libvorbis* /usr/lib/ COPY --from=builder /usr/lib/libebur128* /usr/lib/ COPY --from=builder /usr/lib/libalac* /usr/lib/ COPY --from=builder /usr/bin/MeteorLight /usr/bin/MeteorLight WORKDIR / ENTRYPOINT ["/usr/bin/MeteorLight"]