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

Automating image tag update for admin dashboard #15

Merged
merged 26 commits into from
May 7, 2024

Commits on Apr 16, 2024

  1. Merge pull request #13 from MukuFlash03/image-push

    Bumped up base server image tag
    MukuFlash03 authored Apr 16, 2024
    Configuration menu
    Copy the full SHA
    fc792bc View commit details
    Browse the repository at this point in the history
  2. Merge pull request #14 from MukuFlash03/image-push

    Bump up base server image tag
    MukuFlash03 authored Apr 16, 2024
    Configuration menu
    Copy the full SHA
    f924af0 View commit details
    Browse the repository at this point in the history

Commits on Apr 26, 2024

  1. Artifact download test - 1

    Added working code from join repo to fetch docker image tags using artifact download.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    237df16 View commit details
    Browse the repository at this point in the history

Commits on May 1, 2024

  1. Artifact + Matrix - 1

    Combining both artifact and matrix methods since both workflow is triggered by both push event and workflow_dispatch event.
    
    Workflow dispatch event receives tag via input parameter sent via server workflow.
    Push event does not receive any tag and the DOCKER_IMAGE_TAG_2 would have empty value since workflow triggering event and hence input parameter would be empty.
    So, was facing the issue of having empty timestamp being suffixed to the docker image tag in the Dockerfiles.
    
    Hence, using the logic of fetching the latest run id and then downloading the artifact uploaded by server workflow to ensure that a non-empty value is also retrieved for the timestamp.
    This value is stored in DOCKER_IMAGE_TAG_1 and can be used for building docker image.
    
    Now, depending on the trigger event, the appropriate docker image tag can be used in the docker build command for the --build-arg flag.
    
    Additionally, Dockerfiles now use ARG to use the tags passed from the docker build command, hence using environment variables.
    
    Docker-compose files similarly have the args config parameter set.
    
    Developers would have to set the correct server image tags manually here for the docker-compose command to pass the value to the ARG in the Dockerfile and correctly set the image tag to point to the appropriate server image.
    Need to mention somewhere in the ReadME.md to refer to the server image list in Dockerhub to choose the latest image tag. While pushing the image in the GitHub actions, it'll be done manually.
    
    Todo: Change branch name to tags-combo-approach in fetch_runID.py
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 1, 2024
    Configuration menu
    Copy the full SHA
    cd9682a View commit details
    Browse the repository at this point in the history
  2. Artifact + Matrix - 2

    Was unable to see docker_image_tag in echo statement in logs.
    Added docker_image_tag print statement to see retrieved image tag.
    Ah! Was using run_id instead of docker_image_tag as the output value in outputs section in fetch_tag job.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 1, 2024
    Configuration menu
    Copy the full SHA
    11dd97b View commit details
    Browse the repository at this point in the history
  3. Artifact + Matrix - 3

    Still not seeing the env vars echo-ed.
    Debugging by printing various log statements.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 1, 2024
    Configuration menu
    Copy the full SHA
    ed3a505 View commit details
    Browse the repository at this point in the history

Commits on May 2, 2024

  1. Artifact + Matrix - 4

    Still not seeing the env vars echo-ed.
    Debugging by printing various log statements.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 2, 2024
    Configuration menu
    Copy the full SHA
    d66893b View commit details
    Browse the repository at this point in the history
  2. Artifact + Matrix - 5

    Working finally!
    Changed the deprecated set-output command to use {key}={value} format with echo command.
    
    Also, adding commented out build and push commands to see if build, push is successful.
    For this commit, not changing branch = tags-artifact in fetch_runID.py
    Once, server code has latest working yml file, then will come back and push another commit to change branch to tags-combo-approach.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 2, 2024
    Configuration menu
    Copy the full SHA
    39b289f View commit details
    Browse the repository at this point in the history
  3. Artifact + Matrix - 6

    Removed an extra echo statement.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 2, 2024
    Configuration menu
    Copy the full SHA
    340d9d0 View commit details
    Browse the repository at this point in the history
  4. Artifact + Matrix - 7

    Updating Dockerfiles to use ARG environment variable with latest timestamp that will be passed through:
    - `docker build --build-arg` command in Github actions in the workflow for automated pushing to Docker hub.
    - `args: ` config field in docker-compose which will need to be set manually by developers locally.
    
    Also, changing branch in fetch_runID and Dockerfiles to tags-combo-approach.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 2, 2024
    Configuration menu
    Copy the full SHA
    15c9da1 View commit details
    Browse the repository at this point in the history
  5. Artifact + Matrix - 8

    For public-dash, admin-dash where ARGS are now being used, need to add the args under build command in the docker compose files.
    Gives error if arg is at the same hierarchical level as build.
    
    Also, public-dash docker-compose.yml (non-dev) version changed to have build: context, dockerfile ; unlike only build: frontend.
    This allows adding args under build. Similar to how currently being built in docker-compose.dev.yml.
    
    Also, args to be added under notebook-server and not dashboard since viz_scripts builds off of server image and not frontend, which is a node image.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 2, 2024
    Configuration menu
    Copy the full SHA
    0c78ad3 View commit details
    Browse the repository at this point in the history

Commits on May 3, 2024

  1. Artifact + Matrix - 9

    Adding .env file which stores only docker image timestamp for the latest dockerhub e-mission-server image already pushed.
    
    .env file overwritten in both types of trigger events - push and workflow_dispatch.
    
    Added commit and push github actions as well for pushing latest changes to the .env file made via the workflow.
    
    Lastly, docker-compose now also mentions the ENV variable name to be read from the .env file for the ARG value in the Dockerfile.
    
    No changes required in the Dockerfiles.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 3, 2024
    Configuration menu
    Copy the full SHA
    d03ce01 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a2eca04 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3b8f312 View commit details
    Browse the repository at this point in the history
  4. Added TODOs in github actions workflow YAML file.

    Reminder for things to change as per master branch of e-mission-server once changes are finalized.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 3, 2024
    Configuration menu
    Copy the full SHA
    352c8ae View commit details
    Browse the repository at this point in the history
  5. Artifact + Matrix - 10

    Added another TODO.
    
    evious Push event triggers run failed
    
    Error occurred in GitHub actions git add, commit, push step.
    If file with no changes operated upon, it leaves an error:
    “nothing to commit, working tree clean
    Error: Process completed with exit code 1.”
    
    Need to fix.
    
    ——
    
    Quick fix is to make changes to .env file only if workflow_dispatch event is the trigger.
    Don’t do anything for push event.
    So, in case anyone modifies .env file on their own by using their own timestamp during testing, and pushes it as a part of their PR, then Shankari will have to ask them to revert the changes.
    Else, their custom timestamp will make it to the repo code base.
    
    Found something:
    https://www.reddit.com/r/github/comments/ju3ipr/commit_from_github_action_only_when_changes_exist/
    
    It should work but there’s a drawback of using “exit 0” - it will mask all errors generated during “git commit”.
    This is bad and we won’t be able to see the reason why something wrong happened as the workflow would be shown as successful with a green tick.
    
    Found a solution with git diff:
    https://github.com/simonw/til/blob/main/github-actions/commit-if-file-changed.md
    
    $ git diff --quiet || (git add README.md && git commit -m "Updated README")
    
    However, I won’t be able to log any message saying that no changes to commit, tag not modified.
    Hence, will possibly use just “git diff —quiet” with an if-else block.
    
    Expected results:
    - Push event triggers workflow.
    - It writes DOCKER_IMAGE_TAG_1 fetched from last successful completed run to .env file.
    - It sees that there is a difference in the latest committed .env file in the dashboard repo which includes older timestamp.
    - Hence it runs git commit part of the script to reset to latest server timestamp.
    Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 3, 2024
    Configuration menu
    Copy the full SHA
    d98f75c View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f1ea34c View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    629831f View commit details
    Browse the repository at this point in the history

Commits on May 6, 2024

  1. Configuration menu
    Copy the full SHA
    43adc05 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5e0de4b View commit details
    Browse the repository at this point in the history
  3. Update Dockerfile

    Reverting the Dockerfile tag for testing so that checks can run properly
    nataliejschultz authored May 6, 2024
    Configuration menu
    Copy the full SHA
    791b6d9 View commit details
    Browse the repository at this point in the history
  4. Syntax

    Removing a space.
    nataliejschultz authored May 6, 2024
    Configuration menu
    Copy the full SHA
    4a90d2b View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    53dddcf View commit details
    Browse the repository at this point in the history

Commits on May 7, 2024

  1. Update Dockerfile again

    Also editing this file so that checks pass for now
    nataliejschultz authored May 7, 2024
    Configuration menu
    Copy the full SHA
    e56b1e1 View commit details
    Browse the repository at this point in the history
  2. Finalize Dockerfiile

    Changing this to build from actual e-mission server in hopes of merging!
    nataliejschultz authored May 7, 2024
    Configuration menu
    Copy the full SHA
    980877f View commit details
    Browse the repository at this point in the history
  3. Update Dockerfile in docker folder

    Potentially finalizing the dockerfile in the docker repo.
    nataliejschultz authored May 7, 2024
    Configuration menu
    Copy the full SHA
    f1fd42c View commit details
    Browse the repository at this point in the history