diff --git a/.github/workflows/publish_image.yaml b/.github/workflows/publish_image.yaml new file mode 100644 index 0000000..8d193c4 --- /dev/null +++ b/.github/workflows/publish_image.yaml @@ -0,0 +1,45 @@ +name: Publish Docker image + +on: + push: + branches: + - 'release/**' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..edcea24 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.12-slim + +WORKDIR /app + +COPY ./poetry.lock /app +COPY ./pyproject.toml /app + +RUN pip install poetry +RUN poetry install + +COPY ./openai_api_server_mock /app/openai_api_server_mock + +CMD ["poetry", "run", "fastapi", "run", "openai_api_server_mock/main.py", "--port", "8000"] \ No newline at end of file diff --git a/openai_api_server_mock/settings.py b/openai_api_server_mock/settings.py index 07707a9..2dede47 100644 --- a/openai_api_server_mock/settings.py +++ b/openai_api_server_mock/settings.py @@ -1,4 +1,4 @@ -from typing import Optional, Literal +from typing import Literal from pydantic import Field from pydantic_settings import BaseSettings diff --git a/pyproject_old.toml b/pyproject_old.toml deleted file mode 100644 index fa26442..0000000 --- a/pyproject_old.toml +++ /dev/null @@ -1,38 +0,0 @@ -[build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" - - -[project] -name = "openai_api_mock" -version = "0.1.0" -description = "A fast api based mock of the openai api." -readme = "README.md" -requires-python = ">=3.9" -license = {file = "LICENSE"} -keywords = ["openai api", "fast api", "LLM"] -authors = [ - {name = "Sander Hummerich", email = "sander.hummerich@gmx.de" } -] -maintainers = [ - {name = "Sander Hummerich", email = "sander.hummerich@gmx.de" } -] -classifiers = [ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "Topic :: Software Development :: Build Tools", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3 :: Only", -] -dependencies = [ - "fastapi", - "lorem-text", -] - -[project.scripts] -sample = "sample:main"