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

Refactor utility script to allow for future services #707

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DiamondJoseph
Copy link
Contributor

Move RabbitMQ docker command into a docker-compose file, to allow defining multiple dependent services at once.
This may be used for mock authentication later.

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.17%. Comparing base (86c5905) to head (b778bb9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #707   +/-   ##
=======================================
  Coverage   92.17%   92.17%           
=======================================
  Files          35       35           
  Lines        1803     1803           
=======================================
  Hits         1662     1662           
  Misses        141      141           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@stan-dot
Copy link
Contributor

please then just add it into docker-compose.yaml to replicate the setup the analysis team have where devcontainer spins up many dependencies

see this https://github.com/DiamondLightSource/authz/tree/main/.devcontainer

@callumforrester
Copy link
Contributor

I agree with @stan-dot, automatic support in the devcontainer would be very nice

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't catch this when it was first checked in but I don't think these files belong in src, they are config for the dev environment, not source code.

@stan-dot
Copy link
Contributor

re: PR title phrasing https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it

@DiamondJoseph
Copy link
Contributor Author

re: PR title phrasing https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it

I'm going to need it for system tests with authentication.

@stan-dot
Copy link
Contributor

This may be used for mock authentication later.

your initial phrasing didn't include this urgency

@DiamondJoseph DiamondJoseph force-pushed the docker-compose branch 2 times, most recently from 5c6dd18 to 90c1ca1 Compare November 13, 2024 16:30
@stan-dot
Copy link
Contributor

looking into it

@stan-dot
Copy link
Contributor

        - _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp
      additional_contexts:
        - dev_containers_feature_content_source=/scratch/xma12127/tmp/devcontainercli-xma12127/container-features/0.71.0-1731516455289

[10784 ms] Start: Run: podman compose --project-name blueapi_devcontainer -f /scratch/xma12127/projects/forks/blueapi/.devcontainer/docker-compose.yml -f /scratch/xma12127/projects/forks/blueapi/.devcontainer/docker-compose-infrastructure.yml -f /home/xma12127/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/docker-compose/docker-compose.devcontainer.build-1731516462064.yml build --no-cache
>>>> Executing external compose provider "/dls_sw/apps/docker-compose/2.29.7/bin/docker-compose". Please refer to the documentation for details. <<<<

the classic builder doesn't support additional contexts, set DOCKER_BUILDKIT=1 to use BuildKit
Error: executing /dls_sw/apps/docker-compose/2.29.7/bin/docker-compose --project-name blueapi_devcontainer -f /scratch/xma12127/projects/forks/blueapi/.devcontainer/docker-compose.yml -f /scratch/xma12127/projects/forks/blueapi/.devcontainer/docker-compose-infrastructure.yml -f /home/xma12127/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/docker-compose/docker-compose.devcontainer.build-1731516462064.yml build --no-cache: exit status 1
[10935 ms] Error: Command failed: podman compose --project-name blueapi_devcontainer -f /scratch/xma12127/projects/forks/blueapi/.devcontainer/docker-compose.yml -f /scratch/xma12127/projects/forks/blueapi/.devcontainer/docker-compose-infrastructure.yml -f /home/xma12127/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/docker-compose/docker-compose.devcontainer.build-1731516462064.yml build --no-cache
[10935 ms]     at Pm (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:430:525)
[10935 ms]     at async ftA (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:430:2476)
[10935 ms]     at async htA (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:410:3496)
[10935 ms]     at async TtA (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:482:4021)
[10935 ms]     at async iB (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:482:4963)
[10935 ms]     at async wrA (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:663:203)
[10935 ms]     at async DrA (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:662:14830)
[10935 ms]     at async /dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:482:1190
[10940 ms] Exit code 1
[10943 ms] Command failed: /dls_sw/apps/vscode/1.95.1/code /home/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/xma12127/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --docker-path podman --container-session-data-folder /tmp/devcontainers-ac3d5608-a3b6-4a7b-b055-603691cbb9d01731516450595 --workspace-folder /scratch/xma12127/projects/forks/blueapi --workspace-mount-consistency cached --gpu-availability detect --id-label devcontainer.local_folder=/scratch/xma12127/projects/forks/blueapi --id-label devcontainer.config_file=/scratch/xma12127/projects/forks/blueapi/.devcontainer/devcontainer.json --log-level debug --log-format json --config /scratch/xma12127/projects/forks/blueapi/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --build-no-cache --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root --include-configuration --include-merged-configuration
[10943 ms] Exit code 1

@stan-dot
Copy link
Contributor

having set up in .bashrc_local the DOCKER_BUILDKIT to 1 this error still

>>>> Executing external compose provider "/dls_sw/apps/docker-compose/2.29.7/bin/docker-compose". Please refer to the documentation for details. <<<<

the classic builder doesn't support additional contexts, set DOCKER_BUILDKIT=1 to use BuildKit
Error: executing /dls_sw/apps/docker-compose/2.29.7/bin/docker-compose --project-name blueapi_devcontainer -f /scratch/xma12127/projects/forks/blueapi/.devcontainer/docker-compose.yml -f /scratch/xma12127/projects/forks/blueapi/.devcontainer/docker-compose-infrastructure.yml -f /home/xma12127/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/docker-compose/docker-compose.devcontainer.build-1731517013763.yml build --no-cache: exit status 1
[10834 ms] Error: Command failed: podman compose --project-name blueapi_devcontainer -f /scratch/xma12127/projects/forks/blueapi/.devcontainer/docker-compose.yml -f /scratch/xma12127/projects/forks/blueapi/.devcontainer/docker-compose-infrastructure.yml -f /home/xma12127/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/docker-compose/docker-compose.devcontainer.build-1731517013763.yml build --no-cache
[10834 ms]     at Pm (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:430:525)
[10834 ms]     at async ftA (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:430:2476)
[10834 ms]     at async htA (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:410:3496)
[10834 ms]     at async TtA (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:482:4021)
[10834 ms]     at async iB (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:482:4963)
[10835 ms]     at async wrA (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:663:203)
[10835 ms]     at async DrA (/dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:662:14830)
[10835 ms]     at async /dls/science/users/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js:482:1190
[10839 ms] Exit code 1
[10843 ms] Command failed: /dls_sw/apps/vscode/1.95.1/code /home/xma12127/.vscode/extensions/ms-vscode-remote.remote-containers-0.388.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/xma12127/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --docker-path podman --container-session-data-folder /tmp/devcontainers-3e71b4e7-0683-4357-9dc7-f4cea1ad07ed1731517002325 --workspace-folder /scratch/xma12127/projects/forks/blueapi --workspace-mount-consistency cached --gpu-availability detect --id-label devcontainer.local_folder=/scratch/xma12127/projects/forks/blueapi --id-label devcontainer.config_file=/scratch/xma12127/projects/forks/blueapi/.devcontainer/devcontainer.json --log-level debug --log-format json --config /scratch/xma12127/projects/forks/blueapi/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --build-no-cache --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root --include-configuration --include-merged-configuration
[10843 ms] Exit code 1

@stan-dot
Copy link
Contributor

@garryod please help

@DiamondJoseph
Copy link
Contributor Author

@stan-dot seems to work on my machine, have you pulled the latest version?

@stan-dot
Copy link
Contributor

yeah I did @DiamondJoseph maybe it's about the setup and env variables?

@callumforrester
Copy link
Contributor

I'm beginning to think that the combination of docker-compose/podman/devcontainers is quite broken at the moment for multi-stage builds, see

microsoft/vscode-remote-release#10178
devcontainers/cli#863

This doesn't affect the example @stan-dot linked from the analysis team because that isn't a multi-stage build. Tagging @gilesknap in case he has any suggestions.

@gilesknap
Copy link
Contributor

I found the combination broken when I last tried it and decided it was too fragile to use.

A conversation with @garryod revealed that older versions of docker-compose did work. But that makes it sound like it's going in the wrong direction at present.

@callumforrester
Copy link
Contributor

@DiamondJoseph we can still use docker-compose to manually initialize rabbit + the other dependant services, as was your original plan.

@DiamondJoseph
Copy link
Contributor Author

@callumforrester after I'm done working on what I currently am I'm going to revisit this to see if we can split the Dockerfile into the developer Dockerfile, and use what is currently produced by the python-copier-template, and the Dockerfile for running the service, see if it behaves with podman.

@callumforrester
Copy link
Contributor

Okay, although I still share @gilesknap's concern about the general direction of upstream

@DiamondJoseph DiamondJoseph marked this pull request as ready for review November 25, 2024 11:36
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: To avoid me having to do another huge rebase, can we get #674 in first and then rebase to suit this (pleeease)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you can address my comments ;P

Comment on lines +13 to +16
# with docker
docker compose -f .devcontainer/compose.yml up
# or with podman-compose
podman-compose -f .devcontainer/compose.yml up
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: Although we gave up on autostarting these services in the devcontainer, can we make docker-compose available in the devcontainer so the developer can do it manually? Otherwise this whole section doesn't apply if you're using a devcontainer.

Copy link
Contributor

@stan-dot stan-dot left a comment

Choose a reason for hiding this comment

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

all ok

@DiamondJoseph
Copy link
Contributor Author

all ok

Tested and it works on your Diamond and personal machines @stan-dot?

@stan-dot
Copy link
Contributor

no I didn't test it such as my devcontainer setup fails with any repo today for some reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants