diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e008c9287..06958f6cd 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,12 +1,13 @@ -# Note: You can use any Debian/Ubuntu based image you want. -FROM mcr.microsoft.com/devcontainers/python:3.7-bullseye - +ARG PY_VER +ARG DISTRO +FROM mcr.microsoft.com/devcontainers/python:${PY_VER}-${DISTRO} RUN \ apt update && \ apt-get install bash-completion graphviz default-mysql-client -y && \ pip install flake8 black faker ipykernel pytest pytest-cov nose nose-cov datajoint && \ pip uninstall datajoint -y +USER root ENV DJ_HOST fakeservices.datajoint.io ENV DJ_USER root -ENV DJ_PASS simple \ No newline at end of file +ENV DJ_PASS password diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a5db4d4c5..35b1d0835 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,22 +1,22 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose { - "name": "Development", - "dockerComposeFile": "docker-compose.yaml", + "name": "Existing Docker Compose (Extend)", + // Update the 'dockerComposeFile' list if you have more compose files or use different names. + // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. + "dockerComposeFile": [ + "../LNX-docker-compose.yml", + "docker-compose.yml" + ], + // The 'service' property is the name of the service for the container that VS Code should + // use. Update this value and .devcontainer/docker-compose.yml to the real service name. "service": "app", + // The optional 'workspaceFolder' property is the path VS Code should open by default when + // connected. This is typically a file mount in .devcontainer/docker-compose.yml "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - // Use this environment variable if you need to bind mount your local source code into a new container. - "remoteEnv": { - "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" - }, - // https://containers.dev/features - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/devcontainers/features/git:1": {}, - "ghcr.io/eitsupi/devcontainer-features/jq-likes:1": {}, - "ghcr.io/guiyomh/features/vim:0": {} - }, - "onCreateCommand": "pip install -e .", - "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", + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [ 80, 443, @@ -24,11 +24,25 @@ 8080, 9000 ], + // Uncomment the next line if you want start specific services in your Docker Compose config. + // "runServices": [], + // Uncomment the next line if you want to keep your containers running after VS Code shuts down. + "shutdownAction": "stopCompose", + "onCreateCommand": "python3 -m pip install -e .", + "features": { + "ghcr.io/devcontainers/features/git:1": {}, + }, + // Configure tool-specific properties. "customizations": { "vscode": { "extensions": [ "ms-python.python" ] } + }, + "remoteEnv": { + "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" } + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "devcontainer" } \ No newline at end of file diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml deleted file mode 100644 index a456ed151..000000000 --- a/.devcontainer/docker-compose.yaml +++ /dev/null @@ -1,10 +0,0 @@ -version: "3" -services: - app: - build: . - extra_hosts: - - fakeservices.datajoint.io:127.0.0.1 - volumes: - - ../..:/workspaces:cached - entrypoint: /usr/local/share/docker-init.sh - command: tail -f /dev/null diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 000000000..1ee8ea148 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,32 @@ +version: '2.4' +services: + # Update this to the name of the service you want to work with in your docker-compose.yml file + app: + # Uncomment if you want to override the service's Dockerfile to one in the .devcontainer + # folder. Note that the path of the Dockerfile and context is relative to the *primary* + # docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile" + # array). The sample below assumes your primary file is in the root of your project. + container_name: devcontainer + image: devcontainer + build: + context: . + dockerfile: .devcontainer/Dockerfile + args: + - PY_VER=${PY_VER:-3.8} + - DISTRO=${DISTRO:-buster} + + volumes: + # Update this to wherever you want VS Code to mount the folder of your project + - ..:/workspaces:cached + + # Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust. + # cap_add: + # - SYS_PTRACE + # security_opt: + # - seccomp:unconfined + + user: root + + # Overrides default command so things don't shut down after the process ends. + command: /bin/sh -c "while sleep 1000; do :; done" + diff --git a/.github/workflows/development.yaml b/.github/workflows/development.yaml index fdcbcd677..5f3b1f075 100644 --- a/.github/workflows/development.yaml +++ b/.github/workflows/development.yaml @@ -77,7 +77,7 @@ jobs: - name: Run primary tests env: PY_VER: ${{matrix.py_ver}} - DJ_PASS: simple + DJ_PASS: password MYSQL_VER: ${{matrix.mysql_ver}} DISTRO: alpine MINIO_VER: RELEASE.2021-09-03T03-56-13Z diff --git a/.gitignore b/.gitignore index 4b7bdb2c4..6e1d664ff 100644 --- a/.gitignore +++ b/.gitignore @@ -30,4 +30,6 @@ docs/site !.vscode/settings.json !.vscode/launch.json -!.devcontainer/devcontainer.json \ No newline at end of file +!.devcontainer/devcontainer.json +!.devcontainer/docker-compose.yml + diff --git a/LNX-docker-compose.yml b/LNX-docker-compose.yml index 9c0a95b78..eaf3a48cd 100644 --- a/LNX-docker-compose.yml +++ b/LNX-docker-compose.yml @@ -7,9 +7,10 @@ x-net: services: db: <<: *net - image: datajoint/mysql:${MYSQL_VER} + image: datajoint/mysql:${MYSQL_VER:-8.0} environment: - - MYSQL_ROOT_PASSWORD=${DJ_PASS} + - MYSQL_ROOT_PASSWORD=${DJ_PASS:-password} + command: mysqld --default-authentication-plugin=mysql_native_password # ports: # - "3306:3306" # volumes: @@ -21,7 +22,7 @@ services: interval: 15s minio: <<: *net - image: minio/minio:${MINIO_VER} + image: minio/minio:${MINIO_VER:-RELEASE.2022-08-11T04-37-28Z} environment: - MINIO_ACCESS_KEY=datajoint - MINIO_SECRET_KEY=datajoint @@ -44,7 +45,7 @@ services: interval: 15s fakeservices.datajoint.io: <<: *net - image: datajoint/nginx:v0.2.6 + image: datajoint/nginx:v0.2.7 environment: - ADD_db_TYPE=DATABASE - ADD_db_ENDPOINT=db:3306 @@ -58,7 +59,7 @@ services: # - "3306:3306" app: <<: *net - image: datajoint/djtest:py${PY_VER}-${DISTRO} + image: datajoint/djtest:py${PY_VER:-3.8}-${DISTRO:-alpine} depends_on: db: condition: service_healthy @@ -69,7 +70,7 @@ services: environment: - DJ_HOST=fakeservices.datajoint.io - DJ_USER=root - - DJ_PASS + - DJ_PASS=password - DJ_TEST_HOST=fakeservices.datajoint.io - DJ_TEST_USER=datajoint - DJ_TEST_PASSWORD=datajoint @@ -93,7 +94,7 @@ services: nosetests -vsw tests_old --with-coverage --cover-package=datajoint # ports: # - "8888:8888" - user: ${HOST_UID}:anaconda + user: ${HOST_UID:-1000}:anaconda volumes: - .:/src - /tmp/.X11-unix:/tmp/.X11-unix:rw diff --git a/docs/src/develop.md b/docs/src/develop.md index 4acb9ed35..842c04d96 100644 --- a/docs/src/develop.md +++ b/docs/src/develop.md @@ -104,7 +104,7 @@ It is often useful in development to connect to DataJoint's relational database Connect as follows to the database running within your developer environment: ``` -mysql -hfakeservices.datajoint.io -uroot -psimple +mysql -hfakeservices.datajoint.io -uroot -ppassword ``` ### Documentation