Skip to content

Commit

Permalink
New: smfc docker support added
Browse files Browse the repository at this point in the history
  • Loading branch information
petersulyok committed Nov 19, 2023
1 parent 1d0ffcb commit a6990d8
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 0 deletions.
59 changes: 59 additions & 0 deletions Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# smfc in docker
This file explains how `smfc` image can be executed in docker environment.

Visit the [GitHub repository](https://github.com/petersulyok/smfc) of `smfc` for more details or reporting issues.

# Usage

## docker CLI
```
$ docker run \
-d \
--rm \
--log-driver=journald \
--privileged=true \
--name "smfc" \
-v /dev:/dev:ro \
-v /run:/run:ro \
-v /opt/smfc/smfc.conf:/opt/smfc/smfc.conf:ro \
-e SMFC_ARGS="-l 3" \
petersulyok/smfc
```
(see this example in `docker/docker-start.sh`)

## docker-compose
```
version: "2"
services:
smfc:
image: petersulyok/smfc
container_name: smfc
network_mode: none
logging:
driver: journald
privileged: true
environment:
- SMFC_ARGS=-l 3
volumes:
- /dev:/dev:ro
- /run:/run:ro
- /opt/smfc/smfc.conf:/opt/smfc/smfc.conf:ro
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
```
(see this example in `docker/docker-compose.yaml`)

## Parameters
Use the following parameters to configure `smfc`:

| Parameter | type | function |
|-------------|----------------------|------------------------------------------------------|
| `SMFC_ARGS` | environment variable | command-line arguments for `smfc` (-o, -l) |
| `smfc.conf` | volume | configuration file for `smfc`, mapped from host side |

Please also note:
1. this image should be executed in `privileged` mode with access of `/dev` and `/run` folders
because of the tools (i.e. `ipmitool`, `smartctl` and `hddtemp`)
2. `smfc` log messages are forwarded to the host's `journald` daemon. Feel free to use a different [log driver](https://docs.docker.com/config/containers/logging/configure/) for docker.

34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM alpine:3.18

LABEL org.opencontainers.image.title="smfc"
LABEL org.opencontainers.image.authors="petersulyok"
LABEL org.opencontainers.image.desciption="Super Micro fan control for linux servers."
LABEL org.opencontainers.image.url="https://github.com/petersulyok/smfc"

RUN <<EOT
set -xe
apk add --no-cache ipmitool python3 smartmontools
apk add --no-cache --virtual .depends git build-base linux-headers automake autoconf gettext-dev
mkdir /tmp/build/
cd /tmp/build/
wget -O hddtemp.db.1 http://download.savannah.nongnu.org/releases/hddtemp/hddtemp.db
wget -O hddtemp.db.2 https://gitweb.gentoo.org/repo/gentoo.git/plain/app-admin/hddtemp/files/hddgentoo.db
cat hddtemp.db.1 hddtemp.db.2 > /usr/share/misc/hddtemp.db
wget "https://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess"
wget "https://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub"
git clone https://github.com/vitlav/hddtemp.git
cd hddtemp/
autoreconf -vif
./configure --prefix=/usr --disable-nls
make
make install
cd /
rm -r /usr/share/man
rm -r /tmp/build
apk del .depends
EOT

WORKDIR /opt/smfc
ADD --chmod=755 src/smfc.py smfc.py

CMD /opt/smfc/smfc.py -c /opt/smfc/smfc.conf $SMFC_ARGS
5 changes: 5 additions & 0 deletions docker/docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

version="3.3.0"

docker build . -t petersulyok/smfc:$version -t petersulyok/smfc:latest --label "org.opencontainers.image.version=$version" -f Dockerfile
18 changes: 18 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "2"
services:
smfc:
image: petersulyok/smfc
container_name: smfc
network_mode: none
logging:
driver: journald
privileged: true
environment:
- SMFC_ARGS=-l 3
volumes:
- /dev:/dev:ro
- /run:/run:ro
- /opt/smfc/smfc.conf:/opt/smfc/smfc.conf:ro
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
19 changes: 19 additions & 0 deletions docker/docker-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
#
# docker_start.sh (C) 2023, Peter Sulyok
# This script will start `smfc` image in docker.
#

docker run \
-d \
--rm \
--log-driver=journald \
--privileged=true \
--name "smfc" \
-v /dev:/dev:ro \
-v /run:/run:ro \
-v /etc/timezone:/etc/timezone:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /opt/smfc/smfc.conf:/opt/smfc/smfc.conf:ro \
-e SMFC_ARGS="-l 3" \
petersulyok/smfc

0 comments on commit a6990d8

Please sign in to comment.