FROM debian:bookworm-slim

ARG GITEA_VERSION=1.27.3

RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    curl \
    git \
    && rm -rf /var/lib/apt/lists/*

RUN curl -fsSL -o /usr/local/bin/gitea \
    "https://dl.gitea.com/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-amd64" \
    && chmod +x /usr/local/bin/gitea

RUN useradd -m -d /data -s /usr/sbin/nologin git

COPY conf/app.ini.template /etc/gitea/app.ini.template
COPY tools/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

EXPOSE 3000

ENTRYPOINT ["entrypoint.sh"]
