# This file is part of LilyPond, the GNU music typesetter.
#
# Copyright (C) 2020--2022  Jonas Hahnfeld <hahnjo@hahnjo.de>
#
# LilyPond is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LilyPond is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.

FROM ubuntu:18.04 as build
RUN apt-get update && apt-get install --no-install-recommends -y \
        ca-certificates \
        wget \
    && true
# Download and extract urw-base35-fonts - we cannot use the available package
# fonts-urw-base35 which comes without the *.otf files. Do this in a build
# container to not distribute the whole archive, only the *.otf files.
# Do not use ADD which doesn't cache the downloaded archive. Once released, it
# will never change.
RUN wget -q https://github.com/ArtifexSoftware/urw-base35-fonts/archive/20170801.1.tar.gz \
    && mkdir -p /usr/share/fonts/otf/ && tar -C /usr/share/fonts/otf/ \
        -xf /20170801.1.tar.gz --strip-components=2 --wildcards '*/fonts/*.otf'

FROM ubuntu:18.04
COPY --from=build /usr/share/fonts/otf/ /usr/share/fonts/otf/
RUN apt-get update && apt-get --no-install-recommends install -y \
        autoconf \
        bison \
        ca-certificates \
        flex \
        fontconfig \
        fontforge \
        fonts-texgyre \
        g++ \
        gettext \
        ghostscript \
        git \
        guile-2.2-dev \
        imagemagick \
        libfl-dev \
        libfontconfig1-dev \
        libfreetype6-dev \
        libglib2.0-dev \
        libgs-dev \
        libpango1.0-dev \
        lmodern \
        make \
        perl \
        pkgconf \
        python3 \
        rsync \
        texi2html \
        texinfo \
        texlive-binaries \
        texlive-fonts-recommended \
        texlive-font-utils \
        texlive-lang-cyrillic \
        texlive-metapost \
        texlive-plain-generic \
        wget \
        zip \
    && rm -rf /var/lib/apt/lists/* \
    && rm -rf /usr/share/doc /usr/share/man \
    && git config --system --add safe.directory '*'

# This last command is needed to allow invoking git in the container, running as
# nobody, on a repository owned by a different user. See the explanation here:
# https://github.blog/2022-04-18-highlights-from-git-2-36/#stricter-repository-ownership-checks
