diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a35b635..c3f0c14 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -62,9 +62,9 @@ jobs: fi - name: Build and push uses: docker/build-push-action@v5 - if: github.event_name != 'pull_request' && steps.checkchanged.outputs.CHECKEQUALS != 'true' + if: github.event_name == 'workflow_dispatch' || github.event_name != 'pull_request' && steps.checkchanged.outputs.CHECKEQUALS != 'true' with: context: . - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/riscv64 push: ${{ github.event_name != 'pull_request' }} tags: ghcr.io/${{ github.repository }}:latest diff --git a/Dockerfile b/Dockerfile index 04fcc5e..3244aaa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,9 @@ WORKDIR /app ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get -y update && apt-get -y upgrade && apt-get install -y --no-install-recommends samba samba-vfs-modules smbclient ca-certificates && rm -rf /var/lib/apt/lists/* && groupadd smb && useradd -d /tmp -s /sbin/nologin -G smb smbuser +COPY entrypoint.sh / +RUN apt-get -y update && apt-get -y upgrade && apt-get install -y --no-install-recommends tini samba samba-vfs-modules smbclient ca-certificates && rm -rf /var/lib/apt/lists/* && userdel ubuntu EXPOSE 137/udp 138/udp 139 445 + +CMD ["tini", "--", "bash", "/entrypoint.sh"] diff --git a/README.md b/README.md index 844272e..67108da 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,121 @@ # Samba Docker image -This is a bare Samba container without any custom configuration system. +This is a bare Samba Docker image giving you just the raw Samba server and a simple, but very direct configuration solution. -Why? All existing 3rd-party containers have their custom environment variable or YAML based config system. You might prefer a more raw solution. +Note: Most existing Samba Docker images allow creating users and setting smb.conf values via environment variables or via a custom YAML based config system. This Docker image takes a more direct approach. You have to set up your own smb.conf (but you can use the template below) and you have to configure users with a normal shell script. -Sample usage: +## Volumes + +You'll need to mount these volumes: + +* `/etc/samba`: Should contain your smb.conf. +* `/var/lib/samba`: Samba server's data +* `/scripts`: This can contain two scripts to prepare the container. Those scripts will be executed via `-euo pipefail` to ensure that script errors will actually trigger a failure instead of ignoring them. + * `/scripts/one-time-init.sh`: will be executed exactly once per container creation and allows e.g. creating Linux users and groups before Samba is launchedl + * `/scripts/prepare-sh`: executed every time before Samba is launched. +* One or more data volumes for your shares, as referenced in your `smb.conf` (e.g. `/data`). + +## Zeroconf/Bonjour + +Service discovery is not built into this image. You'll need, for example, Avahi either on the host or in a separate Docker container. If it's on the host you can create your service definition like this: ```sh -docker run --restart always -d --init --name samba --net=host -v /path/to/samba/data/:/data/ -v /path/to/samba/db:/var/lib/samba -v /path/to/samba/conf:/etc/samba ghcr.io/ensody/samba bash -c "groupadd smb; useradd -d /tmp -s /sbin/nologin -G smb smbuser; nmbd -D; exec smbd -F --no-process-group /etc/avahi/services/smb.service < + + + %h + + _adisk._tcp + sys=waMa=0,adVF=0x100 + dk0=adVN=TimeMachine,adVF=0x82 + + + _smb._tcp + 445 + + +EOF +``` + +Note that the first service sets up TimeMachine discovery. If you don't use macOS you can optionally remove it, but it shouldn't hurt either. + +## Example + +You can modify and copy-paste this into your shell: + +```sh +# Where to store all the data and configs +SAMBA_ROOT=/var/data/samba + +mkdir -p "$SAMBA_ROOT"/{conf,data,db,scripts} + +cat > "$SAMBA_ROOT"/scripts/one-time-init.sh < "$SAMBA_ROOT"/conf/smb.conf <