FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.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 /bids-validator && \
    chmod +x /bids-validator/local-run

RUN /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 && \
    ./psychopy_linux_installer \
        --python-version=3.10 \
        --psychopy-version=latest \
        --install-dir=/psychopy \
        --venv-name=psychopy-test-installation \
        --additional-packages=pytest,codespell,autopep8,black,isort,bandit,flake8,pylint,seedir \
        --non-interactive \
        --disable-shortcut \
        -f && \
    rm psychopy_linux_installer && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

    RUN cd /psychopy/psychopy-test-installation/.venv/bin \
    && for file in *; do \
        echo "Linking $file to /usr/local/bin/$file"; \
        ln -sf "/psychopy/psychopy-test-installation/.venv/bin/$file" "/usr/local/bin/$file"; \
    done
