From d89a6288892828c4228bd474212f722bd88fbb7f Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 5 Sep 2024 14:19:02 -0700 Subject: [PATCH] add oci image build --- .github/workflows/oci.yaml | 63 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 6 ++++ pyproject.toml | 19 ++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 .github/workflows/oci.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/oci.yaml b/.github/workflows/oci.yaml new file mode 100644 index 0000000..0783c2a --- /dev/null +++ b/.github/workflows/oci.yaml @@ -0,0 +1,63 @@ +--- +name: OCI Build and Publish + +"on": + workflow_dispatch: + push: + branches: + - "**" + tags: + - "v*.*.*" + pull_request: + branches: + - main + - master + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + oci_image: + name: Build OCI Image + if: github.repository == 'lsst/s3daemon' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2c88cf0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.12 + +WORKDIR /app +COPY . . +RUN pip install --no-cache-dir --root-user-action ignore . +ENTRYPOINT ["s3daemon"] diff --git a/pyproject.toml b/pyproject.toml index 0f1cf5d..808b3a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,22 @@ +[project] +name = "s3daemon" +dynamic = ["version", "dependencies"] + +[build-system] +requires = ["setuptools>=64", "setuptools_scm>=8"] +build-backend = "setuptools.build_meta" + +[project.scripts] +s3daemon = "s3daemon.s3daemon:main" + +[tool.setuptools_scm] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} + +[tool.setuptools] +package-dir = {"" = "python"} + [tool.black] line-length = 110 target-version = ["py311"]