SeppeBudenaers / IoT_Technologie_PXL_2024

1 stars 0 forks source link

Automatic packaging of the docker image #28

Open TheNeg0t1ator opened 9 months ago

TheNeg0t1ator commented 9 months ago

Part of:

SeppeBudenaers commented 8 months ago

Create GitHub Actions Workflow:

Create a file named .github/workflows/docker-build.yml in your repository to define the GitHub Actions workflow.

   name: Build Docker Image

   on:
     push:
       branches:
         - main

   jobs:
     build:
       runs-on: ubuntu-latest

       steps:
         - name: Checkout Repository
           uses: actions/checkout@v2

         - name: Build Docker Image
           run: docker build -t your-image-name:latest .

This workflow is triggered on pushes to the main branch, checks out the repository, and builds the Docker image using the specified Dockerfile.

  1. Configure Docker Hub Secrets: Go to your GitHub repository, navigate to "Settings" > "Secrets," and add two secrets: DOCKER_USERNAME and DOCKER_PASSWORD.

    • DOCKER_USERNAME: Your Docker Hub username.
    • DOCKER_PASSWORD: Your Docker Hub password or a personal access token.

Now, when you push changes to the main branch, GitHub Actions will automatically build the Docker image and use the provided secrets to authenticate and push the image.

finished yaml file

main.yaml file