FROM redmine:5.1.3-bookworm

ENV REDMINE_PATH=/usr/src/redmine \
    REDMINE_LOCAL_PATH=/var/local/redmine

WORKDIR $REDMINE_PATH

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        unzip cron curl \
    && rm -rf /var/lib/apt/lists/*

COPY plugins/ ./plugins
COPY themes/ ./public/themes

RUN unzip ./plugins/\*.zip -d ./plugins \
    && unzip ./public/themes/\*.zip -d ./public/themes \
    && chmod -R 755 ./plugins/* \
    && rm ./plugins/*.zip \
    && rm ./public/themes/*.zip

COPY entrypoint.sh update-repositories.sh ${REDMINE_LOCAL_PATH}/scripts/
COPY crontab ${REDMINE_LOCAL_PATH}/

ENTRYPOINT ["/var/local/redmine/scripts/entrypoint.sh"]
CMD []
