{"id":25221683,"url":"https://github.com/monadical-sas/morpheus","last_synced_at":"2025-10-25T20:30:27.535Z","repository":{"id":175889879,"uuid":"654324163","full_name":"Monadical-SAS/Morpheus","owner":"Monadical-SAS","description":"Morpheus is an open-source project that offers a creative and innovative platform for generating stunning artworks using image editing and stable diffusion models.","archived":false,"fork":false,"pushed_at":"2023-12-17T22:27:22.000Z","size":91982,"stargazers_count":25,"open_issues_count":24,"forks_count":3,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-04-28T04:38:46.165Z","etag":null,"topics":["celery","collaborative","color-palette","controlnet","fastapi","generative-art","helm","huggingface","huggingface-diffusers","img2img","inpainting","kubernetes","nextjs","python3","stable-diffusion","terraform","text2image","upscaling"],"latest_commit_sha":null,"homepage":"https://morpheus.monadical.io/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Monadical-SAS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-06-15T22:04:39.000Z","updated_at":"2024-03-18T15:17:10.000Z","dependencies_parsed_at":"2023-09-24T05:17:18.426Z","dependency_job_id":null,"html_url":"https://github.com/Monadical-SAS/Morpheus","commit_stats":null,"previous_names":["monadical-sas/morpheus"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Monadical-SAS%2FMorpheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Monadical-SAS%2FMorpheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Monadical-SAS%2FMorpheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Monadical-SAS%2FMorpheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Monadical-SAS","download_url":"https://codeload.github.com/Monadical-SAS/Morpheus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238202158,"owners_count":19433177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["celery","collaborative","color-palette","controlnet","fastapi","generative-art","helm","huggingface","huggingface-diffusers","img2img","inpainting","kubernetes","nextjs","python3","stable-diffusion","terraform","text2image","upscaling"],"created_at":"2025-02-10T22:53:01.805Z","updated_at":"2025-10-25T20:30:22.540Z","avatar_url":"https://github.com/Monadical-SAS.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003eMorpheus\u003cbr/\u003e\u003csub\u003eA WebApp to generate artwork with stable diffusion models.\u003c/sub\u003e\u003c/h1\u003e\n\n▶️ \u003ca href=\"#quickstart\"\u003eQuickstart\u003c/a\u003e |\n\u003ca href=\"https://morpheus.monadical.io/\"\u003eDemo\u003c/a\u003e |\n\u003ca href=\"https://github.com/Monadical-SAS/Morpheus\"\u003eGitHub\u003c/a\u003e |\n\u003ca href=\"https://github.com/Monadical-SAS/Morpheus/wiki\"\u003eDocumentation\u003c/a\u003e |\n\u003ca href=\"#background--motivation\"\u003eInfo \u0026 Motivation\u003c/a\u003e |\n\u003ca href=\"https://github.com/Monadical-SAS/Morpheus/wiki/similar-projects\"\u003eSimilar Projects\u003c/a\u003e |\n\u003ca href=\"https://github.com/Monadical-SAS/Morpheus/wiki/Roadmap\"\u003eRoadmap\u003c/a\u003e\n\n\u003ca href=\"https://github.com/Monadical-SAS/Morpheus/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/Open_source-LGPL-green.svg?logo=git\u0026logoColor=green\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Monadical-SAS/Morpheus/\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/Monadical-SAS/Morpheus.svg?logo=github\u0026label=Stars\u0026logoColor=blue\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Monadical-SAS/Morpheus/commits/main\"\u003e\u003cimg src=\"https://img.shields.io/github/last-commit/Monadical-SAS/Morpheus.svg?logo=Sublime+Text\u0026logoColor=green\u0026label=active\"/\u003e\u003c/a\u003e\n\u0026nbsp;\n\u003chr/\u003e\n\n**Morpheus is an open-source project that offers a creative and innovative platform for generating stunning artworks\nusing image editing and stable diffusion models.**\n\n\n\u003cdiv align=\"center\"\u003e\n\u003csub\u003e. . . . . . . . . . . . . . . . . . . . . . . . . . . .\u003c/sub\u003e\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\n## Key Features\n\n- **Freedom \u0026 Open Source**: Create your personal server and maintain complete control over your data.\n- **Robust \u0026 Modular Design**: Our design supports and loads multiple models with ease.\n- **Versatility**: We offer Image-to-Image support, Controlnet, and Pix2pix among other use cases.\n- **Local or Cloud Setup**: Choose the setup that suits your needs best.\n- **Infrastructure as Code**: We've open-sourced our infrastructure code to facilitate scalability.\n\n\u003cbr/\u003e\u003cbr/\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cbr/\u003e\n\u003cimg src=\"https://i.imgur.com/T2UAGUD.png\" width=\"49%\" alt=\"grass\"/\u003e\u003cimg src=\"https://i.imgur.com/T2UAGUD.png\" width=\"49%\" alt=\"grass\"/\u003e\n\u003c/div\u003e\n\n# Quickstart\n\n**🖥\u0026nbsp; Supported OSs:** Linux, macOS (M1-M2) \u0026nbsp; **👾**\n\n## Prequisites:\n\nBefore starting, ensure you have the following:\n\n1. **Firebase**: Morpheus uses firebase to manage authentication, analytics, and the collaborative painting system.\n   Follow the [Firebase Integration Guide](./docs/firebase/firebase.md) to enable the required firebase services.\n\n2. **Docker \u0026 Docker Compose**: Both Docker and Docker-Compose should be installed on your system. If not installed yet,\n   you can download Docker from \u003ca href=\"https://docs.docker.com/get-docker/\"\u003ehere\u003c/a\u003e and Docker-Compose from  \u003ca\n   href=\"https://docs.docker.com/compose/install/#install-using-pip\"\u003ehere\u003c/a\u003e. Skip this step if you're using a\n   Kubernetes setup.\n\n3. **Hardware**: The hardware requirements for this setup will vary depending on the specific application that you are\n   developing. However, it is generally recommended to have a machine with at least 16 GB of RAM and a GPU with 16 GB of\n   VRAM. If you don't have a GPU, you can use a cloud\n   provider like AWS, GCP, or Azure. Skip this step if you're using a Kubernetes setup.\n   \u003cbr/\u003e\n\n## Setup Steps\n\n**Step 1: Verify that Docker is installed and running**\n\nEnsure that Docker and Docker-Compose are installed on your system. If not, install them using the links above. For\nLinux users, you might also need to add your user to the docker group. For more information, see\nthe \u003ca href=\"https://docs.docker.com/engine/install/linux-postinstall/\"\u003eDocker\ndocumentation\u003c/a\u003e for more details.\n\n**Step 2: Clone the repository**\n\nClone the repository to your local system using the command below:\n\n```bash\ngit clone git@github.com:Monadical-SAS/Morpheus.git\n```\n\n**Step 3: Navigate to the Morpheus directory**\n\nChange your current directory to the cloned repository:\n\n```bash\ncd Morpheus\n```\n\n**Step 4: Create a secrets file**\n\nCreate the secrets file by copying the distributed `.env` files:\n\n```bash\ncp -p morpheus-server/secrets.env.dist morpheus-server/secrets.env\ncp -p morpheus-client/env.local.dist morpheus-client/.env.local\ncp -p morpheus-client/env.local.dist morpheus-admin/.env.local\n```\n\n**Step 5: Edit the `morpheus-server/secrets.env` file with your values**\n\nThis step involves editing the `secrets.env` file to provide the application with the necessary secrets to connect to\nthe database, Firebase, AWS, and other services.\n\n**Parameters:**\n\n* `POSTGRES_USER`: The username for the PostgreSQL database.\n* `POSTGRES_DB`: The name of the PostgreSQL database.\n* `POSTGRES_PASSWORD`: The password for the PostgreSQL database.\n* `POSTGRES_HOST`: The hostname or IP address of the PostgreSQL database server.\n* `POSTGRES_PORT`: The port number of the PostgreSQL database server.\n* `PGADMIN_DEFAULT_EMAIL`: The email address for the PGAdmin default user.\n* `PGADMIN_DEFAULT_PASSWORD`: The password for the PGAdmin default user.\n* `FIREBASE_PROJECT_ID`: The ID of your Firebase project.\n* `FIREBASE_PRIVATE_KEY`: The private key for your Firebase project.\n* `FIREBASE_CLIENT_EMAIL`: The client email for your Firebase project.\n* `FIREBASE_WEB_API_KEY`: The web API key for your Firebase project.\n* `AWS_ACCESS_KEY_ID`: The access key ID for your AWS account.\n* `AWS_SECRET_ACCESS_KEY`: The secret access key for your AWS account.\n* `IMAGES_BUCKET`: The name of the S3 bucket where images are stored.\n* `MODELS_BUCKET`: The name of the S3 bucket where models are stored.\n* `IMAGES_TEMP_BUCKET`: The name of the S3 bucket where temporary images are stored.\n* `ENVIRONMENT`: The environment where the application is running. This can be `local`, `staging`, or `production`.\n\n**Instructions:**\n\n1. Open the `secrets.env` file in your preferred text editor.\n2. Replace all content with the following:\n\n```bash\nPOSTGRES_USER=morpheus\nPOSTGRES_DB=morpheus\nPOSTGRES_PASSWORD=password\nPOSTGRES_HOST=postgres\nPOSTGRES_PORT=5432\n\n# PGAdmin credentials\nPGADMIN_DEFAULT_EMAIL=admin@admin.com\nPGADMIN_DEFAULT_PASSWORD=admin\n\nFIREBASE_PROJECT_ID=\"XXXXXXX=\"\nFIREBASE_PRIVATE_KEY=\"XXXXXXX=\"\nFIREBASE_CLIENT_EMAIL=\"XXXXXXX=\"\nFIREBASE_WEB_API_KEY=\"XXXXXXX=\"\n\n# AWS credentials\nAWS_ACCESS_KEY_ID=XXXXXXX=\nAWS_SECRET_ACCESS_KEY=XXXXXXX=\n\n# S3 BUCKETS ID\n#------------------------\n# Bucket name where images are stored\nIMAGES_BUCKET=\"XXXXXXX=\"\n# Bucket name where models are stored\nMODELS_BUCKET=\"XXXXXXX=\"\n# Bucket/Folder where temporal images are stored\nIMAGES_TEMP_BUCKET=\"ßXXXXXXX=\"\n\n# App config\nENVIRONMENT=\"local\"\n```\n\n3. Update the values with your own.\n4. Save the file.\n\nOnce you have updated the `secrets.env` file, the application will be able to connect to the database, Firebase, AWS,\nand other services using the secrets that you provided.\n\n**Step 6. Edit the `morpheus-client/.env.local` and `morpheus-admin/.env.local` files with your values**\n\nThis step involves editing the `.env.local` files in the `morpheus-client` and `morpheus-admin` directories to provide\nthe client application with the necessary values to connect to the backend API, Firebase, and other services.\n\n**Parameters:**\n\n* `NEXT_PUBLIC_API_URL`: The URL of the backend API.\n* `NEXT_PUBLIC_FIREBASE_CONFIG`: The Firebase configuration for your Firebase project. This can be found in the\n  Firebase console.\n* `NEXT_TELEMETRY_DISABLED`: A boolean value indicating whether to disable telemetry.\n* `NEXT_PUBLIC_BACKEND_V2_GET_URL`: The URL of the Excalidraw backend v2 GET endpoint.\n* `NEXT_PUBLIC_BACKEND_V2_POST_URL`: The URL of the Excalidraw backend v2 POST endpoint.\n* `NEXT_PUBLIC_LIBRARY_URL`: The URL of the Excalidraw libraries page.\n* `NEXT_PUBLIC_LIBRARY_BACKEND`: The URL of the Excalidraw library backend.\n* `NEXT_PUBLIC_WS_SERVER_URL`: The URL of the WebSocket server.\n* `NEXT_PUBLIC_GOOGLE_ANALYTICS_ID`: The Google Analytics ID for the client application.\n* `FAST_REFRESH`: A boolean value indicating whether to enable Fast Refresh.\n\n**Instructions:**\n\n1. Open the `.env.local` file in your preferred text editor.\n2. Replace all content with the following:\n\n```bash\n# API CONFIG\nNEXT_PUBLIC_API_URL=http://localhost:8001\n\n# Firebase configuration\nNEXT_PUBLIC_FIREBASE_CONFIG='{\"apiKey\":\"XXXXXXXXXXXX\",\"authDomain\":\"xxxxxxxxxx.firebaseapp.com\",\"projectId\":\"xxxxxxx\",\"storageBucket\":\"xxxxxx.appspot.com\",\"messagingSenderId\":\"123456789\",\"appId\":\"1:123456789:web:xxxxxx\",\"measurementId\":\"G-XXXXXXXXXX\"}'\n\n# NEXT CONFIG\nNEXT_TELEMETRY_DISABLED=1\n\n# EXCALIDRAW CONFIG\nNEXT_PUBLIC_BACKEND_V2_GET_URL=https://json-dev.excalidraw.com/api/v2/\nNEXT_PUBLIC_BACKEND_V2_POST_URL=https://json-dev.excalidraw.com/api/v2/post/\nNEXT_PUBLIC_LIBRARY_URL=https://libraries.excalidraw.com\nNEXT_PUBLIC_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\nNEXT_PUBLIC_WS_SERVER_URL=ws://localhost:3002\nNEXT_PUBLIC_GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX\nFAST_REFRESH=false\n```\n\n3. Update the values with your own.\n4. Save the file.\n\nOnce you have updated the `.env.local` file, the client application will be able to connect to the backend API,\nFirebase, and other services using the values that you provided.\n\n**Step 7. Init the database**\n\nTo initialize the database, apply the migrations by executing the following commands:\n\n```bash\ndocker compose run --rm datalib alembic upgrade head\n```\n\n**Step 8. Run the Morpheus project**\n\nTo run the Morpheus project, execute the following command:\n\n```bash\ndocker compose up\n```\n\nThe Morpheus project will be running on your local machine at localhost:3000 (client), localhost:3001 (admin), and\nlocalhost:8001 (api). Morpheus uses some Stable Diffusion models by default, if you want to change the setup you\ncan do it from the administration panel.\n\n# Development\n\n## Running the backend tests\n\n* To run all the tests: `docker compose run --rm api pytest`.\n* To run a specific test: `docker compose run --rm api pytest tests/«test_module».py`.\n* To run a specific test function: `docker compose run --rm api pytest tests/«test_module».py::«test_function»`.\n\n## Running the migrations\n\nTo use `morpheus-data` image to run the migrations, you need to create a secrets.env file in the morpheus-server\ndirectory. For more information, you can read the morpheus-data [README](./morpheus-data/README.md).\n\n* To create a migration:\n\n```bash\ndocker compose run --rm datalib alembic revision --autogenerate -m \"Initial migration\"\n```\n\n* To migrate or update to the head:\n\n```bash\ndocker compose run --rm datalib alembic upgrade head\n```\n\n## PG admin\n\nPGadmin is available in: localhost:8002. The user and password must be added in secrets.env file.\n\n### example values\n\n```\nPGADMIN_DEFAULT_EMAIL=admin@admin.com\nPGADMIN_DEFAULT_PASSWORD=password\n```\n\n## Implement changes in morpheus-data\n\n`morpheus-data` is a Python library that provides a unified interface for managing all ORM-related operations in\nMorpheus. Other Morpheus microservices can import and use it.\n\nTo run Morpheus locally using `morpheus-data` as a library:\n\n```bash\n\n# Building in separate steps\n#---------------------------------------------\n# build morpheus-data wheel\ndocker compose build datalib\n\n# build morpheus-server api\ndocker compose build api\n\n# Building alltogether\n#---------------------------------------------\ndocker compose build\n\n# Run\n#---------------------------------------------\ndocker compose up\n```\n\n**Note**: You need to build `morpheus-data` and the `morpheus-server` API service (or any other microservice that uses\nit) every time you make a change to `morpheus-data`. This is necessary because you need to rebuild the wheel file and\ninstall it in the `morpheus-server` API service or any other service that uses it. For more information, see\nthe `morpheus-data` [README](./morpheus-data/README.md).\n\n## Adding a new dependency to the backend\n\n1. Add the new dependency directly to the respective `requirements.txt` file.\n2. Update the docker image: `docker compose build api`.\n3. Run the image: `docker compose up`.\n\n**Note:** This project uses `requirements.lint.txt` only for caching in CI workflow linting job.\n\n## Adding a new dependency to the frontend\n\n```shell\n# Add a new dependency to the npm package.json file\nyarn install \u003cdependency\u003e\n\n# Update the docker image\ndocker compose build client\n\n# Run the image\ndocker compose up\n```\n\n## Add new diffusion models\n\nThere are two ways to add new diffusion models to Morpheus:\n\n* Using the admin panel\n* Using the command-line interface (CLI)\n\n**Using the admin panel**\n\nTo use the admin panel, go to localhost:3001. For more details on how to use the admin panel, see\n[here](https://github.com/Monadical-SAS/Morpheus/wiki/Morpheus-Admin-webUI).\n\n**Using the CLI**\n\nTo use the CLI, you must first build the Morpheus server:\n\n```bash\ndocker compose --profile manage build\n\n#or \n\ndocker compose build model-script\n```\n\nOnce the `model-script` is built, you can use the `morpheus-server/scripts/models/cli.py` script to add, list, and\ndelete models. You can also use the `morpheus-server/scripts/models/models-info.yaml` file to specify information about\nthe models.\n\n```bash\n# To show the help\ndocker compose run --rm model-script --help\n\n# To add/update a new model\ndocker compose run --rm model-script upload \u003cserver\u003e \u003ctarget\u003e\n\n# To list content of S3 bucket\ndocker compose run --rm model-script s3 list\n\n# To list content of db from a specific api server\ndocker compose run --rm model-script db list \u003cserver\u003e --target \u003ctarget\u003e\n\n# To add models to the s3 bucket\ndocker compose run --rm model-script s3 register \u003ctarget\u003e\n\n# To add model to the db of a specific api server\ndocker compose run --rm model-script db register \u003cserver\u003e \u003ctarget\u003e\n\n# To update model in the db of a specific api server\ndocker compose run --rm model-script db update \u003cserver\u003e \u003ctarget\u003e\n\n# To delete a model from s3, db and local\ndocker compose run --rm model-script delete \u003cmodel-source\u003e --api-server \u003cserver\u003e --target \u003ctarget\u003e\n\n# To delete a model from s3\ndocker compose run --rm model-script s3 delete \u003cmodel-source\u003e\n\n# To delete a model from db of a specific api server\ndocker compose run --rm model-script db delete \u003cmodel-source\u003e \u003cserver\u003e --target \u003ctarget\u003e\n\n```\n\nTo use the admin panel, go to localhost:3001. For more details on how to use the admin panel, see\n[here](https://github.com/Monadical-SAS/Morpheus/wiki/Morpheus-Admin-CLI).\n\n## Adding a new feature\n\nIf you want to add a new feature, you should follow the next steps:\n\n- Choose an issue from the [issues list](https://github.com/Monadical-SAS/Morpheus/issues) or create a new one\n- Assign yourself to the issue\n- Create a new branch from the main branch\n- Make your changes\n- Write tests for your changes\n- Make sure to run the QA tools and the tests\n- Push your changes\n- Create a pull request\n- If the pull request includes frontend changes, you should also upload some screenshots of the changes\n- Request a review from a team member\n\n### Important\n\nBefore pushing your changes, make sure to run the QA tools and the tests\n\n```bash\n# Run the QA tools\ndocker compose run --rm api flake8 --max-line-length 120 --exclude app/migrations/ .\ndocker compose run --rm api black --line-length 120 --exclude app/migrations/ .\n  \n# Run the tests\ndocker compose run --rm api pytest\n```\n\nIf all the checks pass, you can push your changes\n\n# Production Setup\n\n## Configuring k8s cluster\n\nSome templates have been included to help create the Kubernetes cluster and the necessary infrastructure. For more\ninformation on configuration, see this link: [link](https://github.com/Monadical-SAS/Morpheus/tree/main/infra/modules).\n\nTo configure Terraform, please follow these steps:\n\n* Create a new SSL certificate using the ACM (Amazon Certificate Manager) service in AWS to obtain the ARN (Amazon\n  Resource Name). This certificate will be used to secure the Morpheus web application. The ARN (Amazon Resource Name)\n  of the certificate is a unique identifier that you will need in the next step.\n* Create a DB secret using the \"Secrets Manager\" service in the AWS console. The secret should be an \"Other type of\n  secret\". The value must be in this format: `{\"username\":\"username\",\"password\":\"xxxxxxxxxxxxxxxxx\"}`. Save the\n  secret name for the next steps.\n* Create a terraform.tfvars file in the `./infra/envs/staging/` folder with the information obtained from your AWS\n  account. Use the ARN for the \u003cem\u003earn_ssl_certificate_cf_distribution\u003c/em\u003e field and the DB secret name for \u003cem\u003e\n  db_password_secret_manager_name\u003c/em\u003e. Additionally, update `cname_frontend` with a domain that you manage. Here is an\n  example:\n\n```\nAWS_ACCESS_KEY = \"\"\nAWS_SECRET_KEY = \"\"\nACCOUNT_ID = \"xxxxxxxxxxx\"\ndb_password_secret_manager_name = \"morpheus_db_password\"\narn_ssl_certificate_cf_distribution = \"arn:aws:acm:us-east-1:xxxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxx\"\ncname_frontend = \"morpheus.web.site\"\nvpc_cidr = \"172.21.0.0/16\"\nvpc_public_subnets = [\"172.21.0.10/24\", \"172.21.0.11/24\"]\nvpc_private_subnets = [\"172.21.0.12/24\", \"172.21.0.13/24\"]\ndb_allocated_storage = 20\nself_managed_gpu_nodes_device_size = 30\nregion = \"us-east-1\"\n```\n\nwhere:\n\n* `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` are your AWS credentials. You can obtain these credentials from the AWS\n  Management Console.\n* `ACCOUNT_ID` is your AWS account ID. You can find this information in the AWS Management Console.\n* `db_password_secret_manager_name` is the name of the DB secret that you created in step 2.\n* `arn_ssl_certificate_cf_distribution` is the ARN of the SSL certificate that you created in step 1.\n* `cname_frontend` is the domain name that you want to use for the Morpheus web application.\n* `vpc_cidr` is the CIDR block for the VPC that Terraform will create.\n* `vpc_public_subnets` and `vpc_private_subnets` are the CIDR blocks for the public and private subnets that Terraform\n  will create.\n* `db_allocated_storage` is the size of the EBS volume that Terraform will create for the Morpheus database.\n* `self_managed_gpu_nodes_device_size` is the size of the GPU for the self-managed GPU nodes that Terraform will create.\n* `region` is the AWS region where you want to create the Kubernetes cluster and the necessary infrastructure.\n\nTo manage Terraform backends, follow these steps:\n\n1. Create an S3 bucket to manage the Terraform backends.\n2. Create a backend.conf file in ./infra/envs/staging/ based on backend.conf.dist. Make sure to update the route if you\n   prefer to use a different one.\n\n```conf\nbucket = \"morpheus-infra-backend\"\nkey = \"env/staging/infra/state.tfstate\"\nregion = \"us-east-1\"\n```\n\n3. Create the cluster:\n\n* Navigate to the ./infra/envs/staging directory. This is where the Terraform configuration files for the staging\n  environment are located.\n\n```bash\ncd ./infra/envs/staging\n```\n\n* Initialize Terraform. This command will download the necessary modules and providers.\n\n```bash\nterraform init -backend-config=backend.conf\n```\n\n* Apply the Terraform configuration. This command will create the Kubernetes cluster and the necessary infrastructure.\n  You will be prompted to confirm the changes before they are applied.\n\n```bash\nterraform apply\n```\n\n* Save the Terraform outputs to a separate file.\n\n```bash\nterraform output \u003e outputs.tfvars\n```\n\nThe Terraform outputs are the values of the variables that Terraform created when it applied the configuration. These\nvalues can be useful for configuring other applications, such as kubectl.\nSaving the outputs to a file will make it easy to access them in the next step, when you create the kubectl\nconfiguration file.\n\n* Create a kubectl configuration file to access the cluster. Use the Terraform outputs to complete the arguments for the\n  region and cluster name.\n\n```bash\naws eks --region us-east-1 update-kubeconfig --name cluster-name-from-outputs\n```\n\n* The kubectl configuration file is used to tell kubectl how to connect to the Kubernetes cluster.\n* The aws eks update-kubeconfig command will create a kubectl configuration file for the specified cluster in the\n  specified region.\n* You will need to replace cluster-name-from-outputs with the name of the Kubernetes cluster that was created by\n  Terraform.\n  Once you have completed these steps, you will be able to use kubectl to manage the Kubernetes cluster.\n\n### Installing helm charts - Nginx ingress\n\n1. Create a backend.conf file in the ./infra/charts/staging/ folder based on the backend.conf.dist file provided.\n\n```\nbucket = \"morpheus-infra-backend\"\nkey = \"env/staging/charts/state.tfstate\"\nregion = \"us-east-1\"\n```\n\n2. Create a terraform.tfvars file in the ./infra/envs/staging/ folder that includes the path to your Kubernetes\n   configuration.\n\n```\nkubeconfig_path = \"/home/user/.kube/config\"\n```\n\n3. To apply the Ingress Helm chart (this step should be performed after creating the cluster):\n\n```bash\ncd ./infra/test/eks-charts\nterraform init -backend-config=backend.conf\n# write yes to apply changes\nterraform apply\n```\n\n### Creating secrets\n\ncreate a file called morpheus-secrets.yaml based on ./infra/tools/k8s/morpheus-secrets.yaml.example.\nMake sure to update the values with the secrets that are coded in base64.\n\n```bash\n# To code for example POSTGRES_USER\necho -n \"dbpassword\" | base64 -w 0\n```\n\n```yaml\napiVersion: v1\nkind: Secret\nmetadata:\n  name: morpheus-secret\ntype: Opaque\ndata:\n  POSTGRES_USER: XXXXXXX=\n  POSTGRES_DB: XXXXXXX=\n  POSTGRES_PASSWORD: XXXXXX=\n  POSTGRES_HOST: XXXXXXX=\n  FIREBASE_PROJECT_ID: XXXXXX=\n  FIREBASE_PRIVATE_KEY: XXXXXXX=\n  FIREBASE_CLIENT_EMAIL: XXXXXXX=\n  AWS_ACCESS_KEY_ID: XXXXXXX=\n  AWS_SECRET_ACCESS_KEY: XXXXXXX=\n  SENTRY_DSN: XXXXXXX=\n  FLOWER_ADMIN_STRING: XXXXXXX\n  IMAGES_BUCKET: XXXXXXX\n  IMAGES_TEMP_BUCKET: XXXXXXXXX\n  MODELS_BUCKET: XXXXXXX\n```\n\nwhere:\n\n* `apiVersion`: This field specifies the version of the Kubernetes API that the secret is compatible with. In this case,\n  the secret is compatible with Kubernetes API version 1.\n* `kind`: This field specifies the type of object that the manifest represents. In this case, the manifest represents a\n  secret object.\n* `metadata`: This field contains information about the secret, such as its name and labels. The name field is required\n  and must be unique within the namespace where the secret is created.\n* `type`: This field specifies the type of secret. In this case, the secret is an Opaque secret. Opaque secrets are used\n  to store sensitive data that should be encrypted at rest.\n* `data`: This field contains the secret data. The data is stored as a map of key-value pairs. The keys must be unique\n  and the values can be any type of data.\n  The following are the secrets that are stored in the morpheus-secret:\n\n* `POSTGRES_USER`: The username for the PostgreSQL database.\n* `POSTGRES_DB`: The name of the PostgreSQL database.\n* `POSTGRES_PASSWORD`: The password for the PostgreSQL database.\n* `POSTGRES_HOST`: The hostname or IP address of the PostgreSQL database server.\n* `FIREBASE_PROJECT_ID`: The ID of the Firebase project.\n* `FIREBASE_PRIVATE_KEY`: The private key for the Firebase project.\n* `FIREBASE_CLIENT_EMAIL`: The client email address for the Firebase project.\n* `AWS_ACCESS_KEY_ID`: The AWS access key ID.\n* `AWS_SECRET_ACCESS_KEY`: The AWS secret access key.\n* `SENTRY_DSN`: The Sentry DSN.\n* `FLOWER_ADMIN_STRING`: The Flower admin string.\n* `IMAGES_BUCKET`: The name of the S3 bucket where the Morpheus images are stored.\n* `IMAGES_TEMP_BUCKET`: The name of the S3 bucket where the Morpheus temporary images are stored.\n* `MODELS_BUCKET`: The name of the S3 bucket where the Morpheus models are stored.\n\nApply secrets:\n\n```\nkubectl apply -f morpheus-secrets.yaml\n```\n\nTo enable the pulling and pushing of images to your registry, create a secret called regcred for Docker credentials.\n\n```bash\n# https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\nkubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username=dockeruser --docker-password=xxxxxxxxxxxxxxxxx --docker-email=xxxxxxxxxxxxxxxxxxx\n```\n\n### Install nvidia plugin for k8s\n\nApply the nvidia plugin.\n\n```bash\nkubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v0.13.0/nvidia-device-plugin.yml\n```\n\n# CI/CD configuration\n\nThe platform currently uses GitHub Actions for deployment. To integrate this with your custom project, you should set\nthe following secrets in GitHub:\n\nAWS access variables:\n\n- `AWS_ACCESS_KEY_ID`: Your AWS access key ID.\n- `AWS_SECRET_ACCESS_KEY`: Your AWS secret access key.\n- `AWS_CLUSTER_NAME`: The name of your EKS cluster.\n- `AWS_REGION`: The AWS region where your EKS cluster is located.\n\nCloudflare tokens to clear the cache:\n\n- `CLOUDFLARE_API_TOKEN`:Your Cloudflare API token.\n- `CLOUDFLARE_ZONE_ID`:The ID of your Cloudflare zone.\n\nDockerhub tokens to push and pull images in the deploy process:\n\n- `DOCKER_HUB_TOKEN`:Your Dockerhub token.\n- `DOCKER_HUB_USER`:Your Dockerhub username.\n\nFirebase configuration:\n\n- `FIREBASE_CLIENT_EMAIL`:Your Firebase client email address.\n- `FIREBASE_PRIVATE_KEY`:Your Firebase private key.\n- `FIREBASE_PROJECT_ID`:Your Firebase project ID.\n\nOther infra configuration:\n\n- FRONTEND_DOMAIN: Platform domain (Eg. morpheus.com)\n\nSentry configuration:\n\n- `SENTRY_AUTH_TOKEN`:Your Sentry authentication token.\n- `SENTRY_ENV`: The Sentry environment name.\n- `SENTRY_ORG`:The Sentry organization name.\n- `SENTRY_PROJECT`:The Sentry project name.\n- `SENTRY_URL`:The Sentry URL.\n\nMonorepo configuration:\n\n- CICD_REPO_PATH: Repo path in the GitHub actions runner. Usually the repo name. E.g.\n  /home/runner/work/Morpheus/Morpheus\n\n# How to collaborate\n\n### Forking the Repository\n\n* Go to the Morpheus's GitHub repository.\n* Click on the \"Fork\" button in the top-right corner of the repository page.\n* This will create a copy of the repository under your GitHub account.\n\n### Cloning the Forked Repository\n\n* On your GitHub account, navigate to the forked repository.\n* Click on the \"Code\" button and copy the repository URL.\n* Clone the repository locally\n\n### Adding an Upstream Remote\n\nChange to the repository directory using cd.\n\n```\ngit remote add upstream https://github.com/Monadical-SAS/Morpheus.git\n```\n\n### Creating a New Branch for your changes\n\n### Create a Pull request\n\n* Go to the original project's GitHub repository.\n* Create a new PR selecting your forked repository and the branch containing your changes.\n\n### Updating Your Fork with Upstream Changes:\n\n* Fetch the upstream repository changes using the git fetch command.\n\n```\ngit fetch upstream\n```\n\n* Switch to your local main branch using git checkout main and merge the upstream changes into your local main branch\n  using git merge.\n\n```\ngit merge upstream/main\n```\n\n* Push the updated changes to your forked repository on GitHub using git push.\n\n```\ngit push origin main\n```\n\n### Commit style\n\nTo enhance collaboration, we have adopted the conventional commit specification to facilitate the creation of an \"\nexplicit commit history.\" This practice not only assists in achieving a clearer understanding of changes made but also\nstreamlines the release process for Morpheus versions.\n\nSome examples:\n\n* feat: Implement user authentication feature\n* fix: Resolve issue with data not saving correctly\n* chore: Update dependencies to latest versions\n* docs: Add documentation for API endpoints\n* refactor: Simplify code structure for improved readability\n* test: Add unit tests for new validation logic\n* style: Format code according to style guidelines\n* perf: Optimize database queries for faster performance\n\nFor additional information see: [conventional commits](https://www.conventionalcommits.org/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonadical-sas%2Fmorpheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonadical-sas%2Fmorpheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonadical-sas%2Fmorpheus/lists"}