feat: Инициализация API проекта
Добавлена базовая структура проекта, включая Dockerfile, Helm charts и .gitignore.
This commit is contained in:
parent
f4bd6a483b
commit
cd4967fd40
4
api/.dockerignore
Normal file
4
api/.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
.venv
|
||||
k8s
|
||||
.idea
|
||||
k8s
|
||||
3
api/.gitignore
vendored
Normal file
3
api/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
k8s/helm/visus-api/templates/secrets.yaml
|
||||
.venv
|
||||
*.pyc
|
||||
18
api/app/Dockerfile
Normal file
18
api/app/Dockerfile
Normal file
@ -0,0 +1,18 @@
|
||||
FROM python:3.10-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libpq-dev \
|
||||
libmagic1 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY req.txt .
|
||||
|
||||
RUN pip install --no-cache-dir -r req.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["uvicorn", "app.main:app", "--host=0.0.0.0"]
|
||||
5
api/k8s/helm/visus-api/Chart.yaml
Normal file
5
api/k8s/helm/visus-api/Chart.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
apiVersion: v2
|
||||
name: visus-api-app
|
||||
description: Visus API project
|
||||
version: 0.1.0
|
||||
appVersion: "1.0"
|
||||
35
api/k8s/helm/visus-api/templates/deployment.yaml
Normal file
35
api/k8s/helm/visus-api/templates/deployment.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Chart.Name }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ .Chart.Name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ .Chart.Name }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
ports:
|
||||
- containerPort: {{ .Values.service.port }}
|
||||
env:
|
||||
- name: SECRET_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: visus-api-secret
|
||||
key: SECRET_KEY
|
||||
volumeMounts:
|
||||
- name: uploads-volume
|
||||
mountPath: {{ .Values.persistence.uploads.containerPath }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
volumes:
|
||||
- name: uploads-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: "{{ .Release.Name }}-uploads-pvc"
|
||||
23
api/k8s/helm/visus-api/templates/ingress.yaml
Normal file
23
api/k8s/helm/visus-api/templates/ingress.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: visus-api-ingress
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: lets-encrypt
|
||||
spec:
|
||||
tls:
|
||||
- hosts:
|
||||
- {{ .Values.ingress.domain }}
|
||||
secretName: {{ .Values.ingress.secretTLSName }}
|
||||
ingressClassName: public
|
||||
rules:
|
||||
- host: {{ .Values.ingress.domain }}
|
||||
http:
|
||||
paths:
|
||||
- path: {{ .Values.ingress.path }}
|
||||
pathType: {{ .Values.ingress.pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ .Chart.Name }}-service
|
||||
port:
|
||||
number: {{ .Values.service.port }}
|
||||
29
api/k8s/helm/visus-api/templates/pvc.yaml
Normal file
29
api/k8s/helm/visus-api/templates/pvc.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
{{- if .Values.persistence.uploads.enabled }}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: {{ .Chart.Name }}-uploads-pv
|
||||
spec:
|
||||
capacity:
|
||||
storage: {{ .Values.persistence.uploads.size }}
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: microk8s-hostpath
|
||||
hostPath:
|
||||
path: {{ .Values.persistence.path }}/uploads
|
||||
type: DirectoryOrCreate
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ .Chart.Name }}-uploads-pvc
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: microk8s-hostpath
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.uploads.size }}
|
||||
volumeName: {{ .Chart.Name }}-uploads-pv
|
||||
{{- end }}
|
||||
11
api/k8s/helm/visus-api/templates/service.yaml
Normal file
11
api/k8s/helm/visus-api/templates/service.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .Chart.Name }}-service
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: {{ .Values.service.port }}
|
||||
selector:
|
||||
app: {{ .Chart.Name }}
|
||||
35
api/k8s/helm/visus-api/values.yaml
Normal file
35
api/k8s/helm/visus-api/values.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: andreiduvakin/visus-api:latest
|
||||
tag: latest
|
||||
pullPolicy: Always
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 8000
|
||||
|
||||
resources:
|
||||
limits:
|
||||
memory: 512Mi
|
||||
cpu: 500m
|
||||
|
||||
persistence:
|
||||
path: /mnt/k8s_storage/visus-api
|
||||
uploads:
|
||||
enabled: true
|
||||
size: 7Gi
|
||||
containerPath: /app/uploads
|
||||
|
||||
ingress:
|
||||
secretTLSName: visus-api-tls-secret
|
||||
|
||||
domain: api.visus.numerum.team
|
||||
|
||||
path: /
|
||||
pathType: Prefix
|
||||
|
||||
env:
|
||||
LOG_LEVEL: info
|
||||
LOG_FILE: logs/app.log
|
||||
ALGORITHM: HS256
|
||||
@ -9,4 +9,6 @@ SQLAlchemy==2.0.37
|
||||
uvicorn==0.34.0
|
||||
Werkzeug==3.1.3
|
||||
pyjwt==2.10.1
|
||||
python-magic==0.4.27
|
||||
python-magic==0.4.27
|
||||
aiofiles==24.1.0
|
||||
python-multipart==0.0.20
|
||||
Loading…
x
Reference in New Issue
Block a user