This guide explains how to set up automatic Docker Hub deployment for the JAQ Stack Examples repository.
The repository is configured with:
- Dockerfile: Builds the Basic Authentication example
- GitHub Actions: Automatically builds and pushes to Docker Hub on main branch pushes
- Docker Hub Repository:
surendocker/jaqstack-examples
- Docker Hub account
- GitHub repository with Actions enabled
- Docker installed locally (for testing)
- Go to Docker Hub
- Click "Create Repository"
- Set repository name:
jaqstack-examples - Set visibility: Public or Private (your choice)
- Click "Create"
- Go to your GitHub repository
- Navigate to Settings → Secrets and variables → Actions
- Click New repository secret
- Add the following secrets:
- Name:
DOCKERHUB_USERNAME - Value: Your Docker Hub username (e.g.,
surendocker)
- Name:
DOCKERHUB_TOKEN - Value: Your Docker Hub access token
To create a Docker Hub access token:
- Go to Docker Hub → Account Settings → Security
- Click "New Access Token"
- Give it a name (e.g., "GitHub Actions")
- Set permissions to "Read, Write, Delete"
- Copy the generated token
- Push changes to the
mainbranch - Go to Actions tab in your GitHub repository
- Watch the "Build and Push Docker Image" workflow
- Check Docker Hub for the new image
# Pull the latest image
docker pull surendocker/jaqstack-examples:latest
# Run the container
docker run -d -p 8080:8080 --name jaqstack-app surendocker/jaqstack-examples:latest- URL: http://localhost:8080
- Basic Authentication Example: http://localhost:8080
You can customize the application with environment variables:
docker run -d -p 8080:8080 \
-e JAVA_OPTS="-Xmx1024m -Xms512m" \
--name jaqstack-app \
surendocker/jaqstack-examples:latestCreate a docker-compose.yml file:
version: '3.8'
services:
jaqstack-app:
image: surendocker/jaqstack-examples:latest
ports:
- "8080:8080"
environment:
- JAVA_OPTS=-Xmx1024m -Xms512m
restart: unless-stoppedThen run:
docker-compose up -d- Build fails: Check that all secrets are set correctly
- Push fails: Verify Docker Hub token has correct permissions
- Image not found: Ensure the repository name matches exactly
# Check container logs
docker logs jaqstack-app
# Check GitHub Actions logs
# Go to Actions tab → Click on failed workflow → View logs# Build locally
docker build -t jaqstack-examples:local .
# Run locally
docker run -d -p 8080:8080 --name jaqstack-app jaqstack-examples:localThe workflow creates multiple tags:
latest: Latest version from main branchmain: Branch-specific tagsha-<commit-hash>: Specific commit tags
- Never commit Docker Hub credentials to the repository
- Use GitHub Secrets for all sensitive information
- Regularly rotate your Docker Hub access tokens
- Consider using Docker Hub's automated security scanning
For issues with:
- Docker: Check Docker documentation
- GitHub Actions: Check GitHub Actions documentation
- Docker Hub: Check Docker Hub documentation