Software

DevOps and CI/CD Pipeline Setup: A Practical Getting Started Guide

Marta Teknoloji•March 25, 2025•10 min read

DevOps is a culture and set of practices that brings software development (Dev) and operations (Ops) teams together so that software reaches customers faster, more reliably and continuously. CI/CD (Continuous Integration / Continuous Delivery) is the technical backbone of this culture. In this guide, we explain step by step how to set up a CI/CD pipeline from scratch.

What Is CI/CD?

Continuous Integration (CI)

Developers merge their code into the main branch several times a day, and automated tests run on every merge. The aim: to catch errors early and prevent integration problems.

Continuous Delivery (CD)

Code that passes the tests is automatically deployed to the staging environment and can be taken to production with a single click. Continuous Deployment, on the other hand, fully automates the entire process through to production.

Required Tools

  • Source code management: Git (GitHub, GitLab or Bitbucket)
  • CI/CD tool: GitHub Actions, GitLab CI, Jenkins or CircleCI
  • Containerisation: Docker — packages the application together with its runtime environment
  • Container registry: Docker Hub, GitHub Container Registry or Harbor
  • Orchestration: Kubernetes (K8s) — scales and manages containers
  • Infrastructure as code: Terraform or Pulumi — defines infrastructure as code

Step 1: Creating a Dockerfile

Create a Dockerfile to package your application as a container. Minimise the image size with a multi-stage build. For example, for a Next.js application: node_modules and compilation in the build stage, and only production files in the runner stage. This approach reduces the image size by 60-70%.

Step 2: GitHub Actions Pipeline

Create a .github/workflows/ci.yml file in the repository. A basic pipeline consists of the following steps:

  • Trigger: Trigger on a push to the main and develop branches or when a PR is opened
  • Checkout: Pull the code
  • Setup: Set up the Node.js, Python or Java environment
  • Install: Install dependencies (npm ci, pip install)
  • Lint: Code quality check (ESLint, Prettier)
  • Test: Run unit and integration tests
  • Build: Create the Docker image
  • Push: Send the image to the container registry
  • Deploy: Deploy to Kubernetes or the staging environment

Step 3: Test Automation

The most valuable part of a CI pipeline is automated tests:

  • Unit tests: Jest, Vitest, pytest — verify that each function works correctly
  • Integration tests: Test that API endpoints communicate correctly with the database and external services
  • E2E tests: Playwright or Cypress — simulate user scenarios in the browser
  • Security scanning: Dependency and code security scanning with OWASP ZAP or Snyk
  • Coverage: Aim for a minimum of 80% test coverage, and block PRs if they reduce coverage

Step 4: Kubernetes Deployment

To deploy the image that has passed the tests and been built to Kubernetes:

  • Deployment manifest: replicas, resource limits, liveness/readiness probe definitions
  • Service: Service definition that exposes Pods on the network (ClusterIP, LoadBalancer)
  • Ingress: Domain-based traffic routing (nginx-ingress or Traefik)
  • Helm chart: Managing all Kubernetes resources as a single package, with environment-specific values files

As a deployment strategy, you can opt for Rolling Update (zero downtime) or Canary (the new version goes to a small percentage, with a gradual increase if there are no problems).

Step 5: Monitoring and Alerting

The work does not end once the pipeline has deployed — the application needs to be monitored:

  • Metrics: Collecting CPU, memory, request count and latency metrics with Prometheus
  • Dashboard: Creating visual dashboards with Grafana
  • Log management: Centralised log collection with Loki or ELK (Elasticsearch, Logstash, Kibana)
  • Alerting: Slack/e-mail notification when certain thresholds are exceeded
  • Error tracking: Real-time monitoring of application errors with Sentry

Best Practices

  • Create a separate preview environment for every PR (Vercel, Netlify or a K8s namespace)
  • Use GitHub Secrets, HashiCorp Vault or AWS Secrets Manager for secrets management
  • Try to keep pipeline duration under 10 minutes — speed it up with parallel testing and caching
  • Practise trunk-based development — avoid long-lived feature branches
  • Include database migrations in the CI pipeline
  • Have a rollback plan — you should be able to return to the previous version with a single command

Conclusion

A CI/CD pipeline is indispensable to modern software development. Although it takes time at first setup, in the long run it pays back many times over in terms of speed, reliability and quality. At Marta Teknoloji, we provide services in CI/CD pipeline setup based on GitHub Actions, GitLab CI, Docker and Kubernetes, automation of existing processes and DevOps consultancy.

#DevOps#CI/CD#GitHub Actions#Docker#Kubernetes#otomasyon

Want to learn more?

Contact us for information about our cybersecurity, software, and infrastructure services.

Contact Us→