diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 664cf64d..a86b8b66 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "DocsGPT Dev Container", - "dockerComposeFile": ["../docker-compose-dev.yaml", "docker-compose.override.yaml"], + "dockerComposeFile": ["docker-compose-dev.yaml", "docker-compose.override.yaml"], "service": "dev", "workspaceFolder": "/workspace", "postCreateCommand": ".devcontainer/post-create-command.sh", diff --git a/.devcontainer/docker-compose-dev.yaml b/.devcontainer/docker-compose-dev.yaml new file mode 100644 index 00000000..8a3e75c4 --- /dev/null +++ b/.devcontainer/docker-compose-dev.yaml @@ -0,0 +1,18 @@ +services: + + redis: + image: redis:6-alpine + ports: + - 6379:6379 + + mongo: + image: mongo:6 + ports: + - 27017:27017 + volumes: + - mongodb_data_container:/data/db + + + +volumes: + mongodb_data_container: \ No newline at end of file diff --git a/.devcontainer/docker-compose.override.yaml b/.devcontainer/docker-compose.override.yaml index 11db7289..979bf48f 100644 --- a/.devcontainer/docker-compose.override.yaml +++ b/.devcontainer/docker-compose.override.yaml @@ -4,9 +4,9 @@ services: dev: build: context: . - dockerfile: .devcontainer/Dockerfile + dockerfile: Dockerfile volumes: - - .:/workspace:cached + - ../:/workspace:cached command: sleep infinity depends_on: redis: diff --git a/.devcontainer/post-create-command.sh b/.devcontainer/post-create-command.sh index 93796b49..597b985e 100755 --- a/.devcontainer/post-create-command.sh +++ b/.devcontainer/post-create-command.sh @@ -2,7 +2,25 @@ set -e # Exit immediately if a command exits with a non-zero status -cp -n .env-template .env || true +if [ ! -f frontend/.env.development ]; then + cp -n .env-template frontend/.env.development || true # Assuming .env-template is in the root +fi + +# Determine VITE_API_HOST based on environment +if [ -n "$CODESPACES" ]; then + # Running in Codespaces + CODESPACE_NAME=$(echo "$CODESPACES" | cut -d'-' -f1) # Extract codespace name + PUBLIC_API_HOST="https://${CODESPACE_NAME}-7091.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" + echo "Setting VITE_API_HOST for Codespaces: $PUBLIC_API_HOST in frontend/.env.development" + sed -i "s|VITE_API_HOST=.*|VITE_API_HOST=$PUBLIC_API_HOST|" frontend/.env.development +else + # Not running in Codespaces (local devcontainer) + DEFAULT_API_HOST="http://localhost:7091" + echo "Setting VITE_API_HOST for local dev: $DEFAULT_API_HOST in frontend/.env.development" + sed -i "s|VITE_API_HOST=.*|VITE_API_HOST=$DEFAULT_API_HOST|" frontend/.env.development +fi + + mkdir -p model if [ ! -d model/all-mpnet-base-v2 ]; then wget -q https://d3dg1063dc54p9.cloudfront.net/models/embeddings/mpnet-base-v2.zip -O model/mpnet-base-v2.zip diff --git a/README.md b/README.md index 6795ddd8..0ae8ec99 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ On windows: 3. Run the following command: - ```bash + ```bash docker compose -f deployment/docker-compose.yaml up --build ``` 4. Navigate to http://localhost:5173/. diff --git a/application/Dockerfile b/application/Dockerfile index 27213072..308b721b 100644 --- a/application/Dockerfile +++ b/application/Dockerfile @@ -6,7 +6,6 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ apt-get install -y software-properties-common && \ add-apt-repository ppa:deadsnakes/ppa && \ -# Install necessary packages and Python apt-get update && \ apt-get install -y --no-install-recommends gcc wget unzip libc6-dev python3.12 python3.12-venv && \ rm -rf /var/lib/apt/lists/* @@ -49,7 +48,6 @@ FROM ubuntu:24.04 as final RUN apt-get update && \ apt-get install -y software-properties-common && \ add-apt-repository ppa:deadsnakes/ppa && \ -# Install Python apt-get update && apt-get install -y --no-install-recommends python3.12 && \ ln -s /usr/bin/python3.12 /usr/bin/python && \ rm -rf /var/lib/apt/lists/*