dev container files
Browse files- .devcontainer/Dockerfile +67 -0
- .devcontainer/devcontainer.json +51 -0
- .devcontainer/requirements.txt +13 -0
- .devcontainer/setup.sh +23 -0
.devcontainer/Dockerfile
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Build: sudo docker build -t <project_name> .
|
| 2 |
+
# Run: sudo docker run -v $(pwd):/workspace/project --gpus all -it --rm <project_name>
|
| 3 |
+
|
| 4 |
+
ARG USERNAME=kitt
|
| 5 |
+
ARG USER_UID=1005
|
| 6 |
+
ARG USER_GID=100
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
FROM nvidia/cuda:12.1.1-base-ubuntu22.04
|
| 10 |
+
|
| 11 |
+
ENV PYTHON_VERSION=3.10
|
| 12 |
+
|
| 13 |
+
ENV PATH /opt/conda/bin:$PATH
|
| 14 |
+
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib"
|
| 15 |
+
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/conda/lib"
|
| 16 |
+
|
| 17 |
+
ENV PYTHONIOENCODING=UTF-8
|
| 18 |
+
ENV LANG=C.UTF-8
|
| 19 |
+
ENV LC_ALL=C.UTF-8
|
| 20 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 21 |
+
ENV PYTHONUNBUFFERED=1
|
| 22 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 23 |
+
ENV CONDA_AUTO_UPDATE_CONDA=false
|
| 24 |
+
|
| 25 |
+
RUN apt update
|
| 26 |
+
RUN apt install -y bash \
|
| 27 |
+
build-essential \
|
| 28 |
+
git \
|
| 29 |
+
curl \
|
| 30 |
+
ca-certificates \
|
| 31 |
+
wget \
|
| 32 |
+
&& rm -rf /var/lib/apt/lists
|
| 33 |
+
|
| 34 |
+
RUN echo $USERNAME
|
| 35 |
+
RUN echo $USER_UID
|
| 36 |
+
RUN echo $USER_GID
|
| 37 |
+
|
| 38 |
+
# Create the user
|
| 39 |
+
RUN groupadd -f --gid 100 users \
|
| 40 |
+
&& useradd --uid 1005 --gid 100 -m kitt -s /bin/bash
|
| 41 |
+
|
| 42 |
+
RUN mkdir /opt/conda \
|
| 43 |
+
&& chown -R kitt:users /opt/conda
|
| 44 |
+
|
| 45 |
+
USER kitt
|
| 46 |
+
|
| 47 |
+
# Install Miniconda and create main env
|
| 48 |
+
ADD --chown=kitt:users --chmod=744 https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh /tmp/miniconda3.sh
|
| 49 |
+
RUN ls -laxoh .
|
| 50 |
+
RUN /bin/bash /tmp/miniconda3.sh -b -u -p /opt/conda \
|
| 51 |
+
&& rm /tmp/miniconda3.sh \
|
| 52 |
+
&& /opt/conda/bin/conda install -y -c anaconda \
|
| 53 |
+
python=$PYTHON_VERSION \
|
| 54 |
+
&& /opt/conda/bin/conda clean -ya
|
| 55 |
+
|
| 56 |
+
RUN /opt/conda/bin/conda config --set ssl_verify False \
|
| 57 |
+
&& pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org \
|
| 58 |
+
&& echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc \
|
| 59 |
+
&& echo "conda activate base" >> ~/.bashrc
|
| 60 |
+
# && ln -s /opt/conda/bin/pip /usr/local/bin/pip3
|
| 61 |
+
|
| 62 |
+
# Install requirements
|
| 63 |
+
COPY --chown=kitt:users requirements.txt /tmp
|
| 64 |
+
RUN pip install --no-cache-dir -r /tmp/requirements.txt \
|
| 65 |
+
&& rm /tmp/requirements.txt
|
| 66 |
+
|
| 67 |
+
CMD ["/bin/bash"]
|
.devcontainer/devcontainer.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "Dockerfile",
|
| 3 |
+
"context": "..",
|
| 4 |
+
"dockerFile": "./Dockerfile",
|
| 5 |
+
"postCreateCommand": "chmod +x ./.devcontainer/setup.sh && sh ./.devcontainer/setup.sh",
|
| 6 |
+
"runArgs": [
|
| 7 |
+
// if you have a GPU, you can use it inside the container
|
| 8 |
+
"--gpus=all",
|
| 9 |
+
// speeds up pytorch data loading
|
| 10 |
+
"--ipc=host"
|
| 11 |
+
],
|
| 12 |
+
"mounts": [
|
| 13 |
+
// important: see respective sections in setup.sh
|
| 14 |
+
// uncomment if you want to use your local aws credentials
|
| 15 |
+
//"source=${env:HOME}${env:USERPROFILE}/.aws,target=/root/.aws,type=bind",
|
| 16 |
+
// uncomment if you want to use the host docker socket inside the container
|
| 17 |
+
//"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
|
| 18 |
+
"source=${env:HOME}${env:USERPROFILE}/.cache/huggingface,target=/home/kitt/.cache/huggingface,type=bind",
|
| 19 |
+
"source=${env:HOME}${env:USERPROFILE}/.local/share/tts,target=/home/kitt/.local/share/tts,type=bind"
|
| 20 |
+
],
|
| 21 |
+
// "remoteUser": "kitt",
|
| 22 |
+
"customizations": {
|
| 23 |
+
"vscode": {
|
| 24 |
+
"extensions": [
|
| 25 |
+
// official docker extension to control docker on the host
|
| 26 |
+
"ms-azuretools.vscode-docker",
|
| 27 |
+
// github copilot
|
| 28 |
+
"github.copilot",
|
| 29 |
+
// gitlens - helps working in repositories
|
| 30 |
+
"eamodio.gitlens",
|
| 31 |
+
// python language support
|
| 32 |
+
"ms-python.python",
|
| 33 |
+
"ms-python.vscode-pylance",
|
| 34 |
+
// sort python imports
|
| 35 |
+
"ms-python.isort",
|
| 36 |
+
// jupyter
|
| 37 |
+
"ms-toolsai.jupyter",
|
| 38 |
+
"ms-toolsai.vscode-jupyter-cell-tags",
|
| 39 |
+
"ms-toolsai.jupyter-renderers",
|
| 40 |
+
"ms-toolsai.vscode-jupyter-slideshow",
|
| 41 |
+
// autocomplete filenames
|
| 42 |
+
"christian-kohler.path-intellisense",
|
| 43 |
+
// displays system usage in the bottom tray
|
| 44 |
+
"mutantdino.resourcemonitor",
|
| 45 |
+
// yaml language support
|
| 46 |
+
"redhat.vscode-yaml"
|
| 47 |
+
// "add.your.own.favorites",
|
| 48 |
+
]
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
}
|
.devcontainer/requirements.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# these requirements are only required for development inside vscode
|
| 2 |
+
pre-commit # hooks for applying linters on commit
|
| 3 |
+
black # code formatting
|
| 4 |
+
isort # import sorting
|
| 5 |
+
flake8 # code analysis
|
| 6 |
+
pylint # code analysis
|
| 7 |
+
bandit # security analysis
|
| 8 |
+
ipykernel # jupyter kernel for vscode
|
| 9 |
+
|
| 10 |
+
# auxiliary requirements
|
| 11 |
+
read-version
|
| 12 |
+
wheel
|
| 13 |
+
setuptools
|
.devcontainer/setup.sh
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# install dev requirements
|
| 4 |
+
pip install --no-cache-dir -r ./.devcontainer/requirements.txt
|
| 5 |
+
|
| 6 |
+
cd /tmp
|
| 7 |
+
|
| 8 |
+
# install docker to interact with the host if you plan to use remote docker inside the devcontainer
|
| 9 |
+
# for example to train a model on the host but in a container, too
|
| 10 |
+
# curl -fsSL https://get.docker.com -o get-docker.sh
|
| 11 |
+
# sh get-docker.sh
|
| 12 |
+
|
| 13 |
+
# install aws cli to interact with the aws cli from the devcontainer
|
| 14 |
+
# don't forget to configure the aws cli with your credentials inside devcontainer.json
|
| 15 |
+
# apt-get install zip -y
|
| 16 |
+
# curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
|
| 17 |
+
# unzip awscliv2.zip
|
| 18 |
+
# ./aws/install
|
| 19 |
+
|
| 20 |
+
# Install diff-so-fancy
|
| 21 |
+
mkdir -p /opt/diff-so-fancy/
|
| 22 |
+
curl -fsSL https://github.com/so-fancy/diff-so-fancy/archive/v1.4.4.tar.gz | tar -xz -C /opt/diff-so-fancy --strip-components=1
|
| 23 |
+
ln -sf /opt/diff-so-fancy/diff-so-fancy /usr/local/bin
|