Files
Compose-Files/Backups/Miker/Learning CI-CD/Handle Local Storage Path Differences.md
2026-07-20 09:23:17 -04:00

2.7 KiB

tags
tags
GIT
CI/CD
CI-CD

In a homelab, your production server usually has unique storage mounts (like /mnt/user/appdata/nginx or /mnt/SSD/data), but your Gitea runner is isolated and lacks access to those specific paths. If you try to run a verification command like docker compose config inside the runner, it will often fail or generate unwanted folders.

Here are the two cleanest ways to solve this:

Solution 1: Use Environment Variables for Paths (Recommended)

Instead of hardcoding absolute paths into your docker-compose.yml, replace them with environment variables.

Update your docker-compose.yml to use a variable: services: nginx: image: nginx:alpine volumes: # Use a variable with a safe local fallback directory for testing - ${DATA_PATH_NGINX:-./nginx_test_data}:/etc/nginx

Map the variables differently in your workflow steps:
When validating on the runner, let it fall back to the safe relative directory. When deploying to production, explicitly inject your real server paths.

  # Step A: Validate (Uses the relative path fallback automatically)
  - name: Verify Compose File Validity
    run: docker compose config

  # Step B: Deploy (Injects your actual live server paths)
  - name: Deploy Containers to Live Server
    env:
      DATA_PATH_NGINX: "/mnt/user/appdata/nginx" # Real production path
    run: |
      docker context use homelab-target
      docker compose --project-directory . up -d --remove-orphans

Solution 2: Store Production Paths in Gitea Secrets

If you want to keep your specific homelab storage architecture hidden from your Git repository code entirely, you can save the base storage directory directly as a Gitea Secret (e.g., BASE_DATA_PATH = /mnt/user/appdata).

  1. Reference the secret variable in your docker-compose.yml:

     services:
       plex:
         image: plexinc/pms
         volumes:
           - ${BASE_DATA_PATH}/plex:/config
    

Provide a dummy path during validation, and the real secret during deployment:

  - name: Verify Compose File Validity
    env:
      BASE_DATA_PATH: "./test_env" # Dummy folder for the runner
    run: docker compose config

  - name: Deploy Containers to Live Server
    env:
      BASE_DATA_PATH: ${{ secrets.BASE_DATA_PATH }} # Real server path
    run: |
      docker context use homelab-target
      docker compose --project-directory . up -d --remove-orphans

💡 Putting It Together

By combining these two methods, your workflow will safely parse your configuration using fake/relative folders on the runner service, seamlessly deploy using your live production hard drive arrays over SSH, and instantly ping your phone via Discord or Telegram with the results.