-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from guzman-raphael/reduce-image
Optimize DevContainer
- Loading branch information
Showing
5 changed files
with
87 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,39 @@ | ||
FROM mcr.microsoft.com/devcontainers/python:3.7-bullseye | ||
FROM python:3.7-slim | ||
|
||
RUN \ | ||
adduser --system --disabled-password --shell /bin/bash vscode && \ | ||
# install docker | ||
apt-get update && \ | ||
apt-get install ca-certificates curl gnupg lsb-release -y && \ | ||
mkdir -m 0755 -p /etc/apt/keyrings && \ | ||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \ | ||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \ | ||
apt-get update && \ | ||
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y && \ | ||
usermod -aG docker vscode && \ | ||
apt-get clean | ||
|
||
RUN \ | ||
# dev setup | ||
apt update && \ | ||
apt-get install bash-completion graphviz default-mysql-client -y && \ | ||
pip install flake8 black faker ipykernel | ||
apt-get install sudo git bash-completion graphviz default-mysql-client -y && \ | ||
usermod -aG sudo vscode && \ | ||
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \ | ||
pip install --no-cache-dir --upgrade black pip && \ | ||
echo '. /etc/bash_completion' >> /home/vscode/.bashrc && \ | ||
echo 'export PS1="\[\e[32;1m\]\u\[\e[m\]@\[\e[34;1m\]\H\[\e[m\]:\[\e[33;1m\]\w\[\e[m\]$ "' >> /home/vscode/.bashrc && \ | ||
# dircolors -b >> /home/vscode/.bashrc && \ # somehow fix colors | ||
apt-get clean | ||
COPY ./requirements.txt /tmp/ | ||
RUN \ | ||
# tutorial dependencies | ||
pip install --no-cache-dir black faker ipykernel && \ | ||
pip install --no-cache-dir -r /tmp/requirements.txt && \ | ||
rm /tmp/requirements.txt | ||
|
||
ENV DJ_HOST fakeservices.datajoint.io | ||
ENV DJ_USER root | ||
ENV DJ_PASS simple | ||
ENV DJ_PASS simple | ||
|
||
USER vscode | ||
CMD bash -c "sudo rm /var/run/docker.pid; sudo dockerd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
version: "3" | ||
services: | ||
app: | ||
build: . | ||
cpus: 2 | ||
mem_limit: 4g | ||
build: | ||
context: .. | ||
dockerfile: ./.devcontainer/Dockerfile | ||
extra_hosts: | ||
- fakeservices.datajoint.io:127.0.0.1 | ||
volumes: | ||
- ../..:/workspaces:cached | ||
entrypoint: /usr/local/share/docker-init.sh | ||
command: tail -f /dev/null | ||
- docker_data:/var/lib/docker # persist docker images | ||
privileged: true # only because of dind | ||
volumes: | ||
docker_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,42 +24,34 @@ Interactive tutorials on the DataJoint framework, in Python. Throughout this set | |
- `.populate()` for automated computation | ||
- `.populate(reserve_jobs=True)` for parallelization | ||
|
||
## Getting started | ||
## Interactive Tutorial | ||
|
||
The easiest way to learn about the basics of DataJoint is to use these tutorial notebooks within a [GitHub Codespace](https://docs.github.com/en/codespaces/overview). Please follow the steps below for the best experience: | ||
The easiest way to learn DataJoint is to use the tutorial notebooks within the included interactive environment configured using [DevContainer](https://containers.dev/). | ||
|
||
1. Fork this repository to your GitHub account. | ||
### Launch Environment | ||
|
||
2. Select the green `Code` button. | ||
Here are some options that provide a great experience: | ||
|
||
3. Within the dropdown menu, select the `Codespaces` tab. | ||
- **Cloud-based IDE**: (*recommended*) | ||
- Launch using [GitHub Codespaces](https://github.com/features/codespaces) using the `+` option which will `Create codespace on main` in the codebase repository on your fork with default options. For more control, see the `...` where you may create `New with options...`. | ||
- Build time for a codespace is **~5m**. This is done infrequently and cached for convenience. | ||
- Start time for a codespace is **~30s**. This will pull the built codespace from cache when you need it. | ||
- *Tip*: Each month, GitHub renews a [free-tier](https://docs.github.com/en/billing/managing-billing-for-github-codespaces/about-billing-for-github-codespaces#monthly-included-storage-and-core-hours-for-personal-accounts) quota of compute and storage. Typically we run into the storage limits before anything else since Codespaces consume storage while stopped. It is best to delete Codespaces when not actively in use and recreate when needed. We'll soon be creating prebuilds to avoid larger build times. Once any portion of your quota is reached, you will need to wait for it to be reset at the end of your cycle or add billing info to your GitHub account to handle overages. | ||
- *Tip*: GitHub auto names the codespace but you can rename the codespace so that it is easier to identify later. | ||
- **Local IDE**: | ||
- Ensure you have [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) | ||
- Ensure you have [Docker](https://docs.docker.com/get-docker/) | ||
- Ensure you have [VSCode](https://code.visualstudio.com/) | ||
- Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) | ||
- `git clone` the codebase repository and open it in VSCode | ||
- Use the `Dev Containers extension` to `Reopen in Container` (More info in the `Getting started` included with the extension) | ||
|
||
4. Select the green `Create codespace on main` button. | ||
You will know your environment has finished loading once you either see a terminal open related to `Running postStartCommand` with a final message: `Done` or the `README.md` is opened in `Preview`. | ||
|
||
5. The environment is ready when a Visual Studio Code window is rendered within your browser. This takes ~5 minutes the first time being launched, and ~1 minute if you revisit this Codespace. | ||
### Instructions | ||
|
||
6. Navigate to the `00-Getting_Started` directory on the left panel and open the `00-Getting Started.ipynb` Jupyter notebook. Execute the cells in this notebook to begin your walk through the tutorials. We recommend finishing all notebooks in `00-Getting_Started` before proceeding to `01-Calcium_Imaging` and `02-Electrophysiology`. | ||
1. We recommend you start by navigating to the `notebooks` directory on the left panel and go through the `00-Getting_Started/01-DataJoint Basics - Interactive.ipynb` Jupyter notebook. Execute the cells in the notebooks to begin your walk through of the tutorial. | ||
|
||
7. Once you are done, GitHub will automatically stop the Codespace after 30 minutes of inactivity or you can manually stop the Codespace. | ||
1. Once you are done, see the options available to you in the menu in the bottom-left corner. For example, in Codespace you will have an option to `Stop Current Codespace` but when running DevContainer on your own machine the equivalent option is `Reopen folder locally`. By default, GitHub will also automatically stop the Codespace after 30 minutes of inactivity. | ||
|
||
8. After stopping the Codespace, we recommend deleting the Codespace to save on storage costs, which are free for the first 15 GB-month. | ||
|
||
+ If you are new to GitHub and run into any errors, please contact us via email at [email protected]. If you are experienced with GitHub, please create an issue on the upstream repository or issue a pull request with a thorough explanation of the error and proposed solution. | ||
|
||
+ **Please Note:** GitHub Codespaces are limited to 120 core-hours per month and 15 GB-month for free users. Once you exceed this limit, you will have to wait for the usage quota to reset or pay to use Codespaces. | ||
|
||
## Run in Local Development Environment | ||
|
||
- Install [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) | ||
|
||
- Install [Docker](https://docs.docker.com/get-docker/) | ||
|
||
- Install [VSCode](https://code.visualstudio.com/) | ||
|
||
- Install the VSCode [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) | ||
|
||
- `git clone` the codebase repository and open it in VSCode | ||
|
||
- Use the `Dev Containers extension` to `Reopen in Container` (More info in the `Getting started` included with the extension.) | ||
|
||
- You will know your environment has finished loading once you see a terminal open related to `Running postStartCommand` with a final message: `Done`. | ||
If you are new to GitHub and run into any errors, please contact us via email at [email protected]. If you are experienced with GitHub, please create an issue on the upstream repository or if you'd like help contribute, feel free to create a pull request. Please include a thorough explanantion of the error and/or proposed solution. |