Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLA-2071] Improves pipelines #61

Merged
merged 17 commits into from
Nov 8, 2024
Merged

Conversation

leonardocustodio
Copy link
Contributor

@leonardocustodio leonardocustodio commented Nov 8, 2024

PR Type

enhancement, configuration changes


Description

  • Introduced a new GitHub Actions workflow to automate Docker image builds.
  • The workflow triggers on both pull requests and pushes to the repository.
  • Utilizes the latest Ubuntu environment for running the job.
  • Includes steps to check out the repository and execute a Docker build.

Changes walkthrough 📝

Relevant files
Configuration changes
docker-build.yml
Add GitHub Actions workflow for Docker image build             

.github/workflows/docker-build.yml

  • Added a new GitHub Actions workflow for building Docker images.
  • Configured the workflow to trigger on pull requests and pushes.
  • Set up a job to run on the latest Ubuntu environment.
  • Included steps to check out the repository and build a Docker image.
  • +15/-0   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Signed-off-by: Leonardo Custodio <[email protected]>
    Copy link

    github-actions bot commented Nov 8, 2024

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    Copy link

    github-actions bot commented Nov 8, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Add a Docker tag to the build command to enhance image versioning

    Specify the Docker tag to ensure the built image can be properly versioned and
    identified, rather than using the default 'latest' tag.

    .github/workflows/docker-build.yml [15]

    -docker build .
    +docker build -t my-image:${{ github.sha }}
    Suggestion importance[1-10]: 8

    Why: Specifying a Docker tag using the commit SHA adds traceability and avoids using the 'latest' tag, which can lead to confusion in environments with multiple deployments.

    8
    Include a Docker registry login step to enable image pushing to a secure registry

    Add a step to log in to a Docker registry before building and pushing the image to
    ensure the image can be pushed to a secured registry.

    .github/workflows/docker-build.yml [11]

     - uses: actions/checkout@v4
    +- name: Log in to Docker Hub
    +  run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
    Suggestion importance[1-10]: 7

    Why: Adding a login step before pushing images ensures that the workflow can push images to secured registries, which is crucial for CI/CD pipelines in private projects.

    7
    Performance
    Implement caching in Docker builds to reduce build times

    Add a caching mechanism to the Docker build process to speed up the build time by
    reusing layers from previous builds.

    .github/workflows/docker-build.yml [15]

    -docker build .
    +docker build --cache-from my-image:latest .
    Suggestion importance[1-10]: 7

    Why: Using caching in Docker builds can significantly reduce build times by reusing layers from previous builds, which is beneficial for speeding up continuous integration processes.

    7
    Enhancement
    Specify branches for the 'push' event to control workflow triggers

    Define triggers for the 'push' event to specify branches, avoiding unintended builds
    on all branches.

    .github/workflows/docker-build.yml [5]

     push:
    +  branches:
    +    - main
    +    - develop
    Suggestion importance[1-10]: 6

    Why: Specifying branches for the 'push' event helps to prevent unintended builds on all branches, thus saving resources and only triggering builds when necessary.

    6

    Signed-off-by: Leonardo Custodio <[email protected]>
    Signed-off-by: Leonardo Custodio <[email protected]>
    Signed-off-by: Leonardo Custodio <[email protected]>
    Signed-off-by: Leonardo Custodio <[email protected]>
    Signed-off-by: Leonardo Custodio <[email protected]>
    Signed-off-by: Leonardo Custodio <[email protected]>
    @leonardocustodio leonardocustodio self-assigned this Nov 8, 2024
    @leonardocustodio leonardocustodio changed the title Create docker-build.yml [PLA-2071] Create docker-build.yml Nov 8, 2024
    @leonardocustodio leonardocustodio marked this pull request as draft November 8, 2024 17:44
    Signed-off-by: Leonardo Custodio <[email protected]>
    Signed-off-by: Leonardo Custodio <[email protected]>
    @leonardocustodio leonardocustodio changed the title [PLA-2071] Create docker-build.yml [PLA-2071] Improves pipelines Nov 8, 2024
    @leonardocustodio leonardocustodio marked this pull request as ready for review November 8, 2024 17:51
    Signed-off-by: Leonardo Custodio <[email protected]>
    Signed-off-by: Leonardo Custodio <[email protected]>
    @leonardocustodio leonardocustodio merged commit ed0c956 into master Nov 8, 2024
    10 checks passed
    @leonardocustodio leonardocustodio deleted the leonardocustodio-patch-1 branch November 8, 2024 21:43
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Development

    Successfully merging this pull request may close these issues.

    2 participants