You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Let's create a deployment of the `task_maistro` app that we created in module 5.\n",
12
+
"\n",
13
+
"## Code structure\n",
14
+
"\n",
15
+
"[The following information should be provided](https://langchain-ai.github.io/langgraph/concepts/application_structure/) to create a LangGraph Platform deployment:\n",
16
+
"\n",
17
+
"* A [LangGraph API Configuration file](https://langchain-ai.github.io/langgraph/concepts/application_structure/#configuration-file) - `langgraph.json`\n",
18
+
"* The graphs that implement the logic of the application - e.g., `task_maistro.py`\n",
19
+
"* A file that specifies dependencies required to run the application - `requirements.txt`\n",
20
+
"* Supply environment variables needed for the application to run - `.env` or `docker-compose.yml`\n",
21
+
"\n",
22
+
"We have this already in the `module-6/deployment` directory!\n",
23
+
"\n",
24
+
"## CLI\n",
25
+
"\n",
26
+
"The [LangGraph CLI](https://langchain-ai.github.io/langgraph/concepts/langgraph_cli/) is a command-line interface for creating a LangGraph Platform deployment."
27
+
]
28
+
},
29
+
{
30
+
"cell_type": "code",
31
+
"execution_count": null,
32
+
"metadata": {
33
+
"id": "dt8qCZr_aIzg"
34
+
},
35
+
"outputs": [],
36
+
"source": [
37
+
"%%capture --no-stderr\n",
38
+
"%pip install -U langgraph-cli"
39
+
]
40
+
},
41
+
{
42
+
"cell_type": "markdown",
43
+
"metadata": {
44
+
"id": "nKLJCLY9aIzk"
45
+
},
46
+
"source": [
47
+
"To create a [self-hosted deployment](https://langchain-ai.github.io/langgraph/how-tos/deploy-self-hosted/#how-to-do-a-self-hosted-deployment-of-langgraph), we'll follow a few steps.\n",
48
+
"\n",
49
+
"### Build Docker Image for LangGraph Server\n",
50
+
"\n",
51
+
"We first use the langgraph CLI to create a Docker image for the [LangGraph Server](https://docs.google.com/presentation/d/18MwIaNR2m4Oba6roK_2VQcBE_8Jq_SI7VHTXJdl7raU/edit#slide=id.g313fb160676_0_32).\n",
52
+
"\n",
53
+
"This will package our graph and dependencies into a Docker image.\n",
54
+
"\n",
55
+
"A Docker image is a template for a Docker container that contains the code and dependencies required to run the application.\n",
56
+
"\n",
57
+
"Ensure that [Docker](https://docs.docker.com/engine/install/) is installed and then run the following command to create the Docker image, `my-image`:\n",
58
+
"\n",
59
+
"```\n",
60
+
"$ cd module-6/deployment\n",
61
+
"$ langgraph build -t my-image\n",
62
+
"```\n",
63
+
"\n",
64
+
"### Set Up Redis and PostgreSQL\n",
65
+
"\n",
66
+
"If you already have Redis and PostgreSQL running (e.g., locally or on other servers), then create and run the LangGraph Server container [by itself](https://langchain-ai.github.io/langgraph/how-tos/deploy-self-hosted/#running-the-application-locally) with the URIs for Redis and PostgreSQL:\n",
67
+
"\n",
68
+
"```\n",
69
+
"docker run \\\n",
70
+
" --env-file .env \\\n",
71
+
" -p 8123:8000 \\\n",
72
+
" -e REDIS_URI=\"foo\"\\\n",
73
+
" -e DATABASE_URI=\"bar\"\\\n",
74
+
" -e LANGSMITH_API_KEY=\"baz\"\\\n",
75
+
" my-image\n",
76
+
"```\n",
77
+
"\n",
78
+
"Alternatively, you can use the provided `docker-compose.yml` file to create three separate containers based on the services defined:\n",
79
+
"\n",
80
+
"* `langgraph-redis`: Creates a new container using the official Redis image.\n",
81
+
"* `langgraph-postgres`: Creates a new container using the official Postgres image.\n",
82
+
"* `langgraph-api`: Creates a new container using your pre-built image.\n",
83
+
"\n",
84
+
"Simply copy the `docker-compose-example.yml` and add the following environment variables to run the deployed `task_maistro` app:\n",
85
+
"\n",
86
+
"* `IMAGE_NAME` (e.g., `my-image`)\n",
87
+
"* `LANGCHAIN_API_KEY`\n",
88
+
"* `OPENAI_API_KEY`\n",
89
+
"\n",
90
+
"Then, [launch the deployment](https://langchain-ai.github.io/langgraph/how-tos/deploy-self-hosted/#using-docker-compose):\n",
0 commit comments