From f63093cd841758f2ddf43e6200c608ad662310d7 Mon Sep 17 00:00:00 2001 From: WahyuriN Date: Fri, 20 Oct 2023 08:19:02 +0700 Subject: [PATCH 01/10] first commit-tambah circleci dan build push --- .circleci/config.yml | 26 ++++++++++++++++++++++++++ build_push_image_karsajobs.sh | 11 +++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .circleci/config.yml create mode 100644 build_push_image_karsajobs.sh diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..1d0c1e0a5 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,26 @@ +version: 2.1 + +jobs: + lint-dockerfile: + docker: + - image: hadolint/hadolint:latest + steps: + - checkout + - run: hadolint Dockerfile + + test-app: + docker: + - image: golang:latest + steps: + - checkout + - run: go test -v -short --count=1 $(go list ./...) + + build-app-karsajobs: + docker: + - image: docker:latest + steps: + - checkout + - run: go build -o karsajobs + - run: docker build -t ghcr.io/wahyurin/a433-microservices/karsajobs:latest . + - run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ghcr.io + - run: docker push ghcr.io/wahyurin/a433-microservices/karsajobs:latest diff --git a/build_push_image_karsajobs.sh b/build_push_image_karsajobs.sh new file mode 100644 index 000000000..deebdb8ab --- /dev/null +++ b/build_push_image_karsajobs.sh @@ -0,0 +1,11 @@ +# Membuat Docker image dari Dockerfile +docker build -t ghcr.io/wahyurin/a433-microservices/karsajobs:latest . + +# Melihat daftar image di lokal +docker images + +# Login ke GitHub Container Registry +echo $TOKEN | docker login ghcr.io -u WahyuriN --password-stdin + +# Mengunggah image ke GitHub Container Registry +docker push ghcr.io/wahyurin/a433-microservices/karsajobs:latest \ No newline at end of file From 2aaa356573c3a00807b47cf08ea8f738c26a07c1 Mon Sep 17 00:00:00 2001 From: WahyuriN Date: Fri, 20 Oct 2023 08:30:43 +0700 Subject: [PATCH 02/10] first commit-tambah circleci-tambah workflow --- .circleci/config.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1d0c1e0a5..d6dd6c4e9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,3 +24,15 @@ jobs: - run: docker build -t ghcr.io/wahyurin/a433-microservices/karsajobs:latest . - run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ghcr.io - run: docker push ghcr.io/wahyurin/a433-microservices/karsajobs:latest + +workflows: + version: 2 + karsajobs-ci: + jobs: + - lint-dockerfile + - test-app: + requires: + - lint-dockerfile + - build-app-karsajobs: + requires: + - test-app From df8d31787a5591016052c69240644842637cf792 Mon Sep 17 00:00:00 2001 From: WahyuriN Date: Fri, 20 Oct 2023 09:29:55 +0700 Subject: [PATCH 03/10] first commit-tambah circleci-export pw docker hub --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d6dd6c4e9..e696046bd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ jobs: workflows: version: 2 - karsajobs-ci: + karsajobs: jobs: - lint-dockerfile - test-app: From 96412d5ef4ea3e645ab6a6528453c6cf68c7c72d Mon Sep 17 00:00:00 2001 From: WahyuriN Date: Fri, 20 Oct 2023 13:20:46 +0700 Subject: [PATCH 04/10] ganti echo github username ke token --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e696046bd..7ca486389 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,7 +22,7 @@ jobs: - checkout - run: go build -o karsajobs - run: docker build -t ghcr.io/wahyurin/a433-microservices/karsajobs:latest . - - run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ghcr.io + - run: echo $TOKEN | docker login ghcr.io -u WahyuriN --password-stdin - run: docker push ghcr.io/wahyurin/a433-microservices/karsajobs:latest workflows: From eedcd07e350c35bc9a665328669a84e0b15e9b22 Mon Sep 17 00:00:00 2001 From: WahyuriN Date: Fri, 20 Oct 2023 13:29:57 +0700 Subject: [PATCH 05/10] tambah ./Dockerfile --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7ca486389..204cc972a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ jobs: - image: hadolint/hadolint:latest steps: - checkout - - run: hadolint Dockerfile + - run: hadolint ./Dockerfile test-app: docker: From f8f3abc7e1da821b51e4883aecdebe2d3385f1a3 Mon Sep 17 00:00:00 2001 From: WahyuriN Date: Fri, 20 Oct 2023 13:32:51 +0700 Subject: [PATCH 06/10] tambah ./Dockerfile --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 204cc972a..fb96f10cc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ jobs: - image: hadolint/hadolint:latest steps: - checkout - - run: hadolint ./Dockerfile + - run: hadolint ./karsajobs/Dockerfile test-app: docker: From 532b252f7e33b56fc1801cd188a5372cf0745683 Mon Sep 17 00:00:00 2001 From: WahyuriN Date: Fri, 20 Oct 2023 13:35:23 +0700 Subject: [PATCH 07/10] tambah hadolint:latest pada test --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fb96f10cc..9a38d1b28 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ jobs: test-app: docker: - - image: golang:latest + - image: hadolint:latest steps: - checkout - run: go test -v -short --count=1 $(go list ./...) From ce845798ca9d26b408950e72b455f39d6cd3686c Mon Sep 17 00:00:00 2001 From: WahyuriN Date: Fri, 20 Oct 2023 13:36:43 +0700 Subject: [PATCH 08/10] golang 1.17 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9a38d1b28..0611d9480 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ jobs: test-app: docker: - - image: hadolint:latest + - image: golang:1.17 steps: - checkout - run: go test -v -short --count=1 $(go list ./...) From d856b5507efea29cec4f8699d920c49f3c492954 Mon Sep 17 00:00:00 2001 From: WahyuriN Date: Fri, 20 Oct 2023 13:43:39 +0700 Subject: [PATCH 09/10] golang 1.17 --- .circleci/config.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0611d9480..812793262 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,24 +6,31 @@ jobs: - image: hadolint/hadolint:latest steps: - checkout - - run: hadolint ./karsajobs/Dockerfile + - run: + name: Lint Dockerfile + command: hadolint ./karsajobs/Dockerfile test-app: docker: - image: golang:1.17 steps: - checkout - - run: go test -v -short --count=1 $(go list ./...) + - run: + name: Run Unit Tests + command: go test -v -short --count=1 $(go list ./...) build-app-karsajobs: docker: - image: docker:latest steps: - checkout - - run: go build -o karsajobs - - run: docker build -t ghcr.io/wahyurin/a433-microservices/karsajobs:latest . - - run: echo $TOKEN | docker login ghcr.io -u WahyuriN --password-stdin - - run: docker push ghcr.io/wahyurin/a433-microservices/karsajobs:latest + - run: + name: Build and Push Docker Image + command: | + go build -o karsajobs + docker build -t ghcr.io/wahyurin/a433-microservices/karsajobs:latest . + echo "$TOKEN" | docker login ghcr.io -u "WahyuriN" --password-stdin + docker push ghcr.io/wahyurin/a433-microservices/karsajobs:latest workflows: version: 2 From 28662140fbbe23b2a343b3c6c910c7591ed702c1 Mon Sep 17 00:00:00 2001 From: WahyuriN Date: Fri, 20 Oct 2023 14:28:06 +0700 Subject: [PATCH 10/10] gol --- .circleci/config.yml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 812793262..5777b04bf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,31 +6,24 @@ jobs: - image: hadolint/hadolint:latest steps: - checkout - - run: - name: Lint Dockerfile - command: hadolint ./karsajobs/Dockerfile + - run: hadolint Dockerfile test-app: docker: - - image: golang:1.17 + - image: golang:latest steps: - checkout - - run: - name: Run Unit Tests - command: go test -v -short --count=1 $(go list ./...) + - run: go test -v -short --count=1 $(go list ./...) build-app-karsajobs: docker: - image: docker:latest steps: - checkout - - run: - name: Build and Push Docker Image - command: | - go build -o karsajobs - docker build -t ghcr.io/wahyurin/a433-microservices/karsajobs:latest . - echo "$TOKEN" | docker login ghcr.io -u "WahyuriN" --password-stdin - docker push ghcr.io/wahyurin/a433-microservices/karsajobs:latest + - run: go build -o karsajobs + - run: docker build -t yourdockerusername/karsajobs:latest . + - run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + - run: docker push yourdockerusername/karsajobs:latest workflows: version: 2