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

562 investigate splitting into entrypoints with a shared dockerfile base #563

Closed
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
22 changes: 22 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3'

services:
service1:
build:
context: .
dockerfile: Dockerfile.base
volumes:
- .:/workspace/service1
environment:
PYTHONPATH: /workspace/service1
command: /bin/bash -c "pip install -r service1/requirements.txt && /container-startup.sh"

service2:
build:
context: .
dockerfile: Dockerfile.base
volumes:
- .:/workspace/service2
environment:
PYTHONPATH: /workspace/service2
command: /bin/bash -c "pip install -r service2/requirements.txt && /container-startup.sh"
21 changes: 21 additions & 0 deletions .github/workflows/blueapi_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI/CD for Service1

on:
push:
branches:
- main
paths:
- 'service1/**'
- 'Dockerfile.base'

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build Docker image
run: docker build -f service1/Dockerfile -t myregistry.com/service1:${{ github.sha }} .

- name: Push Docker image to Registry
run: docker push myregistry.com/service1:${{ github.sha }}
106 changes: 81 additions & 25 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,102 @@ apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: blueapi
title: Athena BlueAPI
description: Lightweight wrapper service around Bluesky Run Engine
title: BlueAPI Service
description: The BlueAPI service for handling API requests.
annotations:
github.com/project-slug: DiamondLightSource/blueapi
diamond.ac.uk/viewdocs-url: https://diamondlightsource.github.io/blueapi
github.com/project-slug: your-org/blueapi
spec:
type: service
lifecycle: production
owner: group:data-acquisition
system: athena
providesApis:
- blueapiControl
- blueapiEvents

---
apiVersion: backstage.io/v1alpha1
kind: API
kind: Component
metadata:
name: bluecli
title: BlueCLI Service
description: The BlueCLI service for command line operations.
annotations:
github.com/project-slug: your-org/bluecli
spec:
type: service
lifecycle: production
owner: group:data-acquisition
system: athena

---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: bluecommon
title: BlueCommon Service
description: The BlueCommon service for shared utilities.
annotations:
github.com/project-slug: your-org/bluecommon
spec:
type: library
lifecycle: production
owner: group:data-acquisition
system: athena

---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: blueworker
title: BlueWorker Service
description: The BlueWorker service for background processing.
annotations:
github.com/project-slug: your-org/blueworker
spec:
type: service
lifecycle: production
owner: group:data-acquisition
system: athena

---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: common
title: Common Service
description: The Common service for common functionalities.
annotations:
github.com/project-slug: your-org/common
spec:
type: library
lifecycle: production
owner: group:data-acquisition
system: athena

---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: blueapiControl
title: Athena BlueAPI Control
description: REST API for getting plans/devices from the worker (and running tasks)
name: generated
title: Generated Service
description: The Generated service for autogenerated components.
annotations:
github.com/project-slug: DiamondLightSource/blueapi
github.com/project-slug: your-org/generated
spec:
type: openapi
type: library
lifecycle: production
owner: user:vid18871
definition:
$text: ./docs/reference/openapi.yaml
owner: group:data-acquisition
system: athena

---
apiVersion: backstage.io/v1alpha1
kind: API
kind: Component
metadata:
name: blueapiEvents
title: Athena BlueAPI Events
description: Event topics which can be listened to over a message bus
name: proto
title: Proto Service
description: The Proto service for protocol definitions.
annotations:
github.com/project-slug: DiamondLightSource/blueapi
github.com/project-slug: your-org/proto
spec:
type: asyncapi
type: library
lifecycle: production
owner: user:vid18871
definition:
$text: ./docs/reference/asyncapi.yaml
owner: group:data-acquisition
system: athena
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies = [
"dls-bluesky-core", #requires ophyd-async
"dls-dodal>=1.24.0",
"super-state-machine", # See GH issue 553
"grpcio-tools",
"GitPython",
]
dynamic = ["version"]
Expand Down Expand Up @@ -61,7 +62,10 @@ dev = [
]

[project.scripts]
blueapi = "blueapi.cli:main"
# todo add all the entrypoints
blueapi = "services.bluecli:main"
blueworker= "services.blueworker:main"
generate_worker= "python -m grpc_tools.protoc -I. --python_out=../generated --pyi_out=../generated --grpc_python_out=../generated worker.proto"

[project.urls]
GitHub = "https://github.com/DiamondLightSource/blueapi"
Expand All @@ -72,7 +76,7 @@ name = "Callum Forrester"


[tool.setuptools_scm]
write_to = "src/blueapi/_version.py"
write_to = "services/_version.py"

[tool.mypy]
ignore_missing_imports = true # Ignore missing stubs in imported modules
Expand Down Expand Up @@ -126,8 +130,9 @@ commands =
"""

[tool.ruff]
src = ["src", "tests"]
src = ["services", "tests"]
line-length = 88
exclude = ["services/proto", "services/_version.py", "services/generated"]
lint.select = [
"B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
Expand Down
3 changes: 3 additions & 0 deletions services/blueapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .._version import __version__

__all__ = ["__version__"]
3 changes: 3 additions & 0 deletions services/blueapi/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# test with: python -m blueapi
if __name__ == "__main__":
raise Exception("blueapi should be ran through the cli at the moment")
File renamed without changes.
Loading
Loading