diff --git a/.github/workflows/cd_support_sphere_py.yml b/.github/workflows/cd_support_sphere_py.yml index 86d8501..4554c90 100644 --- a/.github/workflows/cd_support_sphere_py.yml +++ b/.github/workflows/cd_support_sphere_py.yml @@ -15,6 +15,8 @@ concurrency: env: FORCE_COLOR: 3 + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: dist: @@ -93,3 +95,39 @@ jobs: - uses: pypa/gh-action-pypi-publish@v1.9.0 if: startsWith(github.ref, 'refs/tags') + + push_to_registry: + name: Push Docker image to GH Container Registry + needs: [test-built-dist] + runs-on: ubuntu-latest + steps: + - name: Delay for PyPI + run: sleep 5 # Wait for the package to be available in PyPI + - name: Check out the repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Log in to registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: ./deployment/docker/ + file: ./deployment/docker/populate_db.Dockerfile + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: ${{ github.event_name != 'pull_request' }} + build-args: VERSION=${{needs.test-built-dist.outputs.package-version}} diff --git a/deployment/docker/populate_db.Dockerfile b/deployment/docker/populate_db.Dockerfile index d9da615..a9c6e7b 100644 --- a/deployment/docker/populate_db.Dockerfile +++ b/deployment/docker/populate_db.Dockerfile @@ -3,10 +3,6 @@ FROM python:3.12-slim # Set the working directory inside the container WORKDIR /app -# Copy the Python script and requirements file into the container -COPY ../../src/support_sphere_py /app/support_sphere_py - - # Below ENV values are overridden when running the via K8s Job else the above arg values are used. ENV DB_HOST=localhost ENV DB_PORT=5432 @@ -19,7 +15,7 @@ ENV JWT_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm # Install any necessary dependencies -RUN pip install --no-cache-dir ./support_sphere_py +RUN pip3 install --no-cache-dir --extra-index-url https://test.pypi.org/simple --only-binary=:all: support_sphere_py # Command to run the Python script -ENTRYPOINT ["sh", "-c", "python3 ./support_sphere_py/tests/resources/scripts/role_based_access_control.py && python3 ./support_sphere_py/tests/resources/scripts/update_db_sample_data.py"] +ENTRYPOINT ["sh", "-c", "python3 -m support_sphere.tests.resources.scripts.role_based_access_control && python3 -m support_sphere.tests.resources.scripts.update_db_sample_data"] \ No newline at end of file diff --git a/deployment/docker/populate_db_dev.Dockerfile b/deployment/docker/populate_db_dev.Dockerfile new file mode 100644 index 0000000..02089d3 --- /dev/null +++ b/deployment/docker/populate_db_dev.Dockerfile @@ -0,0 +1,25 @@ +FROM python:3.12-slim + +# Set the working directory inside the container +WORKDIR /app + +# Copy the Python script and requirements file into the container +COPY ../../src/support_sphere_py /app/support_sphere_py + + +# Below ENV values are overridden when running the via K8s Job else the above arg values are used. +ENV DB_HOST=localhost +ENV DB_PORT=5432 +ENV DB_USERNAME=postgres +ENV DB_PASSWORD=example123456 +ENV DB_NAME=postgres +ENV SUPABASE_KONG_HOST=supabase-supabase-kong +ENV SUPABASE_KONG_PORT=8000 +ENV JWT_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE + + +# Install any necessary dependencies +RUN pip install --no-cache-dir ./support_sphere_py + +# Command to run the Python script +ENTRYPOINT ["sh", "-c", "python3 ./support_sphere_py/tests/resources/scripts/role_based_access_control.py && python3 ./support_sphere_py/tests/resources/scripts/update_db_sample_data.py"] \ No newline at end of file diff --git a/pixi.toml b/pixi.toml index 02134db..a96fd95 100644 --- a/pixi.toml +++ b/pixi.toml @@ -31,7 +31,7 @@ setup-db-data-via-k8s-job = { depends-on = [ ]} [feature.db.tasks.build-docker-image-for-api-service] -cmd = "docker build -t pdc/populate_db:1.0 -f deployment/docker/populate_db.Dockerfile ." +cmd = "docker build -t pdc/populate_db:1.0 -f deployment/docker/populate_db_dev.Dockerfile ." [feature.db.tasks.import-docker-image-in-k8s-cluster] cmd = "k3d image import pdc/populate_db:1.0 -c pdc-cluster" diff --git a/src/support_sphere_py/pyproject.toml b/src/support_sphere_py/pyproject.toml index 790fec7..201b502 100644 --- a/src/support_sphere_py/pyproject.toml +++ b/src/support_sphere_py/pyproject.toml @@ -13,7 +13,7 @@ build-backend = "hatchling.build" [project] name = "support-sphere-py" -version = "0.0.8" +version = "0.0.12" description = "Package for support sphere api service" readme = "README.md" requires-python = ">=3.12"