FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# Install required dependencies
RUN apt-get update && \
    apt-get install -y curl git xvfb unzip

# Install Deno
RUN curl -fsSL https://deno.land/install.sh | sh && \
    echo 'export DENO_INSTALL="$HOME/.deno"' >> ~/.bashrc && \
    echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> ~/.bashrc && \
    ln -s $HOME/.deno/bin/deno /usr/local/bin/deno

# Clone the repository and set permissions
RUN git clone https://github.com/bids-standard/bids-validator.git /home/gitlab-runner/bids-validator && \
    chmod +x /home/gitlab-runner/bids-validator/local-run

RUN /home/gitlab-runner/bids-validator/local-run || true

# Set the PATH explicitly
ENV DENO_INSTALL="/root/.deno"
ENV PATH="$DENO_INSTALL/bin:$PATH"

RUN curl -LOs https://github.com/wieluk/psychopy_linux_installer/releases/latest/download/psychopy_linux_installer && \
    chmod +x psychopy_linux_installer && \
    for pyver in 3.8 3.9 3.10; do \
        for psychver in 2024.2.5 2025.2.4 2026.1.1; do \
            if [ "$pyver" = "3.8" ] && [ "$psychver" != "2024.2.5" ]; then \
                continue; \
            fi; \
            ./psychopy_linux_installer --python-version=$pyver \
                                       --psychopy-version=$psychver \
                                       --install-dir=/home/gitlab-runner \
                                       --venv-name=psychopy_${pyver}_${psychver} \
                                       --additional-packages=pytest,pytest-cov,seedir,psychopy-bids \
                                       --non-interactive \
                                       --disable-path \
                                       --disable-shortcut \
                                       --no-fonts \
                                       -f; \
        done; \
    done && \           
    rm psychopy_linux_installer && \
    apt-get clean && rm -rf /var/lib/apt/lists/*
