Modern CI with Podman: Build & Push Images to Docker Hub via GitHub Actions

Modern CI with Podman: Build & Push Images to Docker Hub via GitHub Actions

Use Podman, a lightweight and secure Docker alternative, to build and push images in GitHub Actions directly to Docker Hub.

GitHub Actions Workflow

Create .github/workflows/podman-ci.yml:

name: Build & Push Podman Image

on:
  push:
    branches: [ main ]

jobs:
  build-and-push:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Install Podman
        run: sudo apt update && sudo apt install -y podman

      - name: Login to Docker Hub
        run: |
          echo "${{ secrets.DOCKER_PASSWORD }}" | podman login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin docker.io

      - name: Build & Push Image
        run: |
          podman build -t docker.io/yourdockerhubusername/podman-app:latest .
          podman push docker.io/yourdockerhubusername/podman-app:latest

GitHub Secrets Required

Set these in your repo:

  • DOCKER_USERNAME
  • DOCKER_PASSWORD

Dockerfile

FROM nginx:alpine
COPY webcontent/ /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

Sample index.html

Place this in webcontent/index.html

<!DOCTYPE html>
<html>
<head><title>Podman App</title></head>
<body>
  <h1>Hello from Podman! 🚀</h1>
</body>
</html>

Why Podman?

  • No Daemon Needed
  • Secure & Rootless
  • Docker-Compatible CLI
  • Lightweight & Fast

Once pushed, your GitHub Action will build the image and push it to Docker Hub.