@@ -18,11 +18,13 @@ dockerNetwork := pathology-local
1818
1919.PHONY : dependencies
2020dependencies : # Install dependencies needed to build and test the project @Pipeline
21- cd pathology-api && poetry sync
21+ @cd pathology-api && poetry sync
22+ @cd ../mocks && poetry sync
2223
23- .PHONY : build
24- build : clean-artifacts dependencies
24+ .PHONY : build-pathology
25+ build-pathology :
2526 @cd pathology-api
27+ @echo " Starting build for pathology API..."
2628 @echo " Running type checks..."
2729 @rm -rf target && rm -rf dist
2830 @poetry run mypy --no-namespace-packages .
@@ -35,13 +37,39 @@ build: clean-artifacts dependencies
3537 @cd ./target/pathology-api
3638 @zip -r " ../artifact.zip" .
3739
40+ .PHONY : build-mocks
41+ build-mocks :
42+ @cd mocks
43+ @echo " Starting build for mocks..."
44+ @echo " Running type checks..."
45+ @rm -rf target && rm -rf dist
46+ @poetry run mypy --no-namespace-packages .
47+ @echo " Packaging dependencies..."
48+ @poetry build --format=wheel
49+ VERSION=$$(poetry version -s )
50+ @pip install " dist/pathology_api_mocks-$$ VERSION-py3-none-any.whl" --target " ./target/mocks" --platform manylinux2014_x86_64 --only-binary=:all:
51+ # Copy lambda_handler file separately as it is not included within the package.
52+ @cp lambda_handler.py ./target/mocks/
53+ @cd ./target/mocks
54+ @zip -r " ../artifact.zip" .
55+
56+ .PHONY : build
57+ build : clean-artifacts dependencies build-pathology build-mocks
58+ @echo " Built artifacts for both pathology and mocks"
59+
60+
3861.PHONY : build-images
3962build-images : build # Build the project artefact @Pipeline
4063 @mkdir infrastructure/images/pathology-api/resources/build/
4164 @cp pathology-api/target/artifact.zip infrastructure/images/pathology-api/resources/build/
4265 @mkdir infrastructure/images/pathology-api/resources/build/pathology-api
4366 @unzip infrastructure/images/pathology-api/resources/build/artifact.zip -d infrastructure/images/pathology-api/resources/build/pathology-api
4467
68+ @mkdir infrastructure/images/mocks/resources/build/
69+ @cp mocks/target/artifact.zip infrastructure/images/mocks/resources/build/
70+ @mkdir infrastructure/images/mocks/resources/build/mocks
71+ @unzip infrastructure/images/mocks/resources/build/artifact.zip -d infrastructure/images/mocks/resources/build/mocks
72+
4573 @echo "Building Docker image using Docker. Utilising python version: ${PYTHON_VERSION} ..."
4674 @$(docker) buildx build --load --platform=linux/amd64 --provenance=false --build-arg PYTHON_VERSION=${PYTHON_VERSION} -t localhost/pathology-api-image infrastructure/images/pathology-api
4775 @echo "Docker image 'pathology-api-image' built successfully!"
@@ -50,18 +78,37 @@ build-images: build # Build the project artefact @Pipeline
5078 @$(docker) buildx build --load --build-arg PYTHON_VERSION=${PYTHON_VERSION} -t localhost/api-gateway-mock-image infrastructure/images/api-gateway-mock
5179 @echo "Docker image 'api-gateway-mock-image' built successfully!"
5280
81+ @echo "Building mocks Docker image using Docker. Utilising python version: ${PYTHON_VERSION} ..."
82+ @$(docker) buildx build --load --platform=linux/amd64 --provenance=false --build-arg PYTHON_VERSION=${PYTHON_VERSION} -t localhost/mocks-image infrastructure/images/mocks
83+ @echo "Docker image 'mocks-image' built successfully!"
84+
5385publish : # Publish the project artefact @Pipeline
5486 # TODO: Implement the artefact publishing step
5587
5688deploy : clean-docker build-images # Deploy the project artefact to the target environment @Pipeline
5789 $(docker ) network create $(dockerNetwork ) || echo " Docker network '$( dockerNetwork) ' already exists."
58- $(docker ) run --platform linux/amd64 --name pathology-api -p 5001:8080 --network $(dockerNetwork ) -d localhost/pathology-api-image
90+ $(docker ) run --platform linux/amd64 --name pathology-api -p 5001:8080 --network $(dockerNetwork ) -d localhost/pathology-api-image
91+ $(docker ) run --platform linux/amd64 --name mocks -p 5003:8080 --network $(dockerNetwork ) -d localhost/mocks-image
5992 $(docker ) run --name api-gateway-mock -p 5002:5000 --network $(dockerNetwork ) -d localhost/api-gateway-mock-image
93+ $(docker ) run --name api-gateway-mock-2 -p 5005:5000 -e TARGET_CONTAINER=' MOCKS' --network $(dockerNetwork ) -d localhost/api-gateway-mock-image
94+
95+ # .PHONY: quick-deploy-mock
96+ # quick-deploy-mock: build-mocks
97+ # @echo "Stopping mocks container..."
98+ # @$(docker) stop mocks || echo "No mocks container currently running."
99+
100+ # @echo "Removing mocks container..."
101+ # @$(docker) rm mocks || echo "No mocks container currently exists."
102+
103+ # @$(docker) run --platform linux/amd64 --name mocks -p 5003:8080 --network $(dockerNetwork) -d localhost/mocks-image
104+
60105
61106clean-artifacts :
62107 @echo " Removing build artefacts..."
63108 @rm -rf infrastructure/images/pathology-api/resources/build/
64109 @rm -rf pathology-api/target && rm -rf pathology-api/dist
110+ @rm -rf infrastructure/images/mocks/resources/build/
111+ @rm -rf mocks/target && rm -rf mocks/dist
65112
66113clean-docker : stop
67114 @echo " Removing pathology API container..."
@@ -70,6 +117,12 @@ clean-docker: stop
70117 @echo "Removing api-gateway-mock container..."
71118 @$(docker) rm api-gateway-mock || echo "No api-gateway-mock container currently exists."
72119
120+ @echo "Removing mocks container..."
121+ @$(docker) rm mocks || echo "No mocks container currently exists."
122+
123+ @echo "Removing api-gateway-mock-2 container..."
124+ @$(docker) rm api-gateway-mock-2 || echo "No api-gateway-mock-2 container currently exists."
125+
73126clean :: clean-artifacts clean-docker # Clean-up project resources (main) @Operations
74127
75128.PHONY : stop
@@ -80,6 +133,12 @@ stop:
80133 @echo "Stopping api-gateway-mock container..."
81134 @$(docker) stop api-gateway-mock || echo "No api-gateway-mock container currently running."
82135
136+ @echo "Stopping mocks container..."
137+ @$(docker) stop mocks || echo "No mocks container currently running."
138+
139+ @echo "Stopping api-gateway-mock-2 container..."
140+ @$(docker) stop api-gateway-mock-2 || echo "No api-gateway-mock-2 container currently running."
141+
83142config :: # Configure development environment (main) @Configuration
84143 # Configure poetry to trust dev certificate if specified
85144 @if [[ -n " $$ {DEV_CERTS_INCLUDED}" ]]; then \
0 commit comments