diff --git a/samples/javalin/README.md b/samples/javalin/README.md index 3adedde4..fd318678 100644 --- a/samples/javalin/README.md +++ b/samples/javalin/README.md @@ -24,6 +24,16 @@ For development, we use a local container. This can be seen in the compose.yaml docker compose up --build ``` +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Javalin diff --git a/samples/langchain/README.md b/samples/langchain/README.md index 71fed228..18c8a791 100644 --- a/samples/langchain/README.md +++ b/samples/langchain/README.md @@ -27,6 +27,15 @@ docker compose up --build This will start a Docker container with the flask app which will display the result of the langchain prompt. +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` --- Title: LangChain & Flask diff --git a/samples/metabase/README.md b/samples/metabase/README.md index 3f4ba2a7..900cfe8c 100644 --- a/samples/metabase/README.md +++ b/samples/metabase/README.md @@ -25,6 +25,16 @@ Since Metabase is a self contained application, there isn't an actual developmen 3. Type `defang compose up` in the CLI. 4. Your app will be running within a few minutes. +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Metabase & PostgreSQL diff --git a/samples/nextjs-blog/README.md b/samples/nextjs-blog/README.md index 2b15fac9..819cc69a 100644 --- a/samples/nextjs-blog/README.md +++ b/samples/nextjs-blog/README.md @@ -23,6 +23,15 @@ This template is a starter project developed using Next.js designed to make it e 3. Type `defang compose up` in the CLI 4. Now your application will be launched +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` --- Title: Next.js Blog diff --git a/samples/nextjs-documentation/README.md b/samples/nextjs-documentation/README.md index 2c97ffa7..a91d9944 100644 --- a/samples/nextjs-documentation/README.md +++ b/samples/nextjs-documentation/README.md @@ -14,7 +14,9 @@ This template is a documentation starter project developed using Nextra, designe 1. Download [Defang CLI](https://github.com/DefangLabs/defang) 2. If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc), make sure you have properly [authenticated your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) - Plus, make sure that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`. + Plus, make sure that you have properly set your environment variables like + `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`. +3. For any other config values that need to be set, please remember to configure with `defang config set API_KEY` ## A Step-by-Step Guide diff --git a/samples/nextjs-postgres/README.md b/samples/nextjs-postgres/README.md index 2a838a4d..ea544e42 100644 --- a/samples/nextjs-postgres/README.md +++ b/samples/nextjs-postgres/README.md @@ -10,6 +10,16 @@ This is a sample Next.js application that uses Postgres as a database. It is a s 2. (Optional) If you are using [Defang BYOC](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) authenticated with your AWS account 3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/) +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + ## Development To run the application locally, you can use the following command: diff --git a/samples/nextjs/README.md b/samples/nextjs/README.md index 34d7ca3d..d6ec8013 100644 --- a/samples/nextjs/README.md +++ b/samples/nextjs/README.md @@ -11,6 +11,16 @@ A basic Next.js app with a Dockerfile and compose.yaml ready to deploy to AWS wi 3. (optional) [Authenticate with AWS](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) 4. Run `defang compose up` in the root of this project +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Next.js diff --git a/samples/nocodb/README.md b/samples/nocodb/README.md index 81b2608e..26eee9ef 100644 --- a/samples/nocodb/README.md +++ b/samples/nocodb/README.md @@ -53,6 +53,13 @@ For development, we use a local postgres container and a volume mount for file u `docker compose --file compose.dev.yaml up --build` +## Configuration +If you wish to provide more configurations, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: NocoDB diff --git a/samples/nodejs-chatroom/README.md b/samples/nodejs-chatroom/README.md index 6c16c3c6..f021a691 100644 --- a/samples/nodejs-chatroom/README.md +++ b/samples/nodejs-chatroom/README.md @@ -14,6 +14,16 @@ If you have environment variables configured for your [own cloud account](https: ```sh defang compose up +``` + + ## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY ``` --- diff --git a/samples/nodejs-express/README.md b/samples/nodejs-express/README.md index 5a71461c..15745eff 100644 --- a/samples/nodejs-express/README.md +++ b/samples/nodejs-express/README.md @@ -20,6 +20,16 @@ This Node.js application, built with Express.js, is designed to inspect and disp 2. Type `defang compose up` in the CLI 3. Your app should be up and running with Defang in minutes! + ## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Node.js & Express diff --git a/samples/nodejs-form/README.md b/samples/nodejs-form/README.md index baea0c38..a54ad19c 100644 --- a/samples/nodejs-form/README.md +++ b/samples/nodejs-form/README.md @@ -20,6 +20,16 @@ This is a basic Node.js application using the Express framework to demonstrate h 2. Type `defang compose up` in the CLI 3. Your app should be up and running with Defang in minutes! +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Node.js Express Form diff --git a/samples/nodejs-http/README.md b/samples/nodejs-http/README.md index e4070555..cd87655a 100644 --- a/samples/nodejs-http/README.md +++ b/samples/nodejs-http/README.md @@ -16,6 +16,16 @@ If you have environment variables configured for your [own cloud account](https: defang compose up ``` +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Node.js HTTP Server diff --git a/samples/nodejs-openai/README.md b/samples/nodejs-openai/README.md index 549e9e8b..d97cbfaa 100644 --- a/samples/nodejs-openai/README.md +++ b/samples/nodejs-openai/README.md @@ -25,6 +25,13 @@ or ``` cat prompt.txt | curl -H "Content-Type: application/text" -d @- https://xxxxxxxx/prompt ``` +## Configuration + +Please configure the `OPENAI_KEY` with + +```bash +defang config set OPENAI_KEY +``` --- diff --git a/samples/nodejs-react-postgres/README.md b/samples/nodejs-react-postgres/README.md index 59c4b29a..e9833f55 100644 --- a/samples/nodejs-react-postgres/README.md +++ b/samples/nodejs-react-postgres/README.md @@ -30,6 +30,14 @@ Or run without using Docker by doing the following: 4. Type `defang compose up` in the CLI. 5. Your app will be running within a few minutes. +## Configuration + +For any other config values, please use + +```bash +defang config set API_KEY +``` + --- Title: Node.js & React & PostgreSQL diff --git a/samples/nodejs-rest-api/README.md b/samples/nodejs-rest-api/README.md index b72c26d3..0f607806 100644 --- a/samples/nodejs-rest-api/README.md +++ b/samples/nodejs-rest-api/README.md @@ -4,6 +4,16 @@ This is a simple Node.js application that uses Express.js to create a REST API. It has two endpoints: one that returns a status message, and another that fetches and returns average interest rates data from the U.S. Department of the Treasury's Fiscal Data API. +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Node.js & REST API diff --git a/samples/nodejs-s3/README.md b/samples/nodejs-s3/README.md index be222b7f..f874842b 100644 --- a/samples/nodejs-s3/README.md +++ b/samples/nodejs-s3/README.md @@ -14,6 +14,14 @@ defang config set --name AWS_SECRET_KEY and then enter the value when prompted. +## Configuration + +If you wish to provide more configuration values, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + ## Testing curl -X POST -H 'Content-Type: application/json' -d '{ "first_name" : "jane", "last_name" : "doe" }' https://xxxxxx/upload diff --git a/samples/ollama/README.md b/samples/ollama/README.md index 99c03ea9..c0bfed91 100644 --- a/samples/ollama/README.md +++ b/samples/ollama/README.md @@ -36,6 +36,16 @@ If you want to deploy to your own cloud account, you can use Defang BYOC: 1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`. 2. Run `defang up` in a terminal that has access to your AWS environment variables. +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Ollama diff --git a/samples/phoenix-postgres/README.md b/samples/phoenix-postgres/README.md index 8b45aed7..46a9b4f0 100644 --- a/samples/phoenix-postgres/README.md +++ b/samples/phoenix-postgres/README.md @@ -33,6 +33,13 @@ docker compose -f compose.yaml -f compose.dev.yaml exec phoenix bash 3. Type `defang compose up` in the CLI. 4. Your app will be running within a few minutes. +## Configuration +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Phoenix & PostgreSQL diff --git a/samples/python-form/README.md b/samples/python-form/README.md index 1e620cc8..b079756b 100644 --- a/samples/python-form/README.md +++ b/samples/python-form/README.md @@ -19,7 +19,16 @@ This Flask application provides a basic example of handling form submissions. It 1. Open the terminal and type `defang login` 2. Type `defang compose up` in the CLI 3. Your app should be up and running with Defang in minutes! + +## Configuration +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` --- Title: Python & Form diff --git a/samples/python-implicit-gpu/README.md b/samples/python-implicit-gpu/README.md index 8b37d060..69f27816 100644 --- a/samples/python-implicit-gpu/README.md +++ b/samples/python-implicit-gpu/README.md @@ -19,7 +19,16 @@ This Music Recommendation API provides artist recommendations based on collabora 1. Open the terminal and type `defang login` 2. Type `defang compose up` in the CLI 3. Your app should be up and running with Defang in minutes! + +## Configuration +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` --- Title: Python & Implicit & GPU diff --git a/samples/python-minimal/README.md b/samples/python-minimal/README.md index cbf7f340..7edd2fbb 100644 --- a/samples/python-minimal/README.md +++ b/samples/python-minimal/README.md @@ -24,6 +24,16 @@ This Flask application is designed to inspect and return detailed information ab 1. Open the terminal and type `defang login` 2. Type `defang compose up` in the CLI 3. Your app should be up and running with Defang in minutes! + +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` --- diff --git a/samples/python-openai/README.md b/samples/python-openai/README.md index 69b5ddee..828f73d1 100644 --- a/samples/python-openai/README.md +++ b/samples/python-openai/README.md @@ -24,6 +24,13 @@ or cat prompt.txt | curl -H "Content-Type: application/text" -d @- https://xxxxxxxx/prompt ``` +## Configuration +If you wish to provide more config values, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Python & Flask & OpenAI diff --git a/samples/python-rest-api/README.md b/samples/python-rest-api/README.md index 5d751696..37de44b0 100644 --- a/samples/python-rest-api/README.md +++ b/samples/python-rest-api/README.md @@ -25,6 +25,15 @@ Endpoint to fetch average interest rates from the Fiscal Data Treasury API. 2. Type `defang compose up` in the CLI 3. Your app should be up and running with Defang in minutes! +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` --- Title: Python & REST API diff --git a/samples/python-s3/README.md b/samples/python-s3/README.md index e61b014a..98ae34c9 100644 --- a/samples/python-s3/README.md +++ b/samples/python-s3/README.md @@ -17,6 +17,13 @@ and then enter the value when prompted. curl -X POST -H 'Content-Type: application/json' -d '{ "first_name" : "jane", "last_name" : "doe" }' https://xxxxxx/upload curl https://xxxxxx/download +## Configuration +If you wish to provide more configuration values, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Python & Flask & AWS S3 diff --git a/samples/rails/README.md b/samples/rails/README.md index ab70bb58..01d0300c 100644 --- a/samples/rails/README.md +++ b/samples/rails/README.md @@ -24,6 +24,11 @@ For this sample, you will need to provide the following [configuration](https:// ### `POSTGRES_PASSWORD` This password will be used to initialize the PostgreSQL database and to connect to it. +If you wish to provide more configuration values, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` ## Deployment diff --git a/samples/react/README.md b/samples/react/README.md index 150d02e3..2e8a0d11 100644 --- a/samples/react/README.md +++ b/samples/react/README.md @@ -47,6 +47,16 @@ If you want to deploy to your own cloud account, you can use Defang BYOC: defang --provider=aws compose up ``` +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: React diff --git a/samples/rocket/README.md b/samples/rocket/README.md index 21d998c5..576c6687 100644 --- a/samples/rocket/README.md +++ b/samples/rocket/README.md @@ -34,6 +34,16 @@ If you want to deploy to your own cloud account, you can use Defang BYOC: 1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and check that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`. 2. Run `defang --provider=aws up` in a terminal that has access to your AWS environment variables. +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Rocket diff --git a/samples/sailsjs-postgres/README.md b/samples/sailsjs-postgres/README.md index 5498e3ff..4a195f58 100644 --- a/samples/sailsjs-postgres/README.md +++ b/samples/sailsjs-postgres/README.md @@ -30,6 +30,14 @@ To start the development environment, run: docker compose -f compose.dev.yaml up --build ``` +## Configuration + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Sails.js & PostgreSQL diff --git a/samples/sailsjs/README.md b/samples/sailsjs/README.md index 6f47ff70..527f6fbc 100644 --- a/samples/sailsjs/README.md +++ b/samples/sailsjs/README.md @@ -22,6 +22,16 @@ For development, we use a local container. This can be seen in the compose.yaml 1. docker compose -f compose.dev.yaml up --build +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Sails.js diff --git a/samples/script.py b/samples/script.py new file mode 100644 index 00000000..5eb3730f --- /dev/null +++ b/samples/script.py @@ -0,0 +1,37 @@ +import os +import yaml +import logging + +# Configure logging +logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def find_environment_variables(directory): + env_vars = {} + for root, _, files in os.walk(directory): + for file in sorted(files): + if file.endswith('.yaml') or file.endswith('.yml'): + file_path = os.path.join(root, file) + logging.info(f"Processing file: {file_path}") + with open(file_path, 'r') as stream: + try: + data = yaml.safe_load(stream) + # Check if 'services' key exists + if data and 'services' in data: + for service, config in sorted(data['services'].items()): + # Check if 'environment' exists for each service + if 'environment' in config: + env_vars[file_path] = env_vars.get(file_path, {}) + env_vars[file_path][service] = config['environment'] + except yaml.YAMLError as exc: + logging.error(f"Error parsing {file_path}: {exc}") + return env_vars + +if __name__ == "__main__": + directory = './' + env_vars = find_environment_variables(directory) + for file_path, services in env_vars.items(): + print(f"File: {file_path}") + for service, env in services.items(): + print(f" Service: {service}") + print(f" Environment Variables: {env}") + print() diff --git a/samples/svelte-mysql/README.md b/samples/svelte-mysql/README.md index 02a1aeba..cd9b45e7 100644 --- a/samples/svelte-mysql/README.md +++ b/samples/svelte-mysql/README.md @@ -39,6 +39,16 @@ If you want to edit the database, such that you can deploy them to production, y 2. Type `defang compose up` in the CLI. 3. Your app will be running within a few minutes. +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Svelte & Node.js & MySQL diff --git a/samples/sveltekit-mongodb/README.md b/samples/sveltekit-mongodb/README.md index 64fa98be..aa9ce7c2 100644 --- a/samples/sveltekit-mongodb/README.md +++ b/samples/sveltekit-mongodb/README.md @@ -4,6 +4,16 @@ This is a project that demonstrate both client side component rendering and hydration as well as serverside rendering with external API route configuration. Furthermore, there is also a mongodb connection (not hosted on the atlas) to cache the queried results. +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + ## NOTE This sample showcases how you could deploy a full-stack application with Defang and Sveltekit. However, it deploys mongodb as a defang service. Defang [services](https://12factor.net/processes) are ephemeral and should not be used to run stateful workloads in production as they will be reset on every deployment. For production use cases you should use a managed database like RDS, Aiven, or others. In the future, Defang will help you provision and connect to managed databases. diff --git a/samples/sveltekit/README.md b/samples/sveltekit/README.md index 9e9194c2..42268fbe 100644 --- a/samples/sveltekit/README.md +++ b/samples/sveltekit/README.md @@ -21,6 +21,16 @@ To develop this app, you can run the sveltekit commands as you normally would on 2. Type `defang compose up` in the CLI. 3. Your app will be running within a few minutes. +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: SvelteKit diff --git a/samples/vllm/README.md b/samples/vllm/README.md index 38702639..3f5f69ba 100644 --- a/samples/vllm/README.md +++ b/samples/vllm/README.md @@ -41,6 +41,12 @@ This guide demonstrates how to deploy Mistral using vLLM. You'll need a Hugging By following these steps, you should be able to deploy Mistral along with a custom UI on AWS, using GPU capabilities for enhanced performance. +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Mistral & vLLM diff --git a/samples/vuejs/README.md b/samples/vuejs/README.md index 9601f0a3..d91f075e 100644 --- a/samples/vuejs/README.md +++ b/samples/vuejs/README.md @@ -45,6 +45,17 @@ If you want to deploy to your own cloud account, you can use Defang BYOC: ```bash defang --provider=aws compose up ``` + +## Configuration + +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). + +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. + +```bash +defang config set API_KEY +``` + --- Title: Vue.js