From 560cc3f98b58e4e5c7f8bcda29828982df37a66d Mon Sep 17 00:00:00 2001 From: yinpeng <2291314224@qq.com> Date: Sun, 15 Dec 2024 13:53:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Docker=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E5=92=8C=E5=8F=91=E5=B8=83=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=EF=BC=8C=E5=B9=B6=E4=BC=98=E5=8C=96Dockerfile?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 62 ++++++++++++++++++++++++++++ Dockerfile | 7 ++-- 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..93a9eb7 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,62 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "main" ] + +env: + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # 这个权限用于标记容器镜像 + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # 登录到 GitHub Container Registry + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,format=long + labels: | + org.opencontainers.image.description=OpenAI API Compatible Server + org.opencontainers.image.source=${{ github.event.repository.html_url }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e96b6e4..d0dcd22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,16 +4,17 @@ WORKDIR /app # 复制所需文件到容器中 COPY ./app /app/app -COPY ./main.py /app COPY ./requirements.txt /app RUN pip install --no-cache-dir -r requirements.txt ENV API_KEYS=["your_api_key_1"] ENV ALLOWED_TOKENS=["your_token_1"] -ENV BASE_URL=https://api.groq.com/openai/v1 +ENV BASE_URL=https://generativelanguage.googleapis.com/v1beta +ENV TOOLS_CODE_EXECUTION_ENABLED=true +ENV MODEL_SEARCH=["gemini-2.0-flash-exp"] # Expose port EXPOSE 8000 # Run the application -CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]