Skip to content

Commit

Permalink
Use pyproject.toml, pip-compile and venv to build container image
Browse files Browse the repository at this point in the history
  • Loading branch information
znerol committed Jan 4, 2024
1 parent 6c71909 commit 3a17ba0
Show file tree
Hide file tree
Showing 6 changed files with 427 additions and 57 deletions.
29 changes: 8 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
FROM alpine:3.18.5 as base
FROM alpine:3.18.5
RUN apk update && apk upgrade

RUN apk add --no-cache \
ca-certificates \
py3-gunicorn \
py3-paramiko \
py3-pip \
py3-prometheus-client \
py3-requests \
py3-werkzeug \
py3-wheel \
py3-yaml \
python3

FROM base as builder
ADD . /src
WORKDIR /opt
RUN pip3 wheel --no-deps /src proxmoxer==2.0.1
ADD . /src/prometheus-pve-exporter
RUN python3 -m venv /opt/prometheus-pve-exporter && \
/opt/prometheus-pve-exporter/bin/pip install -r /src/prometheus-pve-exporter/requirements.txt && \
/opt/prometheus-pve-exporter/bin/pip install /src/prometheus-pve-exporter && \
rm -rf /src/prometheus-pve-exporter /root/.cache

FROM base as runtime

COPY --from=builder /opt /opt

RUN pip3 install --no-cache-dir --no-index /opt/*py3-none-any.whl && \
rm /opt/*py3-none-any.whl && \
addgroup -S -g 101 prometheus && \
RUN addgroup -S -g 101 prometheus && \
adduser -D -H -S -G prometheus -u 101 prometheus

USER prometheus

EXPOSE 9221

ENTRYPOINT [ "/usr/bin/pve_exporter" ]
ENTRYPOINT [ "/opt/prometheus-pve-exporter/bin/pve_exporter" ]
33 changes: 33 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "prometheus-pve-exporter"
authors = [
{name = "Lorenz Schori", email = "[email protected]"},
]
description="Proxmox VE exporter for the Prometheus monitoring system."
requires-python = ">=3.9"
keywords = ["prometheus", "exporter", "network", "monitoring", "proxmox"]
license = {text = "Apache-2.0"}
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"Topic :: System :: Monitoring",
"Topic :: System :: Networking :: Monitoring",
"License :: OSI Approved :: Apache Software License",
]
dynamic = ["dependencies", "optional-dependencies", "readme", "version"]

[project.urls]
Homepage = "https://github.com/prometheus-pve/prometheus-pve-exporter"

[project.scripts]
pve_exporter = "pve_exporter.cli:main"

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.in"] }
optional-dependencies.test = { file = ["requirements-test.txt"] }
readme = {file = ["README.rst"]}
File renamed without changes.
7 changes: 7 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
prometheus_client>=0.0.11
proxmoxer
pyyaml
requests
Werkzeug
gunicorn
paramiko
Loading

0 comments on commit 3a17ba0

Please sign in to comment.