Skip to content

Commit

Permalink
Make devcontainer work in codespace (#251)
Browse files Browse the repository at this point in the history
* WIP

* WIP: Enable 'Recommended secrets' in the dev container

* WIP: Polishing

* WIP

* Set default value for container prefix env variable

* WIP

* WIP

* WIP

* Add prefix to container names

* Make python 3.10 version of dev container as default

* Fix env file path

* Fix NATS server config path

* Fix the workspace path

* WIP: Update contributing guide

* WIP

* WIP

* WIP

* Update contributing guide

* Update contributing guide

* Fix test which hangs in codespace

* Update contributing guide

* Update python 3.9 devcontainer configuration

* Update docs

* Update docs and configuration files

* Update configuration files

* Update configuration file

* Polishing

---------

Co-authored-by: Kumaran Rajendhiran <[email protected]>
  • Loading branch information
harishmohanraj and kumaranvpl authored Sep 20, 2024
1 parent 3eb2572 commit ecdcf12
Show file tree
Hide file tree
Showing 13 changed files with 513 additions and 200 deletions.
97 changes: 97 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"name": "python-3.10",
// "image": "mcr.microsoft.com/devcontainers/python:3.10",
"dockerComposeFile": [
"./docker-compose.yml"
],
"service": "python-3.10-fastagency",
"forwardPorts": [
"fastagency-${containerEnv:CONTAINER_PREFIX}-nats-py310:9222"
],
"secrets": {
"OPENAI_API_KEY": {
"description": "This key is optional and only needed if you are working on OpenAI-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
},
"TOGETHER_API_KEY": {
"description": "This key is optional and only needed if you are working with Together API-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
},
"ANTHROPIC_API_KEY": {
"description": "This key is optional and only needed if you are working with Anthropic API-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
},
"AZURE_OPENAI_API_KEY": {
"description": "This key is optional and only needed if you are using Azure's OpenAI services. For it to work, you must also set the related environment variables: AZURE_API_ENDPOINT, AZURE_API_VERSION, and at least one of AZURE_GPT35_MODEL, AZURE_GPT4_MODEL, or AZURE_GPT4o_MODEL. Leave it blank if not required. You can always set these variables later in the codespace terminal."
},
"AZURE_API_ENDPOINT": {
"description": "This key is required if you are using Azure's OpenAI services. It must be used in conjunction with AZURE_OPENAI_API_KEY, AZURE_API_VERSION, and at least one of AZURE_GPT35_MODEL, AZURE_GPT4_MODEL, or AZURE_GPT4o_MODEL to ensure proper configuration. You can always set these variables later as environment variables in the codespace terminal."
},
"AZURE_API_VERSION": {
"description": "This key is required to specify the version of the Azure API you are using. Set this along with AZURE_OPENAI_API_KEY, AZURE_API_ENDPOINT, and at least one of AZURE_GPT35_MODEL, AZURE_GPT4_MODEL, or AZURE_GPT4o_MODEL for Azure OpenAI services. These variables can be configured later as environment variables in the codespace terminal."
},
"AZURE_GPT35_MODEL": {
"description": "This key is required if you are using Azure's GPT-3.5 model. Ensure you also set AZURE_OPENAI_API_KEY, AZURE_API_ENDPOINT, AZURE_GPT4_MODEL, AZURE_GPT4o_MODEL, and AZURE_API_VERSION for full compatibility with Azure OpenAI services. These can be configured later in the codespace terminal as environment variables."
},
"AZURE_GPT4_MODEL": {
"description": "This key is required if you are using Azure's GPT-4 model. It must be set along with AZURE_OPENAI_API_KEY, AZURE_API_ENDPOINT, AZURE_GPT35_MODEL, AZURE_GPT4o_MODEL, and AZURE_API_VERSION to properly integrate with Azure's OpenAI services. All keys can be added later as environment variables in the codespace terminal."
},
"AZURE_GPT4o_MODEL": {
"description": "This key is required if you are using Azure's GPT-4o model. Ensure that AZURE_OPENAI_API_KEY, AZURE_API_ENDPOINT, AZURE_GPT35_MODEL, AZURE_GPT4_MODEL, and AZURE_API_VERSION are also set. You can always add these later as environment variables in the codespace terminal."
},
"BING_API_KEY": {
"description": "This key is optional. The WebSurfer agent can work without it, but when added, it uses Bing's search and data services to improve information retrieval. You can always set it later as an environment variable in the codespace terminal."
}
},
"shutdownAction": "stopCompose",
"workspaceFolder": "/workspaces/fastagency",
// "runArgs": [],
"remoteEnv": {},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"installOhMyZsh": true,
"configureZshAsDefaultShell": true,
"username": "vscode",
"userUid": "1000",
"userGid": "1000"
// "upgradePackages": "true"
},
// "ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers/features/node:1": {},
// The below configuration with "version" set to "latest" fails in codespace
// "ghcr.io/devcontainers/features/git:1": {
// "version": "latest",
// "ppa": true
// },
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/git-lfs:1": {},
"ghcr.io/robbert229/devcontainer-features/postgresql-client:1": {}
},
"updateContentCommand": "bash .devcontainer/setup.sh",
"postCreateCommand": [],
"customizations": {
"vscode": {
"settings": {
"python.linting.enabled": true,
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
},
"[python]": {
"editor.defaultFormatter": "ms-python.vscode-pylance"
},
"editor.rulers": [
80
]
},
"extensions": [
"ms-python.python",
"ms-toolsai.jupyter",
"ms-toolsai.vscode-jupyter-cell-tags",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"ms-toolsai.vscode-jupyter-slideshow",
"ms-python.vscode-pylance"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ version: '3'
services:
python-3.10-fastagency: # nosemgrep
image: mcr.microsoft.com/devcontainers/python:3.10
container_name: $USER-python-3.10-fastagency
container_name: fastagency-${USER}-python-3.10
volumes:
- ../../:/workspaces/fastagency:cached
- ../:/workspaces/fastagency:cached
command: sleep infinity
environment:
- DATABASE_URL=postgresql://admin:password@${USER}-postgres-py310-fastagency:5432/fastagency
- PY_DATABASE_URL=postgresql://admin:password@${USER}-postgres-py310-fastagency:5432/pyfastagency
- NATS_URL=nats://${USER}-nats-py310-fastagency:4222
- DATABASE_URL=postgresql://admin:password@fastagency-${USER}-postgres-py310:5432/fastagency
- PY_DATABASE_URL=postgresql://admin:password@fastagency-${USER}-postgres-py310:5432/pyfastagency
- NATS_URL=nats://fastagency-${USER}-nats-py310:4222
env_file:
- ../devcontainer.env
- ./devcontainer.env
networks:
- fastagency-network
nats-fastagency: # nosemgrep
image: nats:latest
container_name: $USER-nats-py310-fastagency
container_name: fastagency-${USER}-nats-py310
# ports:
# - "${PORT_PREFIX}4222:4222"
# - "${PORT_PREFIX}9222:9222"
volumes:
- ../nats_server.conf:/etc/nats/server.conf
- ./nats_server.conf:/etc/nats/server.conf
command: [ "--config", "/etc/nats/server.conf" ]
env_file:
- ../devcontainer.env
- ./devcontainer.env
networks:
- fastagency-network
postgres-fastagency: # nosemgrep
image: postgres:latest
container_name: $USER-postgres-py310-fastagency
container_name: fastagency-${USER}-postgres-py310
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: password # pragma: allowlist secret
Expand All @@ -42,4 +42,4 @@ services:

networks:
fastagency-network:
name: "${USER}-fastagency-network"
name: fastagency-${USER}-network
63 changes: 0 additions & 63 deletions .devcontainer/python-3.10/devcontainer.json

This file was deleted.

44 changes: 39 additions & 5 deletions .devcontainer/python-3.11/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,40 @@
],
"service": "python-3.11-fastagency",
"forwardPorts": [
"${containerEnv:CONTAINER_PREFIX}-nats-py311-fastagency:9222"
"fastagency-${containerEnv:CONTAINER_PREFIX}-nats-py311:9222"
],
"secrets": {
"OPENAI_API_KEY": {
"description": "This key is optional and only needed if you are working on OpenAI-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
},
"TOGETHER_API_KEY": {
"description": "This key is optional and only needed if you are working with Together API-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
},
"ANTHROPIC_API_KEY": {
"description": "This key is optional and only needed if you are working with Anthropic API-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
},
"AZURE_OPENAI_API_KEY": {
"description": "This key is optional and only needed if you are using Azure's OpenAI services. For it to work, you must also set the related environment variables: AZURE_API_ENDPOINT, AZURE_API_VERSION, and at least one of AZURE_GPT35_MODEL, AZURE_GPT4_MODEL, or AZURE_GPT4o_MODEL. Leave it blank if not required. You can always set these variables later in the codespace terminal."
},
"AZURE_API_ENDPOINT": {
"description": "This key is required if you are using Azure's OpenAI services. It must be used in conjunction with AZURE_OPENAI_API_KEY, AZURE_API_VERSION, and at least one of AZURE_GPT35_MODEL, AZURE_GPT4_MODEL, or AZURE_GPT4o_MODEL to ensure proper configuration. You can always set these variables later as environment variables in the codespace terminal."
},
"AZURE_API_VERSION": {
"description": "This key is required to specify the version of the Azure API you are using. Set this along with AZURE_OPENAI_API_KEY, AZURE_API_ENDPOINT, and at least one of AZURE_GPT35_MODEL, AZURE_GPT4_MODEL, or AZURE_GPT4o_MODEL for Azure OpenAI services. These variables can be configured later as environment variables in the codespace terminal."
},
"AZURE_GPT35_MODEL": {
"description": "This key is required if you are using Azure's GPT-3.5 model. Ensure you also set AZURE_OPENAI_API_KEY, AZURE_API_ENDPOINT, AZURE_GPT4_MODEL, AZURE_GPT4o_MODEL, and AZURE_API_VERSION for full compatibility with Azure OpenAI services. These can be configured later in the codespace terminal as environment variables."
},
"AZURE_GPT4_MODEL": {
"description": "This key is required if you are using Azure's GPT-4 model. It must be set along with AZURE_OPENAI_API_KEY, AZURE_API_ENDPOINT, AZURE_GPT35_MODEL, AZURE_GPT4o_MODEL, and AZURE_API_VERSION to properly integrate with Azure's OpenAI services. All keys can be added later as environment variables in the codespace terminal."
},
"AZURE_GPT4o_MODEL": {
"description": "This key is required if you are using Azure's GPT-4o model. Ensure that AZURE_OPENAI_API_KEY, AZURE_API_ENDPOINT, AZURE_GPT35_MODEL, AZURE_GPT4_MODEL, and AZURE_API_VERSION are also set. You can always add these later as environment variables in the codespace terminal."
},
"BING_API_KEY": {
"description": "This key is optional. The WebSurfer agent can work without it, but when added, it uses Bing's search and data services to improve information retrieval. You can always set it later as an environment variable in the codespace terminal."
}
},
"shutdownAction": "stopCompose",
"workspaceFolder": "/workspaces/fastagency",
// "runArgs": [],
Expand All @@ -23,10 +55,12 @@
},
// "ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/git:1": {
"version": "latest",
"ppa": true
},
// The below configuration with "version" set to "latest" fails in codespace
// "ghcr.io/devcontainers/features/git:1": {
// "version": "latest",
// "ppa": true
// },
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/git-lfs:1": {},
"ghcr.io/robbert229/devcontainer-features/postgresql-client:1": {}
},
Expand Down
14 changes: 7 additions & 7 deletions .devcontainer/python-3.11/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ version: '3'
services:
python-3.11-fastagency: # nosemgrep
image: mcr.microsoft.com/devcontainers/python:3.11
container_name: $USER-python-3.11-fastagency
container_name: fastagency-${USER}-python-3.11
volumes:
- ../../:/workspaces/fastagency:cached
command: sleep infinity
environment:
- DATABASE_URL=postgresql://admin:password@${USER}-postgres-py311-fastagency:5432/fastagency
- PY_DATABASE_URL=postgresql://admin:password@${USER}-postgres-py311-fastagency:5432/pyfastagency
- NATS_URL=nats://${USER}-nats-py311-fastagency:4222
- DATABASE_URL=postgresql://admin:password@fastagency-${USER}-postgres-py311:5432/fastagency
- PY_DATABASE_URL=postgresql://admin:password@fastagency-${USER}-postgres-py311:5432/pyfastagency
- NATS_URL=nats://fastagency-${USER}-nats-py311:4222
env_file:
- ../devcontainer.env
networks:
- fastagency-network
nats-fastagency: # nosemgrep
image: nats:latest
container_name: $USER-nats-py311-fastagency
container_name: fastagency-${USER}-nats-py311
# ports:
# - "${PORT_PREFIX}4222:4222"
# - "${PORT_PREFIX}9222:9222"
Expand All @@ -30,7 +30,7 @@ services:
- fastagency-network
postgres-fastagency: # nosemgrep
image: postgres:latest
container_name: $USER-postgres-py311-fastagency
container_name: fastagency-${USER}-postgres-py311
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: password # pragma: allowlist secret
Expand All @@ -42,4 +42,4 @@ services:

networks:
fastagency-network:
name: "${USER}-fastagency-network"
name: fastagency-${USER}-network
Loading

0 comments on commit ecdcf12

Please sign in to comment.