From bd6ca5c89f3a6c66cc45d83f4daa57a6c2a1ef73 Mon Sep 17 00:00:00 2001 From: Sadasidral <146716206+Sadasidral@users.noreply.github.com> Date: Thu, 12 Oct 2023 22:46:17 +0530 Subject: [PATCH 1/5] creating file: .dockerignore --- .dockerignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c81336f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +Dockerfile +charts/ +target/ +work/ +.git/ From 034b2a6039a2b1df63e2b27435e3c981829f19c6 Mon Sep 17 00:00:00 2001 From: Sadasidral <146716206+Sadasidral@users.noreply.github.com> Date: Thu, 12 Oct 2023 22:46:18 +0530 Subject: [PATCH 2/5] creating file: Dockerfile --- Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b6081f5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM maven:3-eclipse-temurin-8 as BUILD + +COPY . /usr/src/app +RUN mvn --batch-mode -f /usr/src/app/pom.xml clean package + +FROM eclipse-temurin:8-jre +ENV PORT 8080 +EXPOSE 8080 +COPY --from=BUILD /usr/src/app/target /opt/target +WORKDIR /opt/target + +CMD ["/bin/bash", "-c", "find -type f -name '*-SNAPSHOT.jar' | xargs java -jar"] From 036151b4ad3eaf286f3bb1ad199f9175e4469535 Mon Sep 17 00:00:00 2001 From: Sadasidral <146716206+Sadasidral@users.noreply.github.com> Date: Thu, 12 Oct 2023 22:46:18 +0530 Subject: [PATCH 3/5] creating file: manifests/deployment.yaml --- manifests/deployment.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 manifests/deployment.yaml diff --git a/manifests/deployment.yaml b/manifests/deployment.yaml new file mode 100644 index 0000000..938118a --- /dev/null +++ b/manifests/deployment.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mydotnetapp + labels: + app: mydotnetapp + namespace: namespace-workflow-1697130820079 +spec: + replicas: 1 + selector: + matchLabels: + app: mydotnetapp + template: + metadata: + labels: + app: mydotnetapp + spec: + containers: + - name: mydotnetapp + image: acrworkflow1697130820079.azurecr.io/image-workflow-1697130820079:latest + ports: + - containerPort: 8080 \ No newline at end of file From f5558cb8451db1f4852996599e25102ac3e4f481 Mon Sep 17 00:00:00 2001 From: Sadasidral <146716206+Sadasidral@users.noreply.github.com> Date: Thu, 12 Oct 2023 22:46:19 +0530 Subject: [PATCH 4/5] creating file: manifests/service.yaml --- manifests/service.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 manifests/service.yaml diff --git a/manifests/service.yaml b/manifests/service.yaml new file mode 100644 index 0000000..c343d78 --- /dev/null +++ b/manifests/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: mydotnetapp + namespace: namespace-workflow-1697130820079 +spec: + type: LoadBalancer + selector: + app: mydotnetapp + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 \ No newline at end of file From b8d24a66f370cf0b247e7ee278854e6b67c63ff5 Mon Sep 17 00:00:00 2001 From: Sadasidral <146716206+Sadasidral@users.noreply.github.com> Date: Thu, 12 Oct 2023 22:46:19 +0530 Subject: [PATCH 5/5] creating file: .github/workflows/mydotnetapp.yaml --- .github/workflows/mydotnetapp.yaml | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/mydotnetapp.yaml diff --git a/.github/workflows/mydotnetapp.yaml b/.github/workflows/mydotnetapp.yaml new file mode 100644 index 0000000..d06fd8d --- /dev/null +++ b/.github/workflows/mydotnetapp.yaml @@ -0,0 +1,65 @@ +name: mydotnetapp +"on": + push: + branches: + - master + workflow_dispatch: {} +env: + ACR_RESOURCE_GROUP: mycyient-rg + AZURE_CONTAINER_REGISTRY: acrworkflow1697130820079 + CLUSTER_NAME: Thefirstcluster + CLUSTER_RESOURCE_GROUP: mycyient-rg + CONTAINER_NAME: image-workflow-1697130820079 + DEPLOYMENT_MANIFEST_PATH: | + manifests/deployment.yaml + manifests/service.yaml +jobs: + buildImage: + permissions: + contents: read + id-token: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 + name: Azure login + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + - name: Build and push image to ACR + run: az acr build --image ${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.ACR_RESOURCE_GROUP }} -f Dockerfile ./ + deploy: + permissions: + actions: read + contents: read + id-token: write + runs-on: ubuntu-latest + needs: + - buildImage + steps: + - uses: actions/checkout@v3 + - uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 + name: Azure login + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + - uses: azure/use-kubelogin@v1 + name: Set up kubelogin for non-interactive login + with: + kubelogin-version: v0.0.25 + - uses: azure/aks-set-context@v3 + name: Get K8s context + with: + admin: "false" + cluster-name: ${{ env.CLUSTER_NAME }} + resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} + use-kubelogin: "true" + - uses: Azure/k8s-deploy@v4 + name: Deploys application + with: + action: deploy + images: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} + manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }} + namespace: namespace-workflow-1697130820079