diff --git a/.gitea/docker-compose.template b/.gitea/docker-compose.template new file mode 100644 index 0000000..75796bb --- /dev/null +++ b/.gitea/docker-compose.template @@ -0,0 +1,23 @@ +services: + __REPO_NAME__: + image: __FULL_URL__:__BUILD_TAG__ + container_name: __REPO_NAME__ + hostname: ${SAMBA_HOSTNAME} + domainname: ${SAMBA_DOMAIN} + restart: unless-stopped + environment: +__ENV_BLOCK__ + volumes: + - ./config:/etc/samba + - ./private:/var/lib/samba + - ./state/log:/var/log/samba + - ./state/run:/run/samba + networks: + samba-ad-lan: + ipv4_address: ${SAMBA_IP} + stop_grace_period: 60s + +networks: + samba-ad-lan: + external: true + \ No newline at end of file diff --git a/.gitea/rm.template b/.gitea/rm.template new file mode 100644 index 0000000..d0f31f5 --- /dev/null +++ b/.gitea/rm.template @@ -0,0 +1,55 @@ +# __REPO_NAME__ +__DESCRIPTION__ + + + Build Status + + + Gitea Repository + + +This repository is built and pushed automatically. + +__DOCKERHUB_LINK__ + +### 🏗️ Platform Support +| Architecture | Status | Base Image | Build Date | +| :--- | :--- | :--- | :--- | +| x86_64 (amd64) | ✅ Active | __BASE_IMAGE__ | __CURRENT_DATE__ | +| aarch64 (arm64) | __ARM_STATUS__ | __BASE_IMAGE__ | __CURRENT_DATE__ | + +--- + +## 🐙 Method 1: Docker Compose (Recommended) + +### 🚀 1. Create `docker-compose.yml` +```yaml +__COMPOSE_BLOCK__ +``` +### 🚀 2. Pull & start the container +### Pull or update the image +```bash +docker compose pull +``` +### Start container in background +```bash +docker compose up -d +``` +--- + +## 🐳 Method 2: Standalone Container (Docker Run / CLI) +### 🚀 1. Pull the image manually +```bash +docker pull __FULL_URL__:__BUILD_TAG__ +``` +### 🚀 2. Run the container directly +```bash +__DOCKER_RUN__ +``` + +*Last updated on: __CURRENT_DATE__* + +### 📜 Version History +| Version | Date | Status | +| :--- | :--- | :--- | +__HISTORY_CONTENT__ \ No newline at end of file diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 11e2880..2742ba6 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -235,21 +235,21 @@ jobs: RAW_COMMIT_MSG="${{ gitea.event.head_commit.message }}" COMMIT_MSG=$(echo "$RAW_COMMIT_MSG" | sed 's/\[skip ci\]//g' | tr -d '\r\n' | xargs) - TOKEN="${{ secrets.RUNNER_TOKEN }}" - curl -sSLf -H "Authorization: token $TOKEN" \ - "https://git.pi-farm.de/pi-farm/templates/raw/branch/main/README.template" \ - -o README.template || echo "Warnung: README Template konnte nicht geladen werden" + # Lokale Templates an die vom Skript erwartete Stelle kopieren + if [ -f ".gitea/docker-compose.template" ]; then + cp .gitea/docker-compose.template docker-compose.template + elif [ -f "docker-compose.template" ]; then + echo "Using local docker-compose.template" + else + echo "❌ FEHLER: docker-compose.template nicht gefunden!" + exit 1 + fi - curl -sSLf -H "Authorization: token $TOKEN" \ - "https://git.pi-farm.de/pi-farm/templates/raw/branch/main/docker-compose.template" \ - -o docker-compose.template || echo "Warnung: Compose Template konnte nicht geladen werden" - - for t_file in README.template docker-compose.template; do - if [ -f "$t_file" ] && grep -qi "" "$t_file"; then - echo "❌ FEHLER: $t_file ist eine HTML-Loginseite! Download verworfen." - rm -f "$t_file" - fi - done + if [ -f ".gitea/README.template" ]; then + cp .gitea/README.template README.template + elif [ -f "README.template" ]; then + echo "Using local README.template" + fi NEW_ROW="| **$BUILD_TAG** | $CURRENT_TIME | $COMMIT_MSG ✅ |" if [ -f "VERSION.history" ]; then @@ -262,6 +262,10 @@ jobs: fi HISTORY_CONTENT=$(cat VERSION.history) + export CURRENT_TIME + export HISTORY_CONTENT + export BASE_IMAGE="$BASE_IMAGE" + ENV_BLOCK_CONTENT="" env_vars=$(grep '^ENV_' buildargs.env | grep -v '^#' | tr -d '\r' || true) if [ -n "$env_vars" ]; then @@ -329,48 +333,68 @@ jobs: fi cat << 'EOF' > update_script.py - import os, sys + import os, re - def process(output_file): - if not os.path.exists(output_file.replace('.md', '.template').replace('.yml', '.template')): - return - - template_name = output_file.replace('.md', '.template').replace('.yml', '.template') - with open(template_name, "r", encoding="utf-8") as f: + # 1. docker-compose.yml generieren + env_keys = [ + "SAMBA_REALM", "SAMBA_DOMAIN", "SAMBA_HOSTNAME", + "SAMBA_FQDN", "SAMBA_IP", "SAMBA_NETWORK", + "DNS_FORWARDER", "SAMBA_ADMIN_PASSWORD" + ] + + env_block_lines = [] + for key in env_keys: + line = (" " * 6) + key + ": ${" + key + "}" + env_block_lines.append(line) + + env_block_str = "\n".join(env_block_lines) + + compose_template = ".gitea/docker-compose.template" if os.path.exists(".gitea/docker-compose.template") else "docker-compose.template" + if os.path.exists(compose_template): + with open(compose_template, "r", encoding="utf-8") as f: content = f.read() - content = content.replace("__REPO_NAME__", os.environ.get("REPO_PURE", "")) - content = content.replace("__FULL_URL__", os.environ.get("FULL_URL", "")) - content = content.replace("__BUILD_TAG__", os.environ.get("BUILD_TAG", "")) - content = content.replace("__BASE_IMAGE__", os.environ.get("BASE_IMAGE", "")) - content = content.replace("__ARM_STATUS__", os.environ.get("ARM_STATUS", "")) - content = content.replace("__CURRENT_DATE__", os.environ.get("CURRENT_TIME", "")) - content = content.replace("__HISTORY_CONTENT__", os.environ.get("HISTORY_CONTENT", "")) - content = content.replace("__DOCKERHUB_LINK__", os.environ.get("DOCKERHUB_LINK_CONTENT", "")) - content = content.replace("__ENV_BLOCK__", os.environ.get("ENV_BLOCK_CONTENT", "").replace("\\n", "\n")) - content = content.replace("__PORTS_BLOCK__", os.environ.get("PORTS_BLOCK_CONTENT", "").replace("\\n", "\n")) - content = content.replace("__VOL_BLOCK__", os.environ.get("VOL_BLOCK_CONTENT", "").replace("\\n", "\n")) - content = content.replace("__DESCRIPTION__", os.environ.get("DESCRIPTION", "Keine Beschreibung.")) + content = content.replace("__REPO_NAME__", "samba-ad-dc") + content = content.replace("__FULL_URL__", "git.pi-farm.de/pi-farm/samba-ad-dc") + content = content.replace("__BUILD_TAG__", os.environ.get("FINAL_TAG", "trixie")) + content = content.replace("__ENV_BLOCK__", env_block_str) - if "__DOCKER_RUN__" in content and os.path.exists("docker_run_block.txt"): - with open("docker_run_block.txt", "r", encoding="utf-8") as f: - content = content.replace("__DOCKER_RUN__", f.read()) - - if "__COMPOSE_BLOCK__" in content and os.path.exists("docker-compose.yml"): - with open("docker-compose.yml", "r", encoding="utf-8") as f: - content = content.replace("__COMPOSE_BLOCK__", f.read()) - - with open(output_file, "w", encoding="utf-8") as f: + with open("docker-compose.yml", "w", encoding="utf-8") as f: f.write(content) - process("docker-compose.yml") - process("README.md") + # 2. README.md aus rm.template generieren + readme_template = ".gitea/rm.template" if os.path.exists(".gitea/rm.template") else "rm.template" + if os.path.exists(readme_template): + with open(readme_template, "r", encoding="utf-8") as f: + rm_content = f.read() + + description = os.environ.get("DESCRIPTION", "Docker Image for samba-ad-dc") + current_date = os.environ.get("CURRENT_TIME", "") + history_content = os.environ.get("HISTORY_CONTENT", "") + base_image = os.environ.get("BASE_IMAGE", "debian:trixie-slim") + + compose_content = open("docker-compose.yml", "r", encoding="utf-8").read() if os.path.exists("docker-compose.yml") else "" + docker_run_content = open("docker_run_block.txt", "r", encoding="utf-8").read() if os.path.exists("docker_run_block.txt") else "" + + # Alle Platzhalter in der README ersetzen + rm_content = rm_content.replace("__REPO_NAME__", "samba-ad-dc") + rm_content = rm_content.replace("__BUILD_TAG__", os.environ.get("FINAL_TAG", "trixie")) + rm_content = rm_content.replace("__FULL_URL__", "git.pi-farm.de/pi-farm/samba-ad-dc") + rm_content = rm_content.replace("__DESCRIPTION__", description) + rm_content.replace("__BASE_IMAGE__", base_image) # Korrigiert: base_image Variable nutzen + rm_content = rm_content.replace("__BASE_IMAGE__", base_image) + rm_content = rm_content.replace("__ARM_STATUS__", "✅ Active" if os.path.exists("Dockerfile.aarch64") else "❌ Not supported") + rm_content = rm_content.replace("__COMPOSE_BLOCK__", compose_content) + rm_content = rm_content.replace("__DOCKER_RUN__", docker_run_content) + rm_content = rm_content.replace("__DOCKERHUB_LINK__", os.environ.get("DOCKERHUB_LINK_CONTENT", "")) + rm_content = rm_content.replace("__CURRENT_DATE__", current_date) + rm_content = rm_content.replace("__HISTORY_CONTENT__", history_content) + + with open("README.md", "w", encoding="utf-8") as f: + f.write(rm_content) + + print("✅ README.md erfolgreich generiert!") EOF - - export REPO_PURE FULL_URL BUILD_TAG BASE_IMAGE ARM_STATUS CURRENT_TIME \ - HISTORY_CONTENT DOCKERHUB_LINK_CONTENT ENV_BLOCK_CONTENT \ - PORTS_BLOCK_CONTENT VOL_BLOCK_CONTENT DESCRIPTION - python3 update_script.py rm -f update_script.py diff --git a/Dockerfile b/Dockerfile index d5bba3d..a40b7b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,16 @@ -FROM debian:13-slim +ARG BUILD_BASE_IMAGE +FROM ${BUILD_BASE_IMAGE} + +ARG BUILD_MAINTAINER +ARG BUILD_TZ +ARG BUILD_APP_NAME +ARG BUILD_LANG +ARG BUILD_LANGUAGE +ARG BUILD_LC_ALL +ARG BUILD_COUNTRY + +LABEL maintainer="${BUILD_MAINTAINER}" +LABEL org.opencontainers.image.title="${BUILD_APP_NAME}" ENV DEBIAN_FRONTEND=noninteractive diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 new file mode 100644 index 0000000..d5bba3d --- /dev/null +++ b/Dockerfile.aarch64 @@ -0,0 +1,56 @@ +FROM debian:13-slim + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + samba \ + samba-ad-dc \ + samba-ad-provision \ + samba-dsdb-modules \ + samba-vfs-modules \ + samba-common-bin \ + python3-samba \ + smbclient \ + winbind \ + dnsutils \ + krb5-user \ + procps \ + iproute2 \ + ca-certificates \ + chrony \ + acl && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN mkdir -p \ + /etc/samba \ + /var/lib/samba \ + /var/lib/samba/ntp_signd \ + /var/log/samba \ + /var/log/chrony \ + /run/samba + +COPY chrony.conf /etc/chrony/chrony.conf +COPY scripts/entrypoint.sh /entrypoint.sh +RUN chmod 755 /entrypoint.sh + +EXPOSE 53/tcp +EXPOSE 53/udp +EXPOSE 88/tcp +EXPOSE 88/udp +EXPOSE 123/udp +EXPOSE 135/tcp +EXPOSE 137/udp +EXPOSE 138/udp +EXPOSE 139/tcp +EXPOSE 389/tcp +EXPOSE 389/udp +EXPOSE 445/tcp +EXPOSE 464/tcp +EXPOSE 464/udp +EXPOSE 636/tcp +EXPOSE 3268/tcp +EXPOSE 3269/tcp + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index b7ac7c1..24519b4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,101 @@ # samba-ad-dc +Samba Active Directory Domain Controller with integrated DNS, Kerberos authentication and Chrony time synchronization. You have to edit the .env file only to your personal needs and start the container. + + Build Status + + + Gitea Repository + + +This repository is built and pushed automatically. + + + +### 🏗️ Platform Support +| Architecture | Status | Base Image | Build Date | +| :--- | :--- | :--- | :--- | +| x86_64 (amd64) | ✅ Active | debian:trixie-slim | 28.10.2026 21:45 | +| aarch64 (arm64) | ✅ Active | debian:trixie-slim | 28.10.2026 21:45 | + +--- + +## 🐙 Method 1: Docker Compose (Recommended) + +### 🚀 1. Create `docker-compose.yml` +```yaml +services: + samba-ad-dc: + image: git.pi-farm.de/pi-farm/samba-ad-dc:trixie + container_name: samba-ad-dc + hostname: ${SAMBA_HOSTNAME} + domainname: ${SAMBA_DOMAIN} + restart: unless-stopped + environment: + SAMBA_REALM: ${SAMBA_REALM} + SAMBA_DOMAIN: ${SAMBA_DOMAIN} + SAMBA_HOSTNAME: ${SAMBA_HOSTNAME} + SAMBA_FQDN: ${SAMBA_FQDN} + SAMBA_IP: ${SAMBA_IP} + SAMBA_NETWORK: ${SAMBA_NETWORK} + DNS_FORWARDER: ${DNS_FORWARDER} + SAMBA_ADMIN_PASSWORD: ${SAMBA_ADMIN_PASSWORD} + volumes: + - ./config:/etc/samba + - ./private:/var/lib/samba + - ./state/log:/var/log/samba + - ./state/run:/run/samba + networks: + samba-ad-lan: + ipv4_address: ${SAMBA_IP} + stop_grace_period: 60s + +networks: + samba-ad-lan: + external: true + +``` +### 🚀 2. Pull & start the container +### Pull or update the image +```bash +docker compose pull +``` +### Start container in background +```bash +docker compose up -d +``` +--- + +## 🐳 Method 2: Standalone Container (Docker Run / CLI) +### 🚀 1. Pull the image manually +```bash +docker pull git.pi-farm.de/pi-farm/samba-ad-dc:trixie +``` +### 🚀 2. Run the container directly +```bash +docker run -d \ + --name samba-ad-dc \ + --restart unless-stopped \ + -e SAMBA_REALM=YOUR-DOMAIN.LOC \ + -e SAMBA_DOMAIN=YOURDOMAIN \ + -e SAMBA_HOSTNAME=DC01 \ + -e SAMBA_FQDN=dc01.your-domain.loc \ + -e SAMBA_IP=192.168.178.10 \ + -e SAMBA_NETWORK=192.168.178.0/24 \ + -e DNS_FORWARDER=192.168.178.1 \ + -e SAMBA_ADMIN_PASSWORD=CHANGE-THIS-TO-A-STRONG-SECRET \ + git.pi-farm.de/pi-farm/samba-ad-dc:trixie-dev + +``` + +*Last updated on: 28.10.2026 21:45* + +### 📜 Version History +| Version | Date | Status | +| :--- | :--- | :--- | +| **trixie-dev** | 28.10.2026 21:45 | ✅ | +| **trixie-dev** | 28.10.2026 20:37 | fix spaces ✅ | +| **trixie-dev** | 28.10.2026 20:22 | ✅ | +| **trixie-dev** | 28.10.2026 20:16 | fix missing environment ✅ | +| **trixie-dev** | 28.10.2026 20:15 | fix build-and-push status ✅ | +| **trixie-dev** | 28.10.2026 20:07 | ✅ | \ No newline at end of file diff --git a/VERSION.history b/VERSION.history new file mode 100644 index 0000000..e69de29 diff --git a/buildargs.env b/buildargs.env index bed51b1..747e18d 100644 --- a/buildargs.env +++ b/buildargs.env @@ -4,7 +4,7 @@ BUILD_COUNTRY=de ## BUILD STAGE BUILD_BASE_IMAGE="debian:${DEBIAN_CODENAME}-slim" -BUILD_TAG="${DEBIAN_CODENAME}-samba-ad-dc-${BUILD_COUNTRY}" +BUILD_TAG="${DEBIAN_CODENAME}" BUILD_TAG_LATEST=n BUILD_MAINTAINER=pi-farm BUILD_APP_NAME=samba-ad-dc @@ -22,4 +22,4 @@ ENV_DNS_FORWARDER=192.168.178.1 ENV_SAMBA_ADMIN_PASSWORD=CHANGE-THIS-TO-A-STRONG-SECRET ## DOCKER / COMPOSE CONFIG -DESCRIPTION="Samba Active Directory Domain Controller with integrated DNS, Kerberos authentication and Chrony time synchronization." +DESCRIPTION="Samba Active Directory Domain Controller with integrated DNS, Kerberos authentication and Chrony time synchronization. You have to edit the .env file only to your personal needs and start the container." \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 98b77d3..3724630 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,10 @@ services: samba-ad-dc: - build: - context: . - dockerfile: Dockerfile - image: pi-farm-samba-ad:latest + image: git.pi-farm.de/pi-farm/samba-ad-dc:trixie container_name: samba-ad-dc hostname: ${SAMBA_HOSTNAME} domainname: ${SAMBA_DOMAIN} restart: unless-stopped - privileged: true environment: SAMBA_REALM: ${SAMBA_REALM} SAMBA_DOMAIN: ${SAMBA_DOMAIN} @@ -31,3 +27,4 @@ services: networks: samba-ad-lan: external: true + \ No newline at end of file