FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
# https://serverfault.com/a/683651
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list \
    && apt update \
    && apt install -y software-properties-common \
    && add-apt-repository -y ppa:ondrej/php \
    && sed -i 's/ppa.launchpad.net/launchpad.proxy.ustclug.org/g' /etc/apt/sources.list.d/ondrej-ubuntu-php-jammy.list \
    && apt update \
    && apt install -y --no-install-recommends \
    make \
    curl \
    php \
    php-pear \
    php-dev \
    php-curl \
    php-xdebug \
    php-mbstring \
    php-xml \
    php-pgsql \
    libevent-dev \
    && rm -rf /var/lib/apt/lists/*

RUN printf "\n\n\n\n\nno\nyes\n\n" | pecl install event \
    && printf "; priority=30\nextension=event.so\n" > /etc/php/$(ls /etc/php/)/mods-available/event.ini \
    && phpenmod -v $(ls /etc/php/) event \
    && curl -s https://mirrors.aliyun.com/composer/composer.phar -o /usr/local/bin/composer \
    && chmod +x /usr/local/bin/composer \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

WORKDIR /EdgeManager
