From b7933cf8ad107499d6c38857bb70cce55646e52f Mon Sep 17 00:00:00 2001 From: Krithika Date: Thu, 17 Oct 2024 09:42:21 -0400 Subject: [PATCH] first commit --- .github/workflows/main.yml | 112 +++++++++++++++++ gitignore.txt | 160 +++++++++++++++++++++++++ images/.DS_Store | Bin 0 -> 6148 bytes images/py-hello-world/Dockerfile.txt | 13 ++ images/py-hello-world/app.py | 11 ++ images/py-hello-world/requirements.txt | 1 + 6 files changed, 297 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 gitignore.txt create mode 100644 images/.DS_Store create mode 100644 images/py-hello-world/Dockerfile.txt create mode 100644 images/py-hello-world/app.py create mode 100644 images/py-hello-world/requirements.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..a5a871f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,112 @@ +name: Build Py Hello World + +on: + push: + branches: [ main ] + +permissions: read-all + +defaults: + run: + shell: bash + +env: + IMAGE_REGISTRY: docker.io + IMAGE_NAME: ${{ github.event.repository.name }}-py-hello-world + REGISTRY_USERNAME: upgradkrithikavenugopal + +jobs: + build: + outputs: + image: ${{ steps.image.outputs.image }} + digest: ${{ steps.build.outputs.digest }} + permissions: + packages: write # for uploading attestations. + contents: read + id-token: write + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2.3.4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v2.0.0 + + - name: Authenticate Docker + # uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0 + uses: docker/login-action@v3 + with: + # Use docker to simpliy local testing. + registry: ${{ env.IMAGE_REGISTRY }} + username: upgradkrithikavenugopal + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a # v4.0.1 + with: + images: ${{ env.IMAGE_REGISTRY }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 # v3.0.0 + id: build + with: + push: true + platforms: linux/amd64,linux/arm64 + context: "{{defaultContext}}:images/py-hello-world" + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Install Cosign + uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0 + + - shell: bash + run: | + set -e + cosign sign --yes \ + -a "repo=${{ github.repository }}" \ + -a "workflow=${{ github.workflow }}" \ + -a "ref=${{ github.sha }}" \ + ${IMAGE_REGISTRY}/${REGISTRY_USERNAME}/${IMAGE_NAME}@${{ steps.build.outputs.digest }} + + - name: Output image + id: image + run: | + image_name="${IMAGE_REGISTRY}/${REGISTRY_USERNAME}/${IMAGE_NAME}" + echo "image=$image_name" >> "$GITHUB_OUTPUT" + + provenance: + needs: [build] + permissions: + actions: read # for detecting the Github Actions environment. + id-token: write # for creating OIDC tokens for signing. + packages: write # for uploading attestations. + uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v1.10.0 + with: + image: ${{ needs.build.outputs.image }} + digest: ${{ needs.build.outputs.digest }} + # Use name rather than env variable because env are not available for reusable workflows. + registry-username: upgradkrithikavenugopal + secrets: + registry-password: ${{ secrets.REGISTRY_PASSWORD }} + + run: + needs: [build, provenance] + runs-on: ubuntu-latest + steps: + - name: Authenticate Docker + uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0 + with: + # Use docker to simpliy local testing. + registry: ${{ env.IMAGE_REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + - name: Run it + env: + IMAGE: ${{ needs.build.outputs.image }} + DIGEST: ${{ needs.build.outputs.digest }} + run: | + docker pull "${IMAGE}@${DIGEST}" + + # See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions for log types. + echo "::warning ${IMAGE}@${DIGEST}" diff --git a/gitignore.txt b/gitignore.txt new file mode 100644 index 0000000..68bc17f --- /dev/null +++ b/gitignore.txt @@ -0,0 +1,160 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/images/.DS_Store b/images/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4b20f9d0f0d992b77c238c0f59a93dee6c7597fe GIT binary patch literal 6148 zcmeHK%}N6?5T3NvZYfF+7CZ*LR$M`?;AL6s3%H^OmD*(&U0gS%KQ2-Vd(#*4ReT<2 zl2j~J4<1CyOqqO>$xK4Nl*|SIgg=gU0U7|{pc0m9*nA;0PP!l^>md|+ju=w>DcFX5 zA(|ckkpVipb?Czrp4lCIK0gHmJj*D|hy5^BA;!Ii{WKYlT=z|s%9WMXs#A69&UJ97 z@?g{(jfZ}3a7n#0rP6R__rmie&by6`W0j41Nfr-uLK4Loa&?hpk;;8F&Z42t4a|U3 zb86j2b24#Tvb{HL$w_-k_3DTw(Ad1r1$_ gF_ud4CaMHello, World!

" + +if __name__ == "__main__": + app.run(debug=True) \ No newline at end of file diff --git a/images/py-hello-world/requirements.txt b/images/py-hello-world/requirements.txt new file mode 100644 index 0000000..c204bef --- /dev/null +++ b/images/py-hello-world/requirements.txt @@ -0,0 +1 @@ +Flask==3.0.0 \ No newline at end of file