Skip to content

Commit b8f8470

Browse files
authored
Merge branch 'datajoint:main' into master
2 parents 8428a50 + 5ad253a commit b8f8470

File tree

4 files changed

+38
-48
lines changed

4 files changed

+38
-48
lines changed

.devcontainer/Dockerfile

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,21 @@
1-
FROM python:3.9-slim@sha256:5f0192a4f58a6ce99f732fe05e3b3d00f12ae62e183886bca3ebe3d202686c7f
2-
3-
ENV PATH /usr/local/bin:$PATH
4-
ENV PYTHON_VERSION 3.9.17
5-
6-
RUN \
7-
adduser --system --disabled-password --shell /bin/bash vscode && \
8-
# install docker
9-
apt-get update && \
10-
apt-get install ca-certificates curl gnupg lsb-release -y && \
11-
mkdir -m 0755 -p /etc/apt/keyrings && \
12-
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
13-
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 && \
14-
apt-get update && \
15-
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y && \
16-
usermod -aG docker vscode && \
17-
apt-get clean
1+
ARG PY_VER
2+
ARG DISTRO
3+
FROM mcr.microsoft.com/devcontainers/python:${PY_VER}-${DISTRO}
184

195
RUN \
206
# dev setup
217
apt update && \
228
apt-get install sudo git gcc bash-completion graphviz default-mysql-client -y && \
23-
usermod -aG sudo vscode && \
24-
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
25-
pip install --no-cache-dir --upgrade black pip && \
26-
echo '. /etc/bash_completion' >> /home/vscode/.bashrc && \
27-
echo 'export PS1="\[\e[32;1m\]\u\[\e[m\]@\[\e[34;1m\]\H\[\e[m\]:\[\e[33;1m\]\w\[\e[m\]$ "' >> /home/vscode/.bashrc && \
9+
pip install --no-cache-dir --upgrade black faker ipykernel pip && \
2810
apt-get clean
2911

12+
# tutorial dependencies
3013
COPY ./requirements.txt /tmp/
31-
3214
RUN \
33-
# tutorial dependencies
34-
pip install --no-cache-dir black faker ipykernel && \
3515
pip install --no-cache-dir -r /tmp/requirements.txt --upgrade && \
3616
rm /tmp/requirements.txt
3717

38-
ENV DJ_HOST fakeservices.datajoint.io
18+
USER root
19+
ENV DJ_HOST db
3920
ENV DJ_USER root
4021
ENV DJ_PASS simple
41-
42-
USER vscode
43-
CMD bash -c "sudo rm /var/run/docker.pid; sudo dockerd"

.devcontainer/devcontainer.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,41 @@
11
{
22
"name": "DataJoint Tutorial",
3-
"dockerComposeFile": "docker-compose.yaml",
3+
"dockerComposeFile": [
4+
"../docker-compose.yml",
5+
"docker-compose.yaml"
6+
],
47
"service": "app",
58
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
69
"remoteEnv": {
710
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
811
},
9-
"onCreateCommand": "pip install -e . && MYSQL_VER=8.0 docker compose down && MYSQL_VER=8.0 docker compose up --build --wait",
10-
"postStartCommand": "docker volume prune -f",
12+
"onCreateCommand": "pip install -q -e .",
13+
"shutdownAction": "stopCompose",
1114
"hostRequirements": {
1215
"cpus": 2,
1316
"memory": "4gb",
1417
"storage": "32gb"
1518
},
1619
"forwardPorts": [
17-
3306
20+
80,
21+
443,
22+
3306,
23+
8080,
24+
9000
1825
],
26+
"features": {
27+
"ghcr.io/devcontainers/features/git:1": {},
28+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
29+
"ghcr.io/devcontainers/features/github-cli:1": {}
30+
},
1931
"customizations": {
2032
"settings": {
2133
"python.pythonPath": "/usr/local/bin/python"
2234
},
2335
"vscode": {
2436
"extensions": [
25-
"ms-python.python@2023.8.0",
26-
"ms-toolsai.jupyter@2023.3.1201040234"
37+
"ms-python.python",
38+
"ms-toolsai.jupyter"
2739
]
2840
}
2941
}

.devcontainer/docker-compose.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
version: "3"
21
services:
32
app:
43
cpus: 2
54
mem_limit: 4g
6-
# build: # build context is used when developing locally
7-
# context: ..
8-
# dockerfile: ./.devcontainer/Dockerfile
5+
build: # build context is used when developing locally
6+
context: .
7+
dockerfile: .devcontainer/Dockerfile
8+
args:
9+
- PY_VER=${PY_VER:-3.11}
10+
- DISTRO=${DISTRO:-buster}
911
image: datajoint/datajoint_tutorials:latest
10-
extra_hosts:
11-
- fakeservices.datajoint.io:127.0.0.1
1212
volumes:
13-
- ..:/workspaces/datajoint-tutorials:cached
13+
- ..:/workspaces:cached
1414
- docker_data:/var/lib/docker # persist docker images
15-
privileged: true # only because of dind
15+
user: root
16+
# Overrides default command so things don't shut down after the process ends.
17+
command: /bin/sh -c "while sleep 1000; do :; done"
1618
volumes:
1719
docker_data:

docker-compose.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# MYSQL_VER=8.0 docker compose up --build
2-
version: "2.4"
32
services:
43
db:
54
restart: always
6-
image: datajoint/mysql:${MYSQL_VER}
5+
image: datajoint/mysql:${MYSQL_VER:-8.0}
76
environment:
8-
- MYSQL_ROOT_PASSWORD=${DJ_PASS}
9-
ports:
10-
- "3306:3306"
7+
- MYSQL_ROOT_PASSWORD=${DJ_PASS:-simple}
8+
command: mysqld --default-authentication-plugin=mysql_native_password
119
healthcheck:
1210
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
1311
timeout: 15s

0 commit comments

Comments
 (0)