diff --git a/.github/workflows/image_build.yml b/.github/workflows/image_build.yml new file mode 100644 index 0000000..d49c5f1 --- /dev/null +++ b/.github/workflows/image_build.yml @@ -0,0 +1,53 @@ +name: Build and Push Docker Image + +on: + push: + branches: ["main"] + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + run: echo "Checking out repository..." + + - uses: actions/checkout@v4 + + - name: Checkout completed + run: echo "Repository checked out." + + - name: Docker login start + run: echo "Logging in to Docker Hub as ${{ secrets.USERNAME }}" + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + + - name: Docker login success + run: echo "Docker Hub login successful." + + - name: Setup Buildx start + run: echo "Setting up Docker Buildx..." + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Buildx ready + run: echo "Docker Buildx is ready." + + - name: Build & push start + run: echo "Building and pushing Docker image..." + + - name: Build and Push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ secrets.USERNAME }}/final-python:latest + + - name: Build & push finished + run: echo "Docker image pushed successfully" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 2796c76..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Build -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] -jobs: - sonarcloud: - name: SonarCloud - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml deleted file mode 100644 index 23dbc83..0000000 --- a/.github/workflows/python-ci.yml +++ /dev/null @@ -1,54 +0,0 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Python Package - -on: - release: - types: [published] - workflow_dispatch: - -permissions: - contents: write - -jobs: - Build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.7' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install --target=./ -r requirements.txt - - - - name: Archive Release - uses: thedoctor0/zip-release@0.7.5 - with: - type: 'zip' - filename: "package-${{github.ref_name}}.zip" - exclusions: '*.git* .editorconfig' - - - name: Upload Release - uses: ncipollo/release-action@v1.12.0 - with: - artifacts: "package-${{github.ref_name}}.zip" - token: ${{ secrets.GITHUB_TOKEN }} - allowUpdates: true - # run: python -m build - # - name: Publish package - # uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - # with: - # user: __token__ - # password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b173c01 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.7-slim + +WORKDIR /app + +RUN pip install pipenv + +COPY Pipfile Pipfile.lock ./ + +RUN pipenv install --system + +COPY . . + +EXPOSE 5000 + +CMD ["python", "app.py"]