This commit is contained in:
2026-02-25 23:16:46 +01:00
commit 216e216dee
10 changed files with 367 additions and 0 deletions

40
cont/conf/Dockerfile Normal file
View File

@@ -0,0 +1,40 @@
FROM alpine:latest
# https://docs.docker.com/reference/dockerfile/#environment-replacement
# ENV PUID=1600
# ENV USER=itsme
# VOLUME [""]
RUN apk update && \
apk add python3 py3-pip su-exec curl && \
mkdir -p /app/snmpython/
WORKDIR /app/snmpython/
COPY ../code/someMain.py /app/snmpython/
# COPY ./entrypoint.sh /entrypoint.sh
# RUN chmod +x /entrypoint.sh
# Add user to run under
# RUN adduser --disabled-password -u "${PUID}" "${USER}"
# RUN chown -R "${USER}" /app/snmpython
COPY ./requirements.txt /app/snmpython/
RUN python3 -m venv venv && \
venv/bin/python3 -m pip install --upgrade pip && \
venv/bin/pip3 install -r requirements.txt
# venv/bin/pip3 install -r requirements.txt
# Set user. No need for root past this point
# USER "${USER}"
# ENTRYPOINT ["/entrypoint.sh"]
# HEALTHCHECK --interval=3s --timeout=3s --retries=3 \
# CMD curl --fail http://127.0.0.1:8181/health || exit 1
CMD ["/app/snmpython/someMain.py"]

3
cont/conf/build.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
docker buildx build --platform linux/amd64 --tag tea.shupogaki.org/yuruc3/snmpython:v0 --debug --push .

View File

@@ -0,0 +1,16 @@
---
services:
mdfanchanger:
container_name: snmpython-dev
user: 1600:1600
image: shupotea/yuruc3/snmpython:dev
build:
dockerfile: ./Dockerfile
environment:
- INFLUXTOKEN: "12345678"
- INFLUXHOST: ""
- HOST_LIST: ["192.168.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1"]
restart: unless-stopped

25
cont/conf/entrypoint.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
set -e
# Default to 1600 if not provided
PUID="${PUID:-1000}"
PGID="${PGID:-1000}"
USER="${USER:-pythusr}"
GROUP="${USER:-pythusr}"
CHOWNPATH="/app/snmpython"
# Create group if missing
if ! getent group "$GROUP" >/dev/null 2>&1; then
addgroup -g "$PGID" "$GROUP"
fi
# Create user if missing
if ! id -u "$USER" >/dev/null 2>&1; then
adduser -D -u "$PUID" -G "$GROUP" "$USER"
fi
# Fix permissions (only do this on /app/API)
chown -R "$PUID:$PGID" "$CHOWNPATH"
# Drop privileges & run command
exec su-exec "$PUID:$PGID" "$@"

View File

@@ -0,0 +1,12 @@
# mysql-connector-python==9.2.0
PyMySQL==1.1.1
sqlmodel==0.0.24
pydantic==2.10.6
pydantic_core==2.27.2
annotated-types==0.7.0
typing==3.7.4.3
pysnmp==7.1.22
# requests==2.32.3
influxdb-client==1.49.0
# influxdb3-python==0.18.0