diff --git a/.github/workflows/publish_docker.yml b/.github/workflows/publish_docker.yml new file mode 100644 index 0000000..a946b07 --- /dev/null +++ b/.github/workflows/publish_docker.yml @@ -0,0 +1,74 @@ +name: perfSONAR Lookup Server Image + +# This action builds Docker images then +# pushes result to GitHub Container Registry. + +on: + push: + branches: [ '*' ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + pull_request: + branches: [ 'main' ] + +env: + REGISTRY: ghcr.io + # github.repository as / + IMAGE_BASE: ${{ github.repository }} + BUILD_DIR: . + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v2 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE }} + tags: | + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker images + id: build-and-push + uses: docker/build-push-action@v3 + with: + context: ${{ env.BUILD_DIR }} + file: ${{ env.BUILD_DIR }}/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9b9883c..6f5ff6d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,4 @@ schema/__pycache__ schema/model.py schema/__init__.py tests/ -Dockerfile -http_ca.crt -Dockerfile \ No newline at end of file +http_ca.crt \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..af458f9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3 + +WORKDIR /usr/src/app + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 8000 + +CMD ["fastapi", "run", "app/main.py", "--port", "8000"] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 63c4ec3..26d1475 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,12 @@ +elasticsearch +fastapi +fastapi-cli +jsonschema opensearch-py +opentelemetry-api +opentelemetry-sdk +opentelemetry-instrumentation +opentelemetry-instrumentation-fastapi +opentelemetry-instrumentation-elasticsearch +slowapi +uvicorn \ No newline at end of file