Skip to content

Commit 6d77392

Browse files
authored
Merge pull request #1115 from ethho/fix-dev-container
Fix dev container
2 parents 8276d5c + 4b7a68c commit 6d77392

File tree

8 files changed

+79
-39
lines changed

8 files changed

+79
-39
lines changed

.devcontainer/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
# Note: You can use any Debian/Ubuntu based image you want.
2-
FROM mcr.microsoft.com/devcontainers/python:3.7-bullseye
3-
1+
ARG PY_VER
2+
ARG DISTRO
3+
FROM mcr.microsoft.com/devcontainers/python:${PY_VER}-${DISTRO}
44
RUN \
55
apt update && \
66
apt-get install bash-completion graphviz default-mysql-client -y && \
77
pip install flake8 black faker ipykernel pytest pytest-cov nose nose-cov datajoint && \
88
pip uninstall datajoint -y
99

10+
USER root
1011
ENV DJ_HOST fakeservices.datajoint.io
1112
ENV DJ_USER root
12-
ENV DJ_PASS simple
13+
ENV DJ_PASS password

.devcontainer/devcontainer.json

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,48 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
23
{
3-
"name": "Development",
4-
"dockerComposeFile": "docker-compose.yaml",
4+
"name": "Existing Docker Compose (Extend)",
5+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
6+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
7+
"dockerComposeFile": [
8+
"../LNX-docker-compose.yml",
9+
"docker-compose.yml"
10+
],
11+
// The 'service' property is the name of the service for the container that VS Code should
12+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
513
"service": "app",
14+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
15+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
616
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
7-
// Use this environment variable if you need to bind mount your local source code into a new container.
8-
"remoteEnv": {
9-
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
10-
},
11-
// https://containers.dev/features
12-
"features": {
13-
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
14-
"ghcr.io/devcontainers/features/git:1": {},
15-
"ghcr.io/eitsupi/devcontainer-features/jq-likes:1": {},
16-
"ghcr.io/guiyomh/features/vim:0": {}
17-
},
18-
"onCreateCommand": "pip install -e .",
19-
"postStartCommand": "MYSQL_VER=8.0 MINIO_VER=RELEASE.2022-08-11T04-37-28Z docker compose -f local-docker-compose.yml down && docker volume prune -f && MYSQL_VER=8.0 MINIO_VER=RELEASE.2022-08-11T04-37-28Z docker compose -f local-docker-compose.yml up --build --wait",
17+
// Features to add to the dev container. More info: https://containers.dev/features.
18+
// "features": {},
19+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
2020
"forwardPorts": [
2121
80,
2222
443,
2323
3306,
2424
8080,
2525
9000
2626
],
27+
// Uncomment the next line if you want start specific services in your Docker Compose config.
28+
// "runServices": [],
29+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
30+
"shutdownAction": "stopCompose",
31+
"onCreateCommand": "python3 -m pip install -e .",
32+
"features": {
33+
"ghcr.io/devcontainers/features/git:1": {},
34+
},
35+
// Configure tool-specific properties.
2736
"customizations": {
2837
"vscode": {
2938
"extensions": [
3039
"ms-python.python"
3140
]
3241
}
42+
},
43+
"remoteEnv": {
44+
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
3345
}
46+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
47+
// "remoteUser": "devcontainer"
3448
}

.devcontainer/docker-compose.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.devcontainer/docker-compose.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: '2.4'
2+
services:
3+
# Update this to the name of the service you want to work with in your docker-compose.yml file
4+
app:
5+
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
6+
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
7+
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
8+
# array). The sample below assumes your primary file is in the root of your project.
9+
container_name: devcontainer
10+
image: devcontainer
11+
build:
12+
context: .
13+
dockerfile: .devcontainer/Dockerfile
14+
args:
15+
- PY_VER=${PY_VER:-3.8}
16+
- DISTRO=${DISTRO:-buster}
17+
18+
volumes:
19+
# Update this to wherever you want VS Code to mount the folder of your project
20+
- ..:/workspaces:cached
21+
22+
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
23+
# cap_add:
24+
# - SYS_PTRACE
25+
# security_opt:
26+
# - seccomp:unconfined
27+
28+
user: root
29+
30+
# Overrides default command so things don't shut down after the process ends.
31+
command: /bin/sh -c "while sleep 1000; do :; done"
32+

.github/workflows/development.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
- name: Run primary tests
7878
env:
7979
PY_VER: ${{matrix.py_ver}}
80-
DJ_PASS: simple
80+
DJ_PASS: password
8181
MYSQL_VER: ${{matrix.mysql_ver}}
8282
DISTRO: alpine
8383
MINIO_VER: RELEASE.2021-09-03T03-56-13Z

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ docs/site
3030

3131
!.vscode/settings.json
3232
!.vscode/launch.json
33-
!.devcontainer/devcontainer.json
33+
!.devcontainer/devcontainer.json
34+
!.devcontainer/docker-compose.yml
35+

LNX-docker-compose.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ x-net:
77
services:
88
db:
99
<<: *net
10-
image: datajoint/mysql:${MYSQL_VER}
10+
image: datajoint/mysql:${MYSQL_VER:-8.0}
1111
environment:
12-
- MYSQL_ROOT_PASSWORD=${DJ_PASS}
12+
- MYSQL_ROOT_PASSWORD=${DJ_PASS:-password}
13+
command: mysqld --default-authentication-plugin=mysql_native_password
1314
# ports:
1415
# - "3306:3306"
1516
# volumes:
@@ -21,7 +22,7 @@ services:
2122
interval: 15s
2223
minio:
2324
<<: *net
24-
image: minio/minio:${MINIO_VER}
25+
image: minio/minio:${MINIO_VER:-RELEASE.2022-08-11T04-37-28Z}
2526
environment:
2627
- MINIO_ACCESS_KEY=datajoint
2728
- MINIO_SECRET_KEY=datajoint
@@ -44,7 +45,7 @@ services:
4445
interval: 15s
4546
fakeservices.datajoint.io:
4647
<<: *net
47-
image: datajoint/nginx:v0.2.6
48+
image: datajoint/nginx:v0.2.7
4849
environment:
4950
- ADD_db_TYPE=DATABASE
5051
- ADD_db_ENDPOINT=db:3306
@@ -58,7 +59,7 @@ services:
5859
# - "3306:3306"
5960
app:
6061
<<: *net
61-
image: datajoint/djtest:py${PY_VER}-${DISTRO}
62+
image: datajoint/djtest:py${PY_VER:-3.8}-${DISTRO:-alpine}
6263
depends_on:
6364
db:
6465
condition: service_healthy
@@ -69,7 +70,7 @@ services:
6970
environment:
7071
- DJ_HOST=fakeservices.datajoint.io
7172
- DJ_USER=root
72-
- DJ_PASS
73+
- DJ_PASS=password
7374
- DJ_TEST_HOST=fakeservices.datajoint.io
7475
- DJ_TEST_USER=datajoint
7576
- DJ_TEST_PASSWORD=datajoint
@@ -93,7 +94,7 @@ services:
9394
nosetests -vsw tests_old --with-coverage --cover-package=datajoint
9495
# ports:
9596
# - "8888:8888"
96-
user: ${HOST_UID}:anaconda
97+
user: ${HOST_UID:-1000}:anaconda
9798
volumes:
9899
- .:/src
99100
- /tmp/.X11-unix:/tmp/.X11-unix:rw

docs/src/develop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ It is often useful in development to connect to DataJoint's relational database
104104
Connect as follows to the database running within your developer environment:
105105
106106
```
107-
mysql -hfakeservices.datajoint.io -uroot -psimple
107+
mysql -hfakeservices.datajoint.io -uroot -ppassword
108108
```
109109
110110
### Documentation

0 commit comments

Comments
 (0)