From de1c4d7d4a47a87f54ce898f3c9f2055b4571a3c Mon Sep 17 00:00:00 2001 From: Thomas Luechtefeld Date: Wed, 26 Jun 2024 13:51:17 -0400 Subject: [PATCH] added devcontainer to brick-template --- .devcontainer/Dockerfile | 55 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 25 +++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..e5414e5 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,55 @@ +FROM mcr.microsoft.com/devcontainers/python:3.9 + +# Install necessary packages +RUN apt-get update && apt-get install -y \ + wget \ + unzip \ + xvfb \ + libxi6 \ + libgconf-2-4 \ + libnss3-dev \ + libxss1 \ + libappindicator1 \ + fonts-liberation \ + libatk-bridge2.0-0 \ + libgtk-3-0 \ + libgbm1 \ + libasound2 \ + libdpkg-perl \ + libatomic1 \ + ca-certificates \ + curl \ + gnupg \ + python3-venv \ + awscli + +# Install pipx and biobricks +RUN python3 -m pip install --user pipx \ + && python3 -m pipx ensurepath + +# Create /mnt/biobricks directory and set permissions +RUN mkdir -p /mnt/biobricks/biobricks-ai \ + && chown -R vscode:vscode /mnt/biobricks + +# Add pipx binaries to the PATH for all users +RUN echo 'export PATH="$PATH:$HOME/.local/bin"' >> /etc/bash.bashrc \ + && echo 'export PATH="$PATH:$HOME/.local/bin"' >> /home/vscode/.bashrc + +# Switch to vscode user to perform user-specific installations +USER vscode + +# Install Python dependencies +COPY requirements.txt /tmp/requirements.txt +RUN pip install -r /tmp/requirements.txt + +# Accept build argument for BIOBRICKS_TOKEN +ARG BIOBRICKS_TOKEN +ENV BIOBRICKS_TOKEN=${BIOBRICKS_TOKEN} + +# Install biobricks and configure it +RUN /bin/bash -c 'source /etc/bash.bashrc && pipx install biobricks && biobricks version' \ + && /bin/bash -c 'if [ -z "$BIOBRICKS_TOKEN" ] || [ ${#BIOBRICKS_TOKEN} -lt 5 ]; then echo "BIOBRICKS_TOKEN is not set or is too short (less than 5 characters)"; exit 1; fi' \ + && /bin/bash -c 'source /etc/bash.bashrc && biobricks configure --bblib=/mnt/biobricks --token=${BIOBRICKS_TOKEN} --interactive=False' + +# Switch back to root user to complete setup +USER root diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..370b64d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,25 @@ +{ + "name": "SMRT Development Container", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + "BIOBRICKS_TOKEN": "${localEnv:BIOBRICKS_TOKEN}" + } + }, + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:1": {} + }, + "settings": { + "terminal.integrated.defaultProfile.linux": "bash", + "python.pythonPath": "/usr/local/bin/python" + }, + "extensions": [ + "ms-python.python", + "ms-toolsai.jupyter", + "ms-vsliveshare.vsliveshare", // Live Share extension + "github.copilot", // GitHub Copilot extension + "insilica.vscode-pycmd" + ], + "remoteUser": "vscode" +}