From 527775518e4651cef6d9ca32ff0c17bf18effb77 Mon Sep 17 00:00:00 2001 From: Davor Runje Date: Tue, 12 Nov 2024 10:35:01 +0000 Subject: [PATCH] wip --- .github/workflows/test-playwright.yaml | 5 +++-- .../fastapi/my_fastagency_app/.dockerignore | 0 .../fastapi/my_fastagency_app/docker/Dockerfile | 11 +++++++++-- .../docker/content/nginx.conf.template | 1 - .../docker/content/run_fastagency.sh | 1 + .../fastapi/my_fastagency_app/pyproject.toml | 1 - .../fastapi/my_fastagency_app/scripts/build_docker.sh | 4 +++- .../my_fastagency_app/scripts/deploy_to_fly_io.sh | 3 +++ .../mesop/my_fastagency_app/.dockerignore | 0 .../mesop/my_fastagency_app/docker/Dockerfile | 11 +++++++++-- .../docker/content/nginx.conf.template | 1 - .../docker/content/run_fastagency.sh | 1 + .../mesop/my_fastagency_app/pyproject.toml | 1 - .../mesop/my_fastagency_app/scripts/build_docker.sh | 4 +++- .../my_fastagency_app/scripts/deploy_to_fly_io.sh | 3 +++ .../nats_n_fastapi/my_fastagency_app/.dockerignore | 0 .../my_fastagency_app/docker/Dockerfile | 11 +++++++++-- .../docker/content/nginx.conf.template | 1 - .../docker/content/run_fastagency.sh | 1 + .../nats_n_fastapi/my_fastagency_app/pyproject.toml | 1 - .../my_fastagency_app/scripts/build_docker.sh | 4 +++- .../my_fastagency_app/scripts/deploy_to_fly_io.sh | 3 +++ 22 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 docs/docs_src/getting_started/fastapi/my_fastagency_app/.dockerignore create mode 100644 docs/docs_src/getting_started/mesop/my_fastagency_app/.dockerignore create mode 100644 docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/.dockerignore diff --git a/.github/workflows/test-playwright.yaml b/.github/workflows/test-playwright.yaml index ea0c55971..a99170da6 100644 --- a/.github/workflows/test-playwright.yaml +++ b/.github/workflows/test-playwright.yaml @@ -104,13 +104,14 @@ jobs: id: fastagency-start run: | # Start fastagency and grab its pid + export COVERAGE_PROCESS_START nohup fastagency run e2e/llm-sans/main.py >nohup.txt 2>nohup-error.txt & # Get the process ID (PID) FAST_PID=$! echo "Started fastagency with PID: $FAST_PID" echo "FAST_PID=$FAST_PID" >> $GITHUB_OUTPUT - echo "Sleeping for 15 seconds to let fastagency start up..." - sleep 15 + echo "Sleeping for 5 seconds to let fastagency start up..." + sleep 5 env: COVERAGE_PROCESS_START: "e2e/playwright.coverage.cfg" - run: echo "obtained FAST_PID" ${{ steps.fastagency-start.outputs.FAST_PID}} diff --git a/docs/docs_src/getting_started/fastapi/my_fastagency_app/.dockerignore b/docs/docs_src/getting_started/fastapi/my_fastagency_app/.dockerignore new file mode 100644 index 000000000..e69de29bb diff --git a/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/Dockerfile b/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/Dockerfile index d2c2ef955..a2a3e74ff 100644 --- a/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/Dockerfile +++ b/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/Dockerfile @@ -18,11 +18,18 @@ RUN pip install --upgrade pip && pip install --no-cache-dir -e "." RUN adduser --disabled-password --gecos '' appuser \ && chown -R appuser /app \ && chown -R appuser:appuser /etc/nginx/conf.d /var/log/nginx /var/lib/nginx \ - && touch /run/nginx.pid && chown -R appuser:appuser /run/nginx.pid + && touch /run/nginx.pid && chown -R appuser:appuser /run/nginx.pid \ + # Allow binding to ports > 1024 without root + && sed -i 's/listen 80/listen 9999/g' /etc/nginx/sites-available/default \ + && sed -i 's/listen \[::\]:80/listen \[::\]:9999/g' /etc/nginx/sites-available/default \ + # Create required directories with correct permissions + && mkdir -p /var/cache/nginx /var/run \ + && chown -R appuser:appuser /var/cache/nginx /var/run USER appuser -EXPOSE 8000 8008 8888 +# ToDo: Fix exposing ports +# EXPOSE 8000 8008 8888 CMD ["/app/run_fastagency.sh"] diff --git a/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/content/nginx.conf.template b/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/content/nginx.conf.template index 7279f13c2..c55a5bc4b 100644 --- a/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/content/nginx.conf.template +++ b/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/content/nginx.conf.template @@ -19,7 +19,6 @@ server { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; proxy_buffering off; diff --git a/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/content/run_fastagency.sh b/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/content/run_fastagency.sh index 3fc2acf46..bbce57e36 100755 --- a/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/content/run_fastagency.sh +++ b/docs/docs_src/getting_started/fastapi/my_fastagency_app/docker/content/run_fastagency.sh @@ -18,6 +18,7 @@ do sed -i "5i\ server 127.0.0.1:$PORT;" nginx.conf.template done envsubst '${MESOP_PORT}' < nginx.conf.template >/etc/nginx/conf.d/default.conf +echo "Nginx config:" cat /etc/nginx/conf.d/default.conf # Start nginx diff --git a/docs/docs_src/getting_started/fastapi/my_fastagency_app/pyproject.toml b/docs/docs_src/getting_started/fastapi/my_fastagency_app/pyproject.toml index 661155473..f08787cc3 100644 --- a/docs/docs_src/getting_started/fastapi/my_fastagency_app/pyproject.toml +++ b/docs/docs_src/getting_started/fastapi/my_fastagency_app/pyproject.toml @@ -9,7 +9,6 @@ name = "my_fastagency_app" dependencies = [ "fastagency[autogen,mesop,server,fastapi]>=0.3.0", - ] [project.optional-dependencies] diff --git a/docs/docs_src/getting_started/fastapi/my_fastagency_app/scripts/build_docker.sh b/docs/docs_src/getting_started/fastapi/my_fastagency_app/scripts/build_docker.sh index fc83d0ceb..47a834bc1 100755 --- a/docs/docs_src/getting_started/fastapi/my_fastagency_app/scripts/build_docker.sh +++ b/docs/docs_src/getting_started/fastapi/my_fastagency_app/scripts/build_docker.sh @@ -1,3 +1,5 @@ #!/bin/bash -docker build -t deploy_fastagency -f docker/Dockerfile --progress plain . +echo -e "\033[0;32mBuilding fastagency docker image\033[0m" +docker build -t deploy_fastagency -f docker/Dockerfile --progress plain . && \ +echo -e "\033[0;32mSuccessfully built fastagency docker image\033[0m" diff --git a/docs/docs_src/getting_started/fastapi/my_fastagency_app/scripts/deploy_to_fly_io.sh b/docs/docs_src/getting_started/fastapi/my_fastagency_app/scripts/deploy_to_fly_io.sh index 3d557d1c9..46e58ff50 100755 --- a/docs/docs_src/getting_started/fastapi/my_fastagency_app/scripts/deploy_to_fly_io.sh +++ b/docs/docs_src/getting_started/fastapi/my_fastagency_app/scripts/deploy_to_fly_io.sh @@ -1,7 +1,10 @@ #!/bin/bash +echo -e "\033[0;32mLogging into fly.io\033[0m" fly auth login +echo -e "\033[0;32mDeploying to fly.io\033[0m" fly launch --config fly.toml --copy-config --yes +echo -e "\033[0;32mSetting secrets\033[0m" fly secrets set OPENAI_API_KEY=$OPENAI_API_KEY diff --git a/docs/docs_src/getting_started/mesop/my_fastagency_app/.dockerignore b/docs/docs_src/getting_started/mesop/my_fastagency_app/.dockerignore new file mode 100644 index 000000000..e69de29bb diff --git a/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/Dockerfile b/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/Dockerfile index edce91fe5..6c48bf490 100644 --- a/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/Dockerfile +++ b/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/Dockerfile @@ -18,11 +18,18 @@ RUN pip install --upgrade pip && pip install --no-cache-dir -e "." RUN adduser --disabled-password --gecos '' appuser \ && chown -R appuser /app \ && chown -R appuser:appuser /etc/nginx/conf.d /var/log/nginx /var/lib/nginx \ - && touch /run/nginx.pid && chown -R appuser:appuser /run/nginx.pid + && touch /run/nginx.pid && chown -R appuser:appuser /run/nginx.pid \ + # Allow binding to ports > 1024 without root + && sed -i 's/listen 80/listen 9999/g' /etc/nginx/sites-available/default \ + && sed -i 's/listen \[::\]:80/listen \[::\]:9999/g' /etc/nginx/sites-available/default \ + # Create required directories with correct permissions + && mkdir -p /var/cache/nginx /var/run \ + && chown -R appuser:appuser /var/cache/nginx /var/run USER appuser -EXPOSE 8000 8008 8888 +# ToDo: Fix exposing ports +# EXPOSE 8000 8008 8888 CMD ["/app/run_fastagency.sh"] diff --git a/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/content/nginx.conf.template b/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/content/nginx.conf.template index 7279f13c2..c55a5bc4b 100644 --- a/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/content/nginx.conf.template +++ b/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/content/nginx.conf.template @@ -19,7 +19,6 @@ server { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; proxy_buffering off; diff --git a/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/content/run_fastagency.sh b/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/content/run_fastagency.sh index 292fc846e..017610491 100755 --- a/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/content/run_fastagency.sh +++ b/docs/docs_src/getting_started/mesop/my_fastagency_app/docker/content/run_fastagency.sh @@ -16,6 +16,7 @@ do sed -i "5i\ server 127.0.0.1:$PORT;" nginx.conf.template done envsubst '${MESOP_PORT}' < nginx.conf.template >/etc/nginx/conf.d/default.conf +echo "Nginx config:" cat /etc/nginx/conf.d/default.conf # Start nginx diff --git a/docs/docs_src/getting_started/mesop/my_fastagency_app/pyproject.toml b/docs/docs_src/getting_started/mesop/my_fastagency_app/pyproject.toml index f80f72a87..b273485d8 100644 --- a/docs/docs_src/getting_started/mesop/my_fastagency_app/pyproject.toml +++ b/docs/docs_src/getting_started/mesop/my_fastagency_app/pyproject.toml @@ -9,7 +9,6 @@ name = "my_fastagency_app" dependencies = [ "fastagency[autogen,mesop,server]>=0.3.0", - ] [project.optional-dependencies] diff --git a/docs/docs_src/getting_started/mesop/my_fastagency_app/scripts/build_docker.sh b/docs/docs_src/getting_started/mesop/my_fastagency_app/scripts/build_docker.sh index fc83d0ceb..47a834bc1 100755 --- a/docs/docs_src/getting_started/mesop/my_fastagency_app/scripts/build_docker.sh +++ b/docs/docs_src/getting_started/mesop/my_fastagency_app/scripts/build_docker.sh @@ -1,3 +1,5 @@ #!/bin/bash -docker build -t deploy_fastagency -f docker/Dockerfile --progress plain . +echo -e "\033[0;32mBuilding fastagency docker image\033[0m" +docker build -t deploy_fastagency -f docker/Dockerfile --progress plain . && \ +echo -e "\033[0;32mSuccessfully built fastagency docker image\033[0m" diff --git a/docs/docs_src/getting_started/mesop/my_fastagency_app/scripts/deploy_to_fly_io.sh b/docs/docs_src/getting_started/mesop/my_fastagency_app/scripts/deploy_to_fly_io.sh index 3d557d1c9..46e58ff50 100755 --- a/docs/docs_src/getting_started/mesop/my_fastagency_app/scripts/deploy_to_fly_io.sh +++ b/docs/docs_src/getting_started/mesop/my_fastagency_app/scripts/deploy_to_fly_io.sh @@ -1,7 +1,10 @@ #!/bin/bash +echo -e "\033[0;32mLogging into fly.io\033[0m" fly auth login +echo -e "\033[0;32mDeploying to fly.io\033[0m" fly launch --config fly.toml --copy-config --yes +echo -e "\033[0;32mSetting secrets\033[0m" fly secrets set OPENAI_API_KEY=$OPENAI_API_KEY diff --git a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/.dockerignore b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/.dockerignore new file mode 100644 index 000000000..e69de29bb diff --git a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/Dockerfile b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/Dockerfile index 068e4c1e9..f2fa97bcb 100644 --- a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/Dockerfile +++ b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/Dockerfile @@ -18,11 +18,18 @@ RUN pip install --upgrade pip && pip install --no-cache-dir -e "." RUN adduser --disabled-password --gecos '' appuser \ && chown -R appuser /app \ && chown -R appuser:appuser /etc/nginx/conf.d /var/log/nginx /var/lib/nginx \ - && touch /run/nginx.pid && chown -R appuser:appuser /run/nginx.pid + && touch /run/nginx.pid && chown -R appuser:appuser /run/nginx.pid \ + # Allow binding to ports > 1024 without root + && sed -i 's/listen 80/listen 9999/g' /etc/nginx/sites-available/default \ + && sed -i 's/listen \[::\]:80/listen \[::\]:9999/g' /etc/nginx/sites-available/default \ + # Create required directories with correct permissions + && mkdir -p /var/cache/nginx /var/run \ + && chown -R appuser:appuser /var/cache/nginx /var/run USER appuser -EXPOSE 8000 8008 8888 +# ToDo: Fix exposing ports +# EXPOSE 8000 8008 8888 CMD ["/app/run_fastagency.sh"] diff --git a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/content/nginx.conf.template b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/content/nginx.conf.template index 7279f13c2..c55a5bc4b 100644 --- a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/content/nginx.conf.template +++ b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/content/nginx.conf.template @@ -19,7 +19,6 @@ server { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; proxy_buffering off; diff --git a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/content/run_fastagency.sh b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/content/run_fastagency.sh index f219f1141..f1ec4c0e5 100755 --- a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/content/run_fastagency.sh +++ b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/docker/content/run_fastagency.sh @@ -20,6 +20,7 @@ do sed -i "5i\ server 127.0.0.1:$PORT;" nginx.conf.template done envsubst '${MESOP_PORT}' < nginx.conf.template >/etc/nginx/conf.d/default.conf +echo "Nginx config:" cat /etc/nginx/conf.d/default.conf # Start nginx diff --git a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/pyproject.toml b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/pyproject.toml index 5dc9bea9e..8f8ffc5c1 100644 --- a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/pyproject.toml +++ b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/pyproject.toml @@ -9,7 +9,6 @@ name = "my_fastagency_app" dependencies = [ "fastagency[autogen,mesop,server,fastapi,nats]>=0.3.0", - ] [project.optional-dependencies] diff --git a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/scripts/build_docker.sh b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/scripts/build_docker.sh index fc83d0ceb..47a834bc1 100755 --- a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/scripts/build_docker.sh +++ b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/scripts/build_docker.sh @@ -1,3 +1,5 @@ #!/bin/bash -docker build -t deploy_fastagency -f docker/Dockerfile --progress plain . +echo -e "\033[0;32mBuilding fastagency docker image\033[0m" +docker build -t deploy_fastagency -f docker/Dockerfile --progress plain . && \ +echo -e "\033[0;32mSuccessfully built fastagency docker image\033[0m" diff --git a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/scripts/deploy_to_fly_io.sh b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/scripts/deploy_to_fly_io.sh index 3d557d1c9..46e58ff50 100755 --- a/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/scripts/deploy_to_fly_io.sh +++ b/docs/docs_src/getting_started/nats_n_fastapi/my_fastagency_app/scripts/deploy_to_fly_io.sh @@ -1,7 +1,10 @@ #!/bin/bash +echo -e "\033[0;32mLogging into fly.io\033[0m" fly auth login +echo -e "\033[0;32mDeploying to fly.io\033[0m" fly launch --config fly.toml --copy-config --yes +echo -e "\033[0;32mSetting secrets\033[0m" fly secrets set OPENAI_API_KEY=$OPENAI_API_KEY