diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 9345c12..b019f1d 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -13,6 +13,9 @@ on: jobs: test: runs-on: docker + # Set environment variable to connect to docker-in-docker service (for consistency) + env: + DOCKER_HOST: tcp://docker-in-docker:2375 steps: - uses: actions/checkout@v4 @@ -34,9 +37,18 @@ jobs: needs: test runs-on: docker if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + # Set environment variable to connect to docker-in-docker service + env: + DOCKER_HOST: tcp://docker-in-docker:2375 steps: - uses: actions/checkout@v4 + # Verify Docker connection to docker-in-docker service + - name: Verify Docker connection + run: | + echo "Using Docker host: $DOCKER_HOST" + docker version || true + - name: Docker info run: | docker info diff --git a/README_DOCKER.md b/README_DOCKER.md index a641079..3458228 100644 --- a/README_DOCKER.md +++ b/README_DOCKER.md @@ -155,6 +155,23 @@ This project includes a CI/CD pipeline configured in `.forgejo/workflows/build.y - `latest` (for the most recent build) 5. The Docker image is pushed to the Forgejo Container Registry at `${FORGEJO_REGISTRY}/${FORGEJO_USERNAME}/podcastrr`. +### Docker-in-Docker for CI/CD + +The CI/CD pipeline uses Docker-in-Docker (DinD) provided by the Forgejo runner to build and push Docker images. This approach has several advantages: + +1. **Isolation**: The Docker daemon runs in its own container, providing better isolation. +2. **Security**: Reduces the attack surface by not requiring privileged access to the host. +3. **Consistency**: Ensures a consistent Docker environment for all builds. + +The CI/CD workflow connects to the Docker-in-Docker service using the `DOCKER_HOST` environment variable: + +```yaml +env: + DOCKER_HOST: tcp://docker-in-docker:2375 +``` + +Note: The Docker-in-Docker service is provided by the Forgejo runner infrastructure and does not need to be configured in your docker-compose.yml file. + ### Using the published Docker image To use the published Docker image in your deployment: