FROM php:8.2-cli

# Install dependencies needed for Composer and PHP zip extension
RUN echo "deb http://deb.debian.org/debian bookworm contrib non-free" > /etc/apt/sources.list.d/contrib.list
RUN apt-get update && apt-get install -y \
    curl \
    unzip \
    libzip-dev \
    libreoffice \
    fontconfig \
    gcc \
    g++ \
    build-essential \
    ttf-mscorefonts-installer \
    && docker-php-ext-install zip \
    && rm -rf /var/lib/apt/lists/*

# Install fonts
RUN mkdir -p /usr/share/fonts/truetype/custom
COPY ./fonts/gilroy/*   /usr/share/fonts/truetype/custom
COPY ./fonts/lexend/*   /usr/share/fonts/truetype/custom
RUN fc-cache -f -v

# Download and install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Verify Composer installation
RUN composer --version

# Install Golang
RUN curl -OL https://go.dev/dl/go1.23.0.linux-arm64.tar.gz \
    && tar -C /usr/local -xzf go1.23.0.linux-arm64.tar.gz \
    && rm go1.23.0.linux-arm64.tar.gz

# Set Go environment variables
ENV PATH="/usr/local/go/bin:${PATH}"

# Verify Go installation
RUN go version

RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b /usr/local/bin

WORKDIR /app/gosrc

CMD ["air", "-c", ".air.toml", "--", "run"]

EXPOSE 80
