diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 54e4075d4918c0c763a96be6d2f763fd22cabfb5..1f41ded4490bbd3f07aa904ee9996465c9406896 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,10 +7,6 @@ stages: variables: DOCKER_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA - # Replace 'path/to/project:agent-name' with your actual agent's path and name - KUBE_CONTEXT: "my-group/banguardian-project:my-k3s-agent" - IMAGE_TAG_BRANCH: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME - IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest @@ -46,21 +42,22 @@ build-server: # 3. Build & Push Docker Image build-docker: stage: package - needs: [build-server] -# image: docker:24.0.5 -# services: -# - docker:24.0.5-dind - image: docker:20-dind + needs: [ build-server ] + # image: docker:24.0.5 + # services: + # - docker:24.0.5-dind + image: docker:24 + services: + - name: docker:24-dind + alias: docker + command: [ "--tls=false" ] + variables: DOCKER_HOST: tcp://docker:2375 DOCKER_DRIVER: overlay2 DOCKER_TLS_CERTDIR: "" # DOCKER_TLS_VERIFY: "" # DOCKER_TLS: "" - services: - - name: docker:20-dind - alias: docker - command: [ "--tls=false" ] before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY @@ -69,15 +66,13 @@ build-docker: - hostname - nslookup gitlab.erpratyush.me - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - - docker build -t $IMAGE_TAG_BRANCH -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST . + - docker build -t $DOCKER_IMAGE -t $IMAGE_TAG_LATEST . - docker image ls - docker push --all-tags $CI_REGISTRY_IMAGE - - # Deployment Template .deploy_template: - needs: [build-docker] + needs: [ build-docker ] image: name: alpine/k8s:1.28.3 # Includes kubectl and envsubst before_script: @@ -85,6 +80,7 @@ build-docker: - kubectl create namespace $K8S_NAMESPACE --dry-run=client -o yaml | kubectl apply -f - script: # Safely inject the image tag and apply to the specific namespace + - envsubst < k3s/deployment.yaml - envsubst < k3s/deployment.yaml | kubectl apply -n $K8S_NAMESPACE -f - # 4. Deploy to Development (Automatic) @@ -93,6 +89,7 @@ deploy-dev: stage: deploy-dev variables: K8S_NAMESPACE: banguardian-dev + INGRESS_HOST: banguardian.pkay-playground-2026.online environment: name: development @@ -102,6 +99,7 @@ deploy-prod: stage: deploy-prod variables: K8S_NAMESPACE: banguardian-prod + INGRESS_HOST: banguardian.pkay.xyz environment: name: production when: manual diff --git a/k3s/deployment.yaml b/k3s/deployment.yaml index 44b534dba1ad6b2888a4ca9a192913d73fa8556b..689beda0c6bc6e817dfc1ed84e6dc09be643166a 100644 --- a/k3s/deployment.yaml +++ b/k3s/deployment.yaml @@ -19,7 +19,7 @@ spec: - name: banguardian-app # This variable is injected by envsubst in your CI/CD pipeline image: ${DOCKER_IMAGE} - imagePullPolicy: Always + imagePullPolicy: IfNotPresent ports: - containerPort: 8080 resources: @@ -30,18 +30,18 @@ spec: memory: "256Mi" cpu: "100m" # Health checks for Spring Boot - livenessProbe: - httpGet: - path: /actuator/health/liveness - port: 8080 - initialDelaySeconds: 30 - periodSeconds: 10 - readinessProbe: - httpGet: - path: /actuator/health/readiness - port: 8080 - initialDelaySeconds: 30 - periodSeconds: 10 +# livenessProbe: +# httpGet: +# path: /actuator/health/liveness +# port: 8080 +# initialDelaySeconds: 30 +# periodSeconds: 10 +# readinessProbe: +# httpGet: +# path: /actuator/health/readiness +# port: 8080 +# initialDelaySeconds: 30 +# periodSeconds: 10 --- # 2. Service @@ -66,12 +66,12 @@ kind: Ingress metadata: name: banguardian-ingress annotations: - kubernetes.io/ingress.class: "nginx" # Optional: Increases max upload size (useful for Spring Boot file uploads) nginx.ingress.kubernetes.io/proxy-body-size: "50m" spec: + ingressClassName: nginx rules: - - host: "app.local.xyz" + - host: ${INGRESS_HOST} http: paths: - path: /