In this tutorial you will learn how to deploy an application hosted in a git repository with a launcher application from the catalog. This method is a variation of the Deploy from catalog functionality.
The Playground catalog offers a set of launcher applications that contain predefined application stacks according to the target language that allow you to automatically launch an application from a git repository.
At the top level, the launching an application in this way involves:
- Cloning the git repository
- Building the code
- Running the application
Notice that this method does not generate any container image, so while it may require a little more time to boot up, it is a good method to iterate and test applications directly from the repository without the need to publish a container image in a registry.
Each launcher type has a predefined workflow in which the steps to follow when deploying an application are specified. These workflows contain default instructions to build and run applications in Python, Golang and NodeJS, and instructions to server static web content. When the launcher clones the target repository it will try locating a
workflow.yaml file with the custom workflow. If none is present the default workflow will be used. Check how to customize your workflow if you need to add or remove steps.
For the purpose of the tutorial, let’s deploy an example python application available at https://github.com/Carmendelope/python-launcher-example that it is loosely based on the tokenizers tutorial.
The default python workflow will install the requirements in the
build step, and run the program in the
exec, but in this case the program requires to download the required data to be processed before launching the application. To accomplish that, a custom workflow has been defined in which the steps to install other dependencies and download data are included. Those steps will be merged with the default python workflow before proceeding.
To deploy the application with the launcher, Open the catalog by clicking and locate the deploy-python-app application. Select the latest version and click the button. Then, copy the following parameters to launch the application.
components: - name: deploy-python-comp type: webservice properties: image: napptive/playground-launcher-python:3.10-v1.0.0 cpu: "500m" memory: 1024Mi # (Optional) if the application exposes a port # If you need to expose your application to Internet, use napptive-ingress trait # https://docs.napptive.com/oam_definitions/traits/napptive-ingress.html ports: - port: 5000 expose: true env: # GitHub repo url - name: LAUNCHER_TARGET_REPO value: https://github.com/Carmendelope/python-launcher-example.git - name: LAUNCHER_MAIN_FILE_PATH value: "main.py" - name: LAUNCHER_EXEC_ARGS value: "" # (Optional) required if the GitHub repository is private # GitHub username # If you prefer to keep it a secret, use a storage trait # https://docs.napptive.com/oam_definitions/traits/storage.html - name: LAUNCHER_REPOSITORY_USER value: "" # (Optional) required if the GitHub repository is private # GitHub PAT # If you prefer to keep it a secret, use a storage trait # https://docs.napptive.com/oam_definitions/traits/storage.html - name: LAUNCHER_REPOSITORY_ACCESS_TOKEN value: "" traits: # Trait section - type: napptive-ingress properties: port: 5000 path: /
When the application is running, open the endpoint and check the message
Before processing value. The message changes to indicate the application status. After a few minutes (whatever it takes to run the program) the text of the endpoint should change to
Post processing value.
Access the application logs to check the running steps.
If you need to deploy an application from a private git repository, make sure to fill the following variables in the parameters
LAUNCHER_REPOSITORY_USERthe user cloning the repository.
LAUNCHER_REPOSITORY_ACCESS_TOKENwith your GitHub user and Access token respectively