diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3aafc41 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,20 @@ +* + +!/pyproject.toml +!/README.md +!/uv.lock + +!/stapi-fastapi/pyproject.toml +!/stapi-fastapi/README.md +!/stapi-fastapi/src/* +!/stapi-fastapi/tests/* + +!/stapi-pydantic/pyproject.toml +!/stapi-pydantic/README.md +!/stapi-pydantic/src/* +!/stapi-pydantic/tests/* + +!/pystapi-validator/pyproject.toml +!/pystapi-validator/README.md +!/pystapi-validator/src/* +!/pystapi-validator/tests/* diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 771b442..000c662 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,6 +38,13 @@ jobs: if: ${{ matrix.python-version == '3.12' }} with: path: site/ + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build Docker Image + uses: docker/build-push-action@v6 + with: + push: false + build-args: PYTHON_VERSION=${{ matrix.python-version }} docs: name: Deploy docs diff --git a/.github/workflows/pypi.yaml b/.github/workflows/release.yaml similarity index 62% rename from .github/workflows/pypi.yaml rename to .github/workflows/release.yaml index 29ce100..7e9245a 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/release.yaml @@ -18,6 +18,7 @@ jobs: TAG: ${{ github.ref_name }} id: split run: echo "package_name=${TAG%%/*}" >> $GITHUB_OUTPUT + release: name: Release ${{ needs.package_name.outputs.package_name }} runs-on: ubuntu-latest @@ -43,3 +44,30 @@ jobs: - uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: ${{ needs.package_name.outputs.package_name}}/dist + + docker: + name: Build Docker Image + runs-on: ubuntu-latest + needs: package_name + if: ${{ needs.package_name.outputs.package_name }} == 'stapi-fastapi' + + permissions: + contents: read + packages: write + id-token: write + + steps: + - name: Log in to the Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and Push Docker Image + uses: docker/build-push-action@v6 + with: + push: true + tags: stapi-spec/stapi-fastapi:${{ github.ref_name }} + build-args: PYTHON_VERSION='3.12' diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..825ed1d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +ARG PYTHON_VERSION=3.12 +ARG BASE_IMAGE=ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-alpine + +FROM ${BASE_IMAGE} AS base + +WORKDIR /app +COPY . /app + +RUN uv sync --frozen + +CMD ["uv", "run", "fastapi", "dev", "/app/stapi-fastapi/tests/application.py", "--host", "0.0.0.0", "--port", "80"]