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

Working on Dockerfile and testing #210

Merged
merged 5 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .docker/cp2k-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ label: cp2k
computer: localhost
description:
default_calc_job_plugin: cp2k
on_computer: True
filepath_executable: /usr/bin/cp2k
append_text:
prepend_text:
2 changes: 1 addition & 1 deletion .docker/opt/add-codes.sh → .docker/init/add-codes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ set -x
export SHELL=/bin/bash

# Install cp2k code.
verdi code show cp2k@localhost || verdi code create core.code.installed --config /opt/aiida-cp2k/.docker/cp2k-code.yml --non-interactive
verdi code show cp2k@localhost || verdi code create core.code.installed --config /home/aiida/aiida-cp2k/.docker/cp2k-code.yml --non-interactive
7 changes: 0 additions & 7 deletions .docker/my_init.d/add-codes.sh

This file was deleted.

8 changes: 0 additions & 8 deletions .docker/my_init.d/add-pgsql-bin-to-path.sh

This file was deleted.

Empty file.
1 change: 1 addition & 0 deletions .docker/s6-rc.d/cp2k-code-setup/timeout-up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
1 change: 1 addition & 0 deletions .docker/s6-rc.d/cp2k-code-setup/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
7 changes: 7 additions & 0 deletions .docker/s6-rc.d/cp2k-code-setup/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/command/execlineb -S0

with-contenv

foreground { s6-echo "Setting up CP2K code" }

/etc/init/add-codes.sh
Empty file added .docker/user/cp2k-code-setup
Empty file.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ jobs:
- name: Create container from aiida_cp2k_test image and test the plugin inside
run: |
export DOCKERID=`docker run -d aiida_cp2k_test`
docker exec --tty $DOCKERID wait-for-services
sleep 5
docker logs $DOCKERID
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'cd /opt/aiida-cp2k/ && py.test --cov aiida_cp2k --cov-append .'
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'cd /home/aiida/aiida-cp2k/ && py.test --cov aiida_cp2k --cov-append .'


pre-commit:
Expand Down
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################

FROM aiidateam/aiida-core:2.1.2
FROM aiidateam/aiida-core-with-services:2.5.0

# To prevent the container to exit prematurely.
ENV KILL_ALL_RPOCESSES_TIMEOUT=50

WORKDIR /opt/

USER root
# Install statically linked CP2K which is a considerably newer release than Debian builtin.
# The statically linked CP2K is a non-MPI binary, but we're running all tests with 1 MPI proc.
RUN set -ex ; \
Expand All @@ -21,16 +21,15 @@ RUN set -ex ; \
echo "1e6fccf901873ebe9c827f45fb29331f599772f6e6281e988d8956c7a3aa143c /usr/bin/cp2k" | sha256sum -c ; \
chmod +x /usr/bin/cp2k

USER aiida
# Install aiida-cp2k plugin.
COPY . aiida-cp2k
COPY --chown="${SYSTEM_UID}:${SYSTEM_GID}" . /home/aiida/aiida-cp2k
RUN pip install ./aiida-cp2k[dev,docs]

# Install coverals.
RUN pip install coveralls

# Install the cp2k code.
COPY .docker/opt/add-codes.sh /opt/
COPY .docker/my_init.d/add-codes.sh /etc/my_init.d/50_add-codes.sh

# Add PGSQL bin folder to PATH.
COPY .docker/my_init.d/add-pgsql-bin-to-path.sh /etc/my_init.d/50_add-pgsql-bin-to-path.sh
COPY .docker/init/add-codes.sh /etc/init/
COPY .docker/s6-rc.d/cp2k-code-setup /etc/s6-overlay/s6-rc.d/cp2k-code-setup
COPY .docker/user/cp2k-code-setup /etc/s6-overlay/s6-rc.d/user/contents.d/cp2k-code-setup
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pip install -e . # Also installs aiida, if missing (but not postgres/rabbitmq).

## For maintainers

### Release

To create a new release, clone the repository, install development dependencies with `pip install '.[dev]'`, and then execute `bumpver update --major/--minor/--patch`.
This will:

Expand All @@ -43,6 +45,33 @@ Additional notes:
- The release tag (e.g. a/b/rc) is determined from the last release.
Use the `--tag` option to override the release tag.

### Testing

To run the tests, you need to have Docker installed in your system.
Once this is done, you can build the Docker image with the following command:

```bash
docker build -t aiida_cp2k_test .
```
Then, you can launch the container:

```bash
DOKERID=`docker run -it aiida_cp2k_test`
```
This will remeber the container ID in the variable `DOKERID`.
You can then run the tests with the following command:

```bash
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'cd /home/aiida/aiida-cp2k/ && pytest'
```

To enter the container for manual testing do:

```bash
docker exec -it --user aiida $DOCKERID bash
```


## License

MIT
Expand Down
Loading