FROM php:7.2-alpine

# postgresql-dev: required for build of pgsql (includes libpq-fe.h)
# zlib-dev: required by zip module
# yarn: called by artisan koel:init to prepare frontend
RUN apk add \
    composer \
    git \
    postgresql-dev \
    yarn \
    zlib-dev

# TODO check if pgsql may be removed
RUN docker-php-ext-install -j$(nproc) \
    exif \
    pdo_pgsql \
    pgsql \
    zip

RUN git clone --branch master --recurse-submodules \
    https://github.com/phanan/koel /koel
WORKDIR /koel

# In Encrypter.php line 43:
# The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
RUN sed 's/^APP_KEY=$/APP_KEY=WORKAROUND_000000000000000000000/' .env.example >.env
RUN composer install --no-interaction
# TODO revert workaround

RUN yarn install

CMD ["sh"]