parent
c993d2f1af
commit
f52fd40455
@ -0,0 +1,61 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: Deploiement
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: code-analysis
|
||||||
|
image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-python37
|
||||||
|
settings:
|
||||||
|
sonar_host: https://codefirst.iut.uca.fr/sonar/
|
||||||
|
sonar_token:
|
||||||
|
from_secret: SECRET_SONAR_TOKEN
|
||||||
|
|
||||||
|
- name: docker-build-and-push
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
context: .
|
||||||
|
registry: hub.codefirst.iut.uca.fr
|
||||||
|
mirror: https://proxy.iut.uca.fr:8443
|
||||||
|
repo: hub.codefirst.iut.uca.fr/alix.jeudi--lemoine/memorymap_api
|
||||||
|
username:
|
||||||
|
from_secret: SECRET_REGISTRY_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: SECRET_REGISTRY_PASSWORD
|
||||||
|
|
||||||
|
- name: deploy-database
|
||||||
|
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||||
|
environment:
|
||||||
|
IMAGENAME: mongo:8.0.3-noble
|
||||||
|
CONTAINERNAME: memorymap_mongodb
|
||||||
|
COMMAND: create
|
||||||
|
OVERWRITE: true
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_MONGO_INITDB_ROOT_USERNAME:
|
||||||
|
from_secret: SECRET_MONGODB_USERNAME
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_MONGO_INITDB_ROOT_PASSWORD:
|
||||||
|
from_secret: SECRET_MONGODB_PASSWORD
|
||||||
|
|
||||||
|
- name: deploy-container
|
||||||
|
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||||
|
environment:
|
||||||
|
IMAGENAME: hub.codefirst.iut.uca.fr/alix.jeudi--lemoine/memorymap_api:latest
|
||||||
|
CONTAINERNAME: memorymap_api
|
||||||
|
COMMAND: create
|
||||||
|
OVERWRITE: true
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_MONGODB_URL: "mongodb://memorymap_mongodb:27017/"
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_MONGODB_USERNAME:
|
||||||
|
from_secret: SECRET_MONGODB_USERNAME
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_MONGODB_PASSWORD:
|
||||||
|
from_secret: SECRET_MONGODB_PASSWORD
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_MONGODB_DATABASE:
|
||||||
|
from_secret: SECRET_MONGODB_DATABASE
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_JWT_SECRET_KEY:
|
||||||
|
from_secret: SECRET_JWT_SECRET_KEY
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_JWT_ALGORITHM:
|
||||||
|
from_secret: SECRET_JWT_ALGORITHM
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_JWT_ACCESS_TOKEN_EXPIRE_MINUTES:
|
||||||
|
from_secret: SECRET_JWT_ACCESS_TOKEN_EXPIRE_MINUTES
|
@ -1,13 +1,15 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
# Constants for PyMongo
|
# Constants for PyMongo
|
||||||
MONGODB_URL = "mongodb://localhost:27017/"
|
MONGODB_URL = os.getenv("MONGODB_URL", "mongodb://localhost:27017/")
|
||||||
MONGODB_USERNAME = "mongoadmin"
|
MONGODB_USERNAME = os.getenv("MONGODB_USERNAME", "mongoadmin")
|
||||||
MONGODB_PASSWORD = "secret"
|
MONGODB_PASSWORD = os.getenv("MONGODB_PASSWORD", "secret")
|
||||||
MONGODB_DATABASE = "memorymap"
|
MONGODB_DATABASE = os.getenv("MONGODB_DATABASE", "memorymap")
|
||||||
|
|
||||||
# Constants for JWT
|
# Constants for JWT
|
||||||
SECRET_KEY = "_2YfT44$xF.Tg_xI63UH3D7:N+>pZN2';j%>7H@?e0:Xor'pV[" # temporary of course :)
|
SECRET_KEY = os.getenv("JWT_SECRET_KEY", "_2YfT44$xF.Tg_xI63UH3D7:N+>pZN2';j%>7H@?e0:Xor'pV[") # temporary of course :)
|
||||||
ALGORITHM = "HS256" # TODO: check if broken (don't believe)
|
ALGORITHM = os.getenv("JWT_ALGORITHM", "HS256") # TODO: check if broken (don't believe)
|
||||||
ACCESS_TOKEN_EXPIRE_MINUTES = 30 # TODO: check what to add here / maybe need to evaluate criticity of that?
|
ACCESS_TOKEN_EXPIRE_MINUTES = os.getenv("JWT_ACCESS_TOKEN_EXPIRE_MINUTES", 30) # TODO: check what to add here / maybe need to evaluate criticity of that?
|
||||||
|
|
||||||
# Constants for OAuth2
|
# Constants for OAuth2
|
||||||
TOKEN_URL = "login" # Path to the auth
|
TOKEN_URL = "login" # Path to the auth
|
@ -0,0 +1,20 @@
|
|||||||
|
# Official Python image
|
||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
# Set workdir
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the file with the requirements
|
||||||
|
COPY requirements.txt .
|
||||||
|
|
||||||
|
# Install the package dependencies in the requirements file.
|
||||||
|
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
||||||
|
|
||||||
|
# Copy the FastAPI app folder in the container
|
||||||
|
COPY ./app .
|
||||||
|
|
||||||
|
# Expose API port
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Launches the uvicorn server (command from offical FastAPI documentation)
|
||||||
|
CMD ["fastapi", "run", "app/main.py", "--port", "80"]
|
@ -1,28 +0,0 @@
|
|||||||
def users_serialize(users: list) -> list:
|
|
||||||
serialized_users: list = []
|
|
||||||
for user in users:
|
|
||||||
serialized_users.append({
|
|
||||||
"id": str(user["_id"]),
|
|
||||||
"username": user["username"]
|
|
||||||
})
|
|
||||||
return serialized_users
|
|
||||||
|
|
||||||
def friends_serialize(friends: list) -> list:
|
|
||||||
serialized_friends: list = []
|
|
||||||
for friend in friends:
|
|
||||||
serialized_friends.append({
|
|
||||||
"id": str(friend["_id"]),
|
|
||||||
"user_id": friend["user_id"]
|
|
||||||
})
|
|
||||||
return serialized_friends
|
|
||||||
|
|
||||||
def pins_serialize(pins: list) -> list:
|
|
||||||
serialized_pins: list = []
|
|
||||||
for pin in pins:
|
|
||||||
serialized_pins.append({
|
|
||||||
"id": str(pin["_id"]),
|
|
||||||
"title": pin["title"],
|
|
||||||
"description": pin["description"]
|
|
||||||
|
|
||||||
})
|
|
||||||
return serialized_pins
|
|
Loading…
Reference in new issue