commit e4f9773a58c3ccea6c7db93998292b615c9d1d62 Author: joseph Date: Wed Nov 18 00:36:42 2026 +0300 initial: demo app + pipeline + k8s manifests diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..5d74f02 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,35 @@ +name: build-scan-deploy +on: + push: + branches: [main] + paths-ignore: ["k8s/**"] + workflow_dispatch: +env: + REGISTRY: 192.168.0.43:3000 + IMAGE: 192.168.0.43:3000/joseph/hello-devops +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: {token: "${{ secrets.REGISTRY_TOKEN }}"} + - name: Install docker CLI + run: curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz | tar xz --strip-components=1 -C /usr/local/bin docker/docker + - name: Lint Dockerfile + run: docker run --rm -i hadolint/hadolint < Dockerfile || true + - name: Build image + run: | + TAG=${GITHUB_SHA::7} + echo "TAG=$TAG" >> $GITHUB_ENV + docker build --build-arg VERSION=$TAG -t $IMAGE:$TAG -t $IMAGE:latest . + - name: Scan with Trivy (fail on CRITICAL) + run: docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy:latest image --severity CRITICAL --exit-code 1 --ignore-unfixed $IMAGE:$TAG + - name: Push to Gitea registry + run: | + echo "${{ secrets.REGISTRY_TOKEN }}" | docker login $REGISTRY -u joseph --password-stdin + docker push $IMAGE:$TAG && docker push $IMAGE:latest + - name: GitOps - bump image tag + run: | + sed -i "s#image: .*hello-devops:.*#image: $IMAGE:$TAG#" k8s/app.yaml + git config user.name "gitea-actions"; git config user.email "ci@lab.local" + git commit -am "deploy: hello-devops $TAG [skip ci]" && git push diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0c1b423 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM nginx:1.29-alpine +ARG VERSION=dev +COPY index.html /usr/share/nginx/html/index.html +RUN sed -i "s/__VERSION__/${VERSION}/" /usr/share/nginx/html/index.html +EXPOSE 80 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e7f3632 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# hello-devops +Demo GitOps pipeline for the DevOps lab. +Push to `main` โ†’ Gitea Actions builds + Trivy-scans the image โ†’ pushes to the Gitea registry โ†’ bumps the tag in `k8s/app.yaml` โ†’ Argo CD syncs it to k3s. +Open: http://192.168.0.41/ (Traefik ingress) diff --git a/index.html b/index.html new file mode 100644 index 0000000..35ad5d9 --- /dev/null +++ b/index.html @@ -0,0 +1,3 @@ +Hello DevOps + +

Hello from the DevOps lab ๐Ÿš€

Built by Gitea Actions ยท scanned by Trivy ยท deployed by Argo CD on k3s

Version: __VERSION__

diff --git a/k8s/app.yaml b/k8s/app.yaml new file mode 100644 index 0000000..ec6c36a --- /dev/null +++ b/k8s/app.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: {name: hello-devops, labels: {app: hello-devops}} +spec: + replicas: 2 + selector: {matchLabels: {app: hello-devops}} + template: + metadata: {labels: {app: hello-devops}} + spec: + containers: + - name: web + image: 192.168.0.43:3000/joseph/hello-devops:initial + ports: [{containerPort: 80}] + resources: {requests: {cpu: 10m, memory: 16Mi}, limits: {memory: 64Mi}} + readinessProbe: {httpGet: {path: /, port: 80}} +--- +apiVersion: v1 +kind: Service +metadata: {name: hello-devops} +spec: {selector: {app: hello-devops}, ports: [{port: 80, targetPort: 80}]} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: {name: hello-devops} +spec: + ingressClassName: traefik + rules: + - http: + paths: [{path: /, pathType: Prefix, backend: {service: {name: hello-devops, port: {number: 80}}}}]