diff --git a/.github/workflows/build-deploy-dev.yml b/.github/workflows/build-deploy-dev.yml new file mode 100644 index 0000000..9a3f57a --- /dev/null +++ b/.github/workflows/build-deploy-dev.yml @@ -0,0 +1,54 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: build and deploy to dev + +on: + push: + branches: + - dev + workflow_dispatch: + +jobs: + build: + runs-on: 'ubuntu-latest' + defaults: + run: + working-directory: ./app + + steps: + - uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Log in to registry + uses: docker/login-action@v1 + with: + registry: https://510emergencies.azurecr.io/ + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Build and push container image to container registry + uses: docker/build-push-action@v2 + with: + push: true + tags: 510emergencies.azurecr.io/kobo-connect-dev:${{ github.sha }} + file: Dockerfile + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Deploy container image to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'kobo-connect' + slot-name: 'production' + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_DEV }} + images: '510emergencies.azurecr.io/kobo-connect-dev:${{ github.sha }}' \ No newline at end of file diff --git a/.github/workflows/docker-build-deploy.yml b/.github/workflows/build-deploy-prod.yml similarity index 94% rename from .github/workflows/docker-build-deploy.yml rename to .github/workflows/build-deploy-prod.yml index fe7cca8..09cb245 100644 --- a/.github/workflows/docker-build-deploy.yml +++ b/.github/workflows/build-deploy-prod.yml @@ -1,7 +1,7 @@ # Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy # More GitHub Actions for Azure: https://github.com/Azure/actions -name: build and deploy to Azure Web App +name: build and deploy to prod on: push: @@ -14,7 +14,7 @@ jobs: runs-on: 'ubuntu-latest' defaults: run: - working-directory: ./summarizer-api + working-directory: ./app steps: - uses: actions/checkout@v2 diff --git a/Dockerfile b/Dockerfile index e8851a8..7fd25fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,20 @@ # python base image in the container from Docker Hub -FROM python:3.9-slim +FROM python:3.11-slim # copy files to the /app folder in the container ADD clients /app/clients ADD mappings /app/mappings COPY ./main.py /app/main.py -COPY ./requirements.txt /app/requirements.txt +COPY ./pyproject.toml /app/pyproject.toml +COPY ./poetry.lock /app/poetry.lock # set the working directory in the container to be /app WORKDIR /app # install required packages -RUN pip install -r requirements.txt +RUN pip install poetry +RUN poetry config virtualenvs.create false +RUN poetry install --no-root # expose the port that uvicorn will run the app on ENV PORT=8000 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..927d589 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,47 @@ +[tool.poetry] +name = "kobo-connect" +version = "0.0.2" +authors = [ + "Jacopo Margutti " +] +description = "kobo-connect" +readme = "README.md" +repository = "https://github.com/rodekruis/kobo-connect" +packages = [{include = "clients"}] + +[tool.poetry.dependencies] +python = "^3.11" +aiohttp = "*" +aiosignal = "*" +async-timeout = "*" +azure-monitor-opentelemetry-exporter = "*" +azure-core = "*" +azure-storage-blob = "*" +azure-cosmos = "*" +attrs = "*" +certifi = "*" +charset-normalizer = "*" +click = "*" +colorama = "*" +fastapi = "*" +frozenlist = "*" +idna = "*" +lxml = "*" +multidict = "*" +pandas = "*" +passlib = "*" +pypdf = "*" +python-docx = "*" +python-dotenv = "*" +python-jose = "*" +regex = "*" +requests = "*" +tiktoken = "*" +tqdm = "*" +urllib3 = "*" +yarl = "*" +uvicorn = "*" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 18ad1fc..0000000 --- a/requirements.txt +++ /dev/null @@ -1,30 +0,0 @@ -aiohttp==3.8.4 -aiosignal==1.3.1 -async-timeout==4.0.2 -attrs==23.1.0 -certifi==2023.5.7 -charset-normalizer==3.2.0 -click==8.1.5 -colorama==0.4.6 -frozenlist==1.4.0 -idna==3.4 -lxml==4.9.3 -multidict==6.0.4 -openai==0.27.8 -pandas==2.2.1 -pypdf==3.12.2 -python-docx==0.8.11 -python-dotenv==1.0.0 -regex==2023.6.3 -requests==2.31.0 -tiktoken==0.4.0 -tqdm==4.65.0 -urllib3==2.0.3 -yarl==1.9.2 -uvicorn==0.23.1 -fastapi==0.100.0 -azure-core==1.29.6 -azure-storage-blob==12.19.0 -azure-cosmos==4.5.1 -python-jose==3.3.0 -passlib==1.7.4 \ No newline at end of file