Skip to content

Commit 46b86e2

Browse files
authored
Merge pull request #125 from ks6088ts-labs/cosmetic
refactor codes
2 parents c6f2093 + 5eb1bf9 commit 46b86e2

File tree

130 files changed

+147
-3893
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+147
-3893
lines changed

Makefile

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ ci-test: install-deps-dev format-check lint test ## run CI tests
5252
# ---
5353
DOCKER_REPO_NAME ?= ks6088ts
5454
DOCKER_IMAGE_NAME ?= azure-ai-services-solutions
55-
DOCKER_IMAGE_COMPONENT ?= backend
55+
DOCKER_SERVICE_NAME ?= backend
5656
DOCKER_COMMAND ?=
57-
DOCKER_TAG ?= $(DOCKER_IMAGE_COMPONENT)-$(GIT_TAG)
58-
DOCKER_FILE ?= ./dockerfiles/$(DOCKER_IMAGE_COMPONENT).Dockerfile
57+
DOCKER_TAG ?= $(DOCKER_SERVICE_NAME)-$(GIT_TAG)
58+
DOCKER_FILE ?= ./$(DOCKER_SERVICE_NAME)/Dockerfile
5959
DOCKER_COMPOSE_FILE ?= ./compose.yaml
6060

6161
# Tools
@@ -95,15 +95,16 @@ _ci-test-docker: docker-lint docker-build docker-scan docker-run
9595

9696
.PHONY: ci-test-docker
9797
ci-test-docker: docker-compose-lint ## run CI test for Docker
98-
$(MAKE) _ci-test-docker DOCKER_IMAGE_COMPONENT=backend
99-
$(MAKE) _ci-test-docker DOCKER_IMAGE_COMPONENT=frontend
98+
$(MAKE) _ci-test-docker DOCKER_SERVICE_NAME=backend
99+
$(MAKE) _ci-test-docker DOCKER_SERVICE_NAME=frontend
100100

101101
# ---
102102
# Application
103103
# ---
104104
.PHONY: backend
105105
backend: ## run backend
106-
poetry run python main.py backend --reload
106+
cd backend \
107+
&& poetry run python main.py backend --reload
107108

108109
.PHONY: frontend
109110
frontend: ## run frontend
@@ -115,7 +116,8 @@ frontend: ## run frontend
115116
# ---
116117
.PHONY: azure-functions-start
117118
azure-functions-start: ## start Azure Functions
118-
poetry run func start
119+
cd backend \
120+
&& poetry run func start
119121

120122
.PHONY: azure-functions-deploy
121123
azure-functions-deploy: ## deploy Azure Functions resources
@@ -125,21 +127,17 @@ azure-functions-deploy: ## deploy Azure Functions resources
125127
azure-functions-destroy: ## destroy Azure Functions resources
126128
sh ./scripts/destroy-azure-functions.sh
127129

128-
.PHONY: azure-functions-functionapp-deploy
129-
azure-functions-functionapp-deploy: ## deploy Azure Functions App
130-
poetry export \
131-
--format requirements.txt \
132-
--output requirements.txt \
133-
--with backend,azure-functions \
134-
--without-hashes
135-
func azure functionapp publish $(shell jq -r '.FUNCTION_APP_NAME' < azure-functions.json)
130+
.PHONY: azure-functions-publish
131+
azure-functions-publish: ## publish Azure Functions App
132+
sh ./scripts/publish-azure-functions.sh
136133

137134
# ---
138135
# OpenAPI Client
139136
# ---
140137
.PHONY: generate-openapi-spec
141138
generate-openapi-spec: ## generate OpenAPI spec
142-
poetry run python main.py generate-openapi-spec
139+
cd backend \
140+
&& poetry run python main.py generate-openapi-spec
143141

144142
.PHONY: generate-openapi-client
145143
generate-openapi-client: ## generate OpenAPI client

README.md

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,26 @@ This repository contains a collection of solutions that leverage Azure AI servic
2424
Use Makefile to run the project locally.
2525

2626
```shell
27-
# help
28-
make
27+
# Launch backend API server
28+
make backend
2929

30-
# install dependencies for development
31-
make install-deps-dev
30+
# Launch frontend app server
31+
make frontend
3232

33-
# run tests
34-
make test
35-
36-
# run CI tests
37-
make ci-test
33+
# Azure Functions
34+
make azure-functions-start
3835
```
3936

4037
### Docker development
4138

42-
```shell
43-
# build docker image
44-
make docker-build
39+
See the actual implementation in the [compose.yaml](./compose.yaml) file.
4540

46-
# run docker container
47-
make docker-run
41+
```shell
42+
# Launch backend API server
43+
docker compose up backend
4844

49-
# run CI tests in docker container
50-
make ci-test-docker
45+
# Launch frontend app server
46+
docker compose up frontend
5147
```
5248

5349
### Run local test
@@ -64,18 +60,19 @@ make test
6460

6561
## Deployment instructions
6662

67-
### Docker compose
63+
```shell
64+
# Deploy Azure resources via Bicep
65+
cd infra
66+
make deploy
67+
```
6868

69-
Docker compose is used to run the services locally.
70-
Refer to the following steps to run the services.
71-
See the actual implementation in the [compose.yaml](./compose.yaml) file.
69+
Azure Functions are deployed using the following commands.
7270

7371
```shell
74-
# Create environment files for each service
75-
cp ./settings/{NAME}.env.sample ./settings/{NAME}.env
76-
77-
# Build and run the services
78-
docker compose up
72+
# Deploy Azure Functions
73+
make azure-functions-deploy
74+
# Publish Azure Functions
75+
make azure-functions-publish
7976
```
8077

8178
### Push docker image to Docker Hub
@@ -86,18 +83,3 @@ To publish the docker image to Docker Hub via GitHub Actions, you need to set th
8683
gh secret set DOCKERHUB_USERNAME --body $DOCKERHUB_USERNAME
8784
gh secret set DOCKERHUB_TOKEN --body $DOCKERHUB_TOKEN
8885
```
89-
90-
### Deploy Azure Functions
91-
92-
To deploy the Azure Functions, run the following script.
93-
94-
```shell
95-
# Deploy the Azure Functions
96-
sh ./scripts/deploy-azure-functions.sh
97-
98-
# Destroy the Azure Functions
99-
sh ./scripts/destroy-azure-functions.sh
100-
```
101-
102-
- [scripts/deploy-azure-functions.sh](./scripts/deploy-azure-functions.sh): Deploy the Azure Functions using Azure CLI.
103-
- [scripts/destroy-azure-functions.sh](./scripts/destroy-azure-functions.sh): Destroy the Azure Functions using Azure CLI.
File renamed without changes.

dockerfiles/backend.Dockerfile renamed to backend/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11.8-slim-bookworm as requirements-stage
1+
FROM python:3.11.8-slim-bookworm AS requirements-stage
22

33
WORKDIR /tmp
44

@@ -16,7 +16,7 @@ ARG GIT_TAG="x.x.x"
1616
WORKDIR /app
1717

1818
COPY --from=requirements-stage /tmp/requirements.txt /app/requirements.txt
19-
COPY . .
19+
COPY ./backend/ .
2020

2121
# Install dependencies
2222
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)