diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..bde97605f6 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,16 @@ +# Additions for dev container +FROM aiidateam/aiida-core:main + +# Add test dependencies (not installed in image) +RUN pip install ./aiida-core[tests,rest,docs,pre-commit] +# the `locate` command is needed by many tests +RUN apt-get update \ + && apt-get install -y mlocate \ + && rm -rf /var/lib/apt/lists/* + +# add aiida user +RUN /etc/my_init.d/10_create-system-user.sh + +# copy updated aiida configuration script +# this line can be deleted after the new script has been merged +COPY ../.docker/opt/configure-aiida.sh /opt/configure-aiida.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..5bbcf39152 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,12 @@ +{ + "dockerComposeFile": "docker-compose.yml", + "service": "aiida", + "workspaceFolder": "/home/aiida/aiida-core", + "postCreateCommand": "bash ./.devcontainer/post_create.sh", + "waitFor": "postCreateCommand", + "customizations": { + "vscode": { + "extensions": ["ms-python.python", "eamodio.gitlens"] + } + } +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000000..380a0a4760 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,54 @@ +version: '3.4' + +services: + + rabbitmq: + image: rabbitmq:3.8.3-management + environment: + RABBITMQ_DEFAULT_USER: guest + RABBITMQ_DEFAULT_PASS: guest + ports: + - '5672:5672' + - '15672:15672' + + healthcheck: + test: rabbitmq-diagnostics -q ping + interval: 30s + timeout: 30s + retries: 5 + networks: + - aiida + + postgres: + image: postgres:12 + ports: + - '5432:5432' + networks: + - aiida + environment: + POSTGRES_HOST_AUTH_METHOD: trust + + aiida: + #image: "aiidateam/aiida-core:main" + image: "aiida-core-dev" + build: + # need to add the parent directory to context to copy over new configure-aiida.sh + context: .. + dockerfile: .devcontainer/Dockerfile + user: aiida + environment: + DB_HOST: postgres + BROKER_HOST: rabbitmq + + # no need for /sbin/my_init + entrypoint: tail -f /dev/null + volumes: + - ..:/home/aiida/aiida-core:cached + networks: + - aiida + depends_on: + - rabbitmq + - postgres + +networks: + aiida: diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh new file mode 100644 index 0000000000..71f8330853 --- /dev/null +++ b/.devcontainer/post_create.sh @@ -0,0 +1,4 @@ + #!/bin/bash + +# configure aiida +/opt/configure-aiida.sh diff --git a/.docker/opt/configure-aiida.sh b/.docker/opt/configure-aiida.sh index b0f1326584..92aa3ab45d 100755 --- a/.docker/opt/configure-aiida.sh +++ b/.docker/opt/configure-aiida.sh @@ -29,7 +29,8 @@ if [[ ${NEED_SETUP_PROFILE} == true ]]; then --first-name "${USER_FIRST_NAME}" \ --last-name "${USER_LAST_NAME}" \ --institution "${USER_INSTITUTION}" \ - --db-backend "${AIIDADB_BACKEND}" + --db-host "${DB_HOST:localhost}" \ + --broker-host "${BROKER_HOST:localhost}" # Setup and configure local computer. computer_name=localhost