#
# SPDX-License-Identifier: GPL-3.0-or-later
# myMPD (c) 2018-2026 Juergen Mang <mail@jcgames.de>
# https://github.com/jcorporation/mympd
#

# Stage 1
FROM alpine:latest AS build
COPY . /myMPD/
WORKDIR /myMPD
RUN <<EOF
set -ex
./build.sh installdeps
cmake -B "release" -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=Release -DMYMPD_MANPAGES=OFF -DMYMPD_DOC=OFF .
cmake --build release
EOF

# Stage 2
FROM alpine:latest
RUN <<EOF
set +ex
apk update
apk upgrade
apk add --no-cache openssl libid3tag flac lua5.4 pcre2 newt ca-certificates utf8proc
adduser -D -H -h /var/lib/mympd -s /sbin/nologin -g myMPD -u 1000 mympd
EOF
COPY --from=build /myMPD/release/bin/mympd /usr/bin/
COPY --from=build /myMPD/release/bin/mympd-script /usr/bin/
COPY --from=build /myMPD/cli_tools/mympd-config/mympd-config /usr/bin/

USER mympd
ENTRYPOINT ["/usr/bin/mympd"]
