Skip to content

Commit 7c0ac32

Browse files
authored
Merge pull request #2 from MrMatAP/feature/container
Containerisation
2 parents bfa9fbc + b515a04 commit 7c0ac32

File tree

28 files changed

+253
-169
lines changed

28 files changed

+253
-169
lines changed

.idea/dataSources.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/mrmat-python-api-fastapi.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/run.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
GIT_SHA := $(shell git rev-parse --short HEAD)
66
VERSION ?= 0.0.0-dev0.${GIT_SHA}
77
PYTHON_VERSION := $(shell echo "${VERSION}" | sed -e 's/-dev0\./-dev0+/')
8+
WHEEL_VERSION := $(shell echo "${VERSION}" | sed -e 's/-dev0\./.dev0+/')
9+
10+
ROOT_PATH := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
811

912
PYTHON_SOURCES := $(shell find src/mrmat_python_api_fastapi -name '*.py')
10-
PYTHON_TARGET := dist/mrmat_python_api_fastapi-${PYTHON_VERSION}-py3-none-any.whl
13+
PYTHON_TARGET := dist/mrmat_python_api_fastapi-${WHEEL_VERSION}-py3-none-any.whl
1114
CONTAINER_SOURCES := $(shell find var/container)
1215
HELM_SOURCES := $(shell find var/helm)
1316
HELM_TARGET := dist/mrmat-python-api-fastapi-$(VERSION).tgz
@@ -31,16 +34,22 @@ container: $(PYTHON_TARGET) $(CONTAINER_SOURCES)
3134
-f var/container/Dockerfile \
3235
-t localhost:5001/mrmat-python-api-fastapi:$(VERSION) \
3336
--build-arg MRMAT_VERSION=$(VERSION) \
34-
.
37+
--build-arg WHEEL=$(PYTHON_TARGET) \
38+
$(ROOT_PATH)
3539
docker push localhost:5001/mrmat-python-api-fastapi:$(VERSION)
3640

3741
helm-install: $(HELM_TARGET)
42+
kubectl create ns mpafastapi || true
43+
kubectl label --overwrite ns mpafastapi istio-injection=true
3844
helm upgrade \
3945
mrmat-python-api-fastapi \
4046
${HELM_TARGET} \
4147
--install \
42-
--create-namespace \
43-
--namespace mrmat-python-api-fastapi
48+
--force \
49+
--namespace mpafastapi
50+
51+
helm-uninstall:
52+
helm delete -n mpafastapi mrmat-python-api-fastapi
4453

4554
clean:
4655
rm -rf build dist

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
[![Build](https://github.com/MrMatOrg/mrmat-python-api-fastapi/actions/workflows/build.yml/badge.svg)](https://github.com/MrMatOrg/mrmat-python-api-fastapi/actions/workflows/build.yml)
44

55

6-
Boilerplate (and playground) for a code-first Python FastAPI API, with all the bells and whistles we've come to expect
6+
Boilerplate (and playground) for a code-first Python FastAPI API, with all the bells and whistles we've come to expect.
77

requirements.txt

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
11
#
22
# Runtime requirements
33

4-
fastapi==0.115.11 # MIT
5-
sqlalchemy[asyncio]==2.0.40 # MIT
6-
uvicorn==0.34.0 # BSD 3-Clause
7-
pydantic==2.10.6 # MIT
4+
fastapi==0.115.11 # MIT
5+
sqlalchemy[asyncio]==2.0.40 # MIT
6+
uvicorn==0.34.0 # BSD 3-Clause
7+
pydantic==2.10.6 # MIT
8+
psycopg2-binary==2.9.10 # LGPL with exceptions
9+
10+
prometheus-fastapi-instrumentator==7.1.0 # ISC
11+
12+
# For zero-code-instrumentation
13+
# Check the requirements by using opentelemetry-bootstrap -a requirements
14+
opentelemetry-distro # Apache 2.0
15+
opentelemetry-exporter-otlp
16+
opentelemetry-instrumentation-asyncio==0.53b1
17+
opentelemetry-instrumentation-dbapi==0.53b1
18+
opentelemetry-instrumentation-logging==0.53b1
19+
opentelemetry-instrumentation-sqlite3==0.53b1
20+
opentelemetry-instrumentation-threading==0.53b1
21+
opentelemetry-instrumentation-urllib==0.53b1
22+
opentelemetry-instrumentation-wsgi==0.53b1
23+
opentelemetry-instrumentation-asgi==0.53b1
24+
opentelemetry-instrumentation-click==0.53b1
25+
opentelemetry-instrumentation-fastapi==0.53b1
26+
opentelemetry-instrumentation-grpc==0.53b1
27+
opentelemetry-instrumentation-httpx==0.53b1
28+
opentelemetry-instrumentation-requests==0.53b1
29+
opentelemetry-instrumentation-sqlalchemy==0.53b1
30+
opentelemetry-instrumentation-starlette==0.53b1
31+
opentelemetry-instrumentation-tortoiseorm==0.53b1
32+
opentelemetry-instrumentation-urllib3==0.53b1

src/mrmat_python_api_fastapi/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
22+
2223
from pydantic import BaseModel
2324

2425
from .config import Config
25-
app_config = Config.from_json_file()
26+
app_config = Config.from_context()
2627
from sqlalchemy.orm import DeclarativeBase
2728

2829
class ORMBase(DeclarativeBase):

src/mrmat_python_api_fastapi/apis/greeting/v2/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
from typing import Optional
2828
from fastapi import APIRouter
29+
2930
from mrmat_python_api_fastapi.apis.greeting.v2 import GreetingV2Output
3031

3132
router = APIRouter()

src/mrmat_python_api_fastapi/apis/greeting/v3/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# SOFTWARE.
2222

2323
from fastapi import APIRouter
24+
2425
from mrmat_python_api_fastapi.apis.greeting.v3 import GreetingV3Output
2526

2627
router = APIRouter()

0 commit comments

Comments
 (0)