{"id":19143302,"url":"https://github.com/devenes/containerization-dummy-go","last_synced_at":"2026-04-15T14:03:30.291Z","repository":{"id":107130784,"uuid":"469921966","full_name":"devenes/containerization-dummy-go","owner":"devenes","description":"Simple Go server containerization using GitHub Actions, Jenkins and AWS CodeBuild.","archived":false,"fork":false,"pushed_at":"2023-05-03T01:08:55.000Z","size":6216,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-22T19:27:04.984Z","etag":null,"topics":["aws","buildspec","code-deploy","codebuild","codebuild-deploy","codecommit","developer-tools","docker","dockerfile","github-actions","go","golang","jenkins","jenkins-pipeline","jenkinsfile"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devenes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-14T22:17:27.000Z","updated_at":"2022-04-26T10:46:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"770ffa53-55c4-4a83-aa55-7f40d0dc8923","html_url":"https://github.com/devenes/containerization-dummy-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devenes/containerization-dummy-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenes%2Fcontainerization-dummy-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenes%2Fcontainerization-dummy-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenes%2Fcontainerization-dummy-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenes%2Fcontainerization-dummy-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devenes","download_url":"https://codeload.github.com/devenes/containerization-dummy-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenes%2Fcontainerization-dummy-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31844331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T13:28:40.153Z","status":"ssl_error","status_checked_at":"2026-04-15T13:28:29.396Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","buildspec","code-deploy","codebuild","codebuild-deploy","codecommit","developer-tools","docker","dockerfile","github-actions","go","golang","jenkins","jenkins-pipeline","jenkinsfile"],"created_at":"2024-11-09T07:30:19.396Z","updated_at":"2026-04-15T14:03:30.260Z","avatar_url":"https://github.com/devenes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CI/CD with Golang\n\n[![Go](https://github.com/devenes/containerization-dummy-go/actions/workflows/go.yml/badge.svg)](https://github.com/devenes/containerization-dummy-go/actions/workflows/go.yml) [![Docker Build And Push](https://github.com/devenes/containerization-dummy-go/actions/workflows/dockerx.yml/badge.svg)](https://github.com/devenes/containerization-dummy-go/actions/workflows/dockerx.yml)\n\n## Part 1\n\n- Since we want to trigger the CI/CD process with the push we will perform within the GitHub ecosystem, we have pushed the source code to our own repo.\n\n- We used GitHub Actions, the Pipeline as Code tool offered by GitHub, to trigger the process with the push commit.\n\n- A script was written to perform the Docker build process with the trigger and to give the version number.\n\n```\nFROM golang:1.16-alpine\n\nWORKDIR /app\n\nCOPY go.mod .\nCOPY go.sum .\nRUN go mod download\n\nCOPY *.go .\n\nRUN go build -o /dummy-app\nEXPOSE 8080\n\nCMD [\"/dummy-app\"]\n```\n\n- The username and password of the Docker Hub Registry, which is the environment we will push our Docker images to after we build, are defined as secrets in GitHub Repo Settings and used as environment variables in the GitHub Actions pipeline.\n\n- To trigger our Jenkins pipeline, we add the curl command to the end of our GitHub Actions pipeline and our token that we defined in Jenkins to send a request to the webhook link of the server.\n\n  - Note: Token is defined as environment variable in secrets from GitHub repo settings.\n\nIn our Jenkins pipeline, we first stop and delete the running container and clean up the old images. Then we download the Image that we have determined with the current tag number and run it as a container.\n\nWe give 80 as the port number in the docker run command so that our Jenkins running on 8080 and our Go application do not conflict with each other.\n\nThe output of our operations looks like this:\n\nOur image that we pushed to Docker Hub after we got the Build:\n\n## Part 2\n\nBefore starting to operate on CodeBuild, we give some permissions to reach the ECR and to examine the post-process logs in detail:\n\nWe selected our repo by logging into CodeBuild with GitHub. Then we edit the build spec file with the links we got from the ECR settings:\n\n```\nversion: 0.2\n\nphases:\n  pre_build:\n    commands:\n      - echo Logging in to Amazon ECR...\n      - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com\n  build:\n    commands:\n      - echo Build started on `date`\n      - echo Building the Docker image...\n      - docker build -t mydockerrepo .\n      - docker tag mydockerrepo:latest 32976713052.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG\n  post_build:\n    commands:\n      - echo Build completed on `date`\n      - echo Pushing the Docker image...\n      - docker push 32976713052.dkr.ecr.us-east-1.amazonaws.com/mydockerrepo:latest\n```\n\nWe see that our action steps have been successfully completed:\n\n![image](\u003c/readme-images/1%20(6).png\u003e)\n\nAt the end of our Image Build process, we come to the repo we opened on ECR to see if our push to ECR was successful:\n\n![image](\u003c/readme-images/1%20(7).png\u003e)\n\n\u003c!-- # CI/CD with Golang\n\n## 1. Kısım\n\n- GitHub ekosistemi içinde gerçekleştireceğimiz Push işlemiyle birlikte CI/CD sürecini tetiklemek istediğimiz için kaynak kodu kendi repomuza pushladık.\n\n- Push commiti ile birlikte süreci tetikleme işlemini başlatmak için GitHub’ın sunduğu Pipeline as Code aracı olan GitHub Actions’ı kullandık.\n\n- Docker build işleminin tetikleme ile birlikte gerçekleşmesi ve versiyon numarasının verilmesi için script yazıldı.\n\n- Docker imajlarımızı build aldıktan sonra push’layacağımız ortam olan Docker Hub Registry’nin kullanıcı adı ve şifresi GitHub Repo Ayarları içinde secrets olarak tanımlandı ve GitHub Actions pipeline’ı içinde ortam değişkeni olarak kullanıldı.\n\n- Jenkins pipeline’ımızı tetiklemek için server’a ait webhook linkine istek göndermek amacıyla GitHub Actions pipeline’ımızın sonuna curl komutu ve Jenkins’e de tanımladığımız token’ımızı ekliyoruz.\n\n  - Not: Token GitHub repo ayarlarından secretlar içerisinde ortam değişkeni olarak tanımlandı.\n\nJenkins pipeline’ımızda öncelikle çalışan konteynırı durdurup siliyoruz ve eski imajları temizliyoruz. Ardından güncel tag numarası ile belirlediğimiz İmajı indirip konteynır olarak çalıştırıyoruz.\n\nDocker run komutu içinde port numarası olarak 80’i veriyoruz ki 8080’de çalışan Jenkins ile Go uygulamamız birbiriyle çakışmasın.\n\nİşlemlerimizin çıktısı şu şekilde karşımıza geliyor:\n\nBuild aldıktan sonra Docker Hub’a pushladığımız imajımız:\n\n## 2. Kısım\n\nCodeBuild üzerinde işlem yapmaya başlamadan önce ECR’a ulaşması için ve işlem sonrası logların detaylı olarak incelenebilmesi için bazı yetkiler veriyoruz:\n\nCodeBuild üzerinde GitHub ile oturum açarak repomuzu seçtik. Sonrasında build spec dosyasını ECR ayarlarından aldığımız linklerle düzenliyoruz:\n\nİşlem adımlarımızın başarıyla tamamlandığını görüyoruz:\n\nImage Build işlemimiz sonunda ECR’a push aktivitemiz başarılı olmuş mu, bunu görmek için ECR üzerinde açtığımız repoya geliyoruz: --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevenes%2Fcontainerization-dummy-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevenes%2Fcontainerization-dummy-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevenes%2Fcontainerization-dummy-go/lists"}