Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevOps: Add devcontainer #5913

Merged
merged 19 commits into from Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions .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
12 changes: 12 additions & 0 deletions .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"]
}
}
}
60 changes: 60 additions & 0 deletions .devcontainer/docker-compose.yml
@@ -0,0 +1,60 @@
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
# volumes:
# - db-volume:/var/lib/postgresql/data

aiida:
#image: "aiidateam/aiida-core:main"
image: "aiida-core-dev"
build:
Comment on lines +31 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the image aiidalab/base from https://hub.docker.com/r/aiidalab/base/tags is what we can put here in the future if we manage to move it from aiidalab to here, correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost. It would probably rather become FROM image in the .devcontainer/Dockerfile, since the devcontainer focuses on development (which requires e.g. some further dependencies installed).

# 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
# - db-volume:/var/lib/assets
networks:
- aiida
depends_on:
- rabbitmq
- postgres

# volumes:
# db-volume:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do this need to be kept here? Since it is useful for having data stored persistent I suggest keeping it and adding more details.

Copy link
Member Author

@ltalirz ltalirz Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was the intention. Will add further comments

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the end I decided to remove them as they are untested.

it's easy enough to reintroduce them and go to a setup with persistent data

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but it is a bit confusing for me how this codespace is working, if I understand correctly, the container is opened in a remote machine provided by GitHub. How is this persistent volumes mapping can mapping to the local DB file or local file repository?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this would have been intended for running the devcontainer locally through VS Code.

I am not aware of a way of persisting files after github codespaces deletes the containers.


networks:
aiida:
4 changes: 4 additions & 0 deletions .devcontainer/post_create.sh
@@ -0,0 +1,4 @@
#!/bin/bash

# configure aiida
/opt/configure-aiida.sh
3 changes: 2 additions & 1 deletion .docker/opt/configure-aiida.sh
Expand Up @@ -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
Expand Down