Zum Hauptinhalt springen

πŸš€ Conduit CI/CD Deployment

This page documents how I configured my very first cloud server instance in the Developer Akademie DevSecOps Course.

TOC​

team-collaboration/version-control/githubGithub Tip

πŸš€ Conduit CI/CD Deployment

This repository contains everything you need to deploy Conduit (RealWorld Example App) with a Django backend and an Angular frontend using Docker Compose and GitHub Actions.


πŸ“Œ Features​

  • βœ… Automated CI/CD pipeline with GitHub Actions
  • βœ… Docker images built and pushed to GitHub Container Registry (GHCR)
  • βœ… Automatic deployment to your own server via SSH
  • βœ… Django backend + Angular frontend fully containerized

πŸ”§ Prerequisites​

Before you start, make sure you have:

  • A Linux server with Docker & Docker Compose installed
  • A GitHub repository fork of this project
  • GitHub Secrets configured (see below)

βš™οΈ Setup​

1️⃣ Clone the repository​

git clone https://github.com/Gosia2024/conduit-deployment.git
cd conduit-deployment

2️⃣ Configure .env

Create a .env file with your settings (example):

SECRET_KEY=your-django-secret DEBUG=False BACKEND_EXTERNAL_PORT=8000 FRONTEND_EXTERNAL_PORT=80 DJANGO_SUPERUSER_USERNAME=admin DJANGO_SUPERUSER_PASSWORD=admin123 DJANGO_SUPERUSER_EMAIL=admin@example.com ALLOWED_HOSTS=127.0.0.1,localhost,your-server-ip CORS_ORIGIN_WHITELIST=http://localhost,http://your-server-ip

3️⃣ Deploy with Docker Compose

Run:

docker compose up -d --build

πŸ€– CI/CD with GitHub Actions

The workflow in .github/workflows/deploy.yml automates deployment:

1.Build job

  • Runs on push to branch ci-cd-ghcr-deployment

  • Builds & pushes Docker images (frontend + backend) to GHCR

  • Uploads .env and compose.yaml as artifacts

2.Remote Deploy job

Copies config files to your server via SCP

Connects via SSH

Runs:

docker compose down --remove-orphans
docker system prune -af
docker compose up -d

πŸ”‘ Required GitHub Secrets

Add these secrets in your repository β†’ Settings β†’ Secrets and variables β†’ Actions:

  • SECRET_KEY, DEBUG

  • BACKEND_EXTERNAL_PORT, FRONTEND_EXTERNAL_PORT

  • DJANGO_SUPERUSER_USERNAME, DJANGO_SUPERUSER_PASSWORD, DJANGO_SUPERUSER_EMAIL

  • ALLOWED_HOSTS, CORS_ORIGIN_WHITELIST

  • API_URL (frontend β†’ backend URL)

  • SERVER_HOST, SERVER_USER, SERVER_SSH_KEY, DEPLOY_DIR

βœ… Result

Push to ci-cd-ghcr-deployment β†’ πŸš€ automatic deployment

Django backend + Angular frontend running on your server

No manual rebuilds needed

πŸ–ΌοΈ Architecture Developer β†’ GitHub β†’ GitHub Actions β†’ GHCR β†’ Server β†’ Docker Compose β†’ Backend + Frontend

πŸ§ͺ Test

Check if backend is working:

curl http://<server-ip>:8000/api/

Expected response:

{"articles": "http://<server-ip>:8000/api/articles"}

🌍 Frontend

http://<your-server-ip>

πŸŽ‰ That’s it! You now have Conduit running with a full CI/CD pipeline.