bad dockerfile referencing #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Docker Images | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Install Docker | |
run: | | |
# Install Docker | |
sudo apt-get update | |
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get -y install docker-ce | |
- name: Set up QEMU | |
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
- name: Build and push Docker images | |
run: | | |
DOCKERFILES=$(find . -type f -name "Dockerfile.*") | |
echo "DOCKERFILES: $DOCKERFILES" | |
for DOCKERFILE in $DOCKERFILES; do | |
echo "DOCKERFILE: $DOCKERFILE" | |
# Extract the image name from the Dockerfile path | |
IMAGE_NAME=$(basename "${DOCKERFILE}" | sed 's/^Dockerfile\.//') | |
# Build and push multi-architecture Docker images | |
docker buildx create --use | |
docker buildx build --platform linux/arm64,linux/amd64 -t "${DOCKERHUB_USER}/${IMAGE_NAME}" -f "$DOCKERFILE" . | |
# Log in to Docker Hub (replace with your own Docker Hub username and token) | |
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USER" --password-stdin | |
# Push the multi-architecture Docker image to Docker Hub | |
docker buildx use default | |
docker push "${DOCKERHUB_USER}/${IMAGE_NAME}" | |
done | |
env: | |
DOCKERHUB_USER: ${{ secrets.DH_USER}} | |
DOCKERHUB_PASSWORD: ${{ secrets.DH_PAT }} |