Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added README.md
Empty file.
17 changes: 17 additions & 0 deletions template/python-connector/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

# Markdown files
[*.{md,mdx}]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions template/python-connector/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
78 changes: 78 additions & 0 deletions template/python-connector/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
ARG PYTHON_VERSION=3.12
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-alpine AS build

COPY --from=ghcr.io/openfaas/of-watchdog:0.10.7 /fwatchdog /usr/bin/fwatchdog
RUN chmod +x /usr/bin/fwatchdog

ARG UPGRADE_PACKAGES
ARG ADDITIONAL_PACKAGE
ARG TEMPLATE_DIR="."
ARG FUNCTION_DIR="function"
ARG RUN_LOCAL="false"
ARG DEBUG_PORT=5678
ARG DEBUG_HOST="0.0.0.0"

# Add non root user
RUN addgroup -S app && adduser -D -G app app

RUN --mount=type=cache,target=/var/cache/apk \
if [ "${UPGRADE_PACKAGES}" = "true" ] || [ "${UPGRADE_PACKAGES}" = "1" ]; then apk upgrade; fi && \
apk add ${ADDITIONAL_PACKAGE}

RUN chown app /home/app

USER app

ENV PATH=/opt/venv/bin:$PATH:/home/app/.local/bin \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
UV_FROZEN=true \
UV_LINK_MODE=copy \
UV_CACHE_DIR=/var/cache/uv \
RUN_LOCAL=${RUN_LOCAL} \
DEBUG_PORT=${DEBUG_PORT} \
DEBUG_HOST=${DEBUG_HOST} \
PYDEVD_DISABLE_FILE_VALIDATION=1

# Template specific steps
WORKDIR /home/app/
COPY --chown=app:app ${TEMPLATE_DIR}/template/python-connector/index.py .
COPY --chown=app:app ${TEMPLATE_DIR}/template/python-connector/pyproject.toml .
COPY --chown=app:app ${TEMPLATE_DIR}/template/python-connector/uv.lock .
USER root
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
--mount=type=cache,target=/var/cache/uv/ \
uv export --no-dev --format requirements-txt -o requirements.txt && \
touch requirements-dev.txt; \
if [ "$RUN_LOCAL" = "true" ]; then \
uv export --only-dev --format requirements-txt -o requirements-dev.txt; \
fi

# Build the function directory and install any user-specified components
USER app

RUN mkdir -p function
RUN touch ./function/__init__.py
WORKDIR /home/app/function/
COPY --chown=app:app ${FUNCTION_DIR}/requirements.txt .

# install function code
USER root
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
--mount=type=cache,target=/var/cache/uv/ \
uv pip install --system -r ../requirements.txt -r ../requirements-dev.txt -r requirements.txt

COPY --chown=app:app ${FUNCTION_DIR}/ .

# configure WSGI server and healthcheck
USER app
WORKDIR /home/app/

ENV fprocess="python index.py"
ENV cgi_headers="true"
ENV mode="http"
ENV upstream_url="http://127.0.0.1:5000"

HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1

CMD ["fwatchdog"]
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions template/python-connector/function/handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def handle(event, context):
# Be sure to read the readme on returning the correct success or failure response for Netwrix Connectors
13 changes: 13 additions & 0 deletions template/python-connector/function/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[project]
name = "netwrix-python"
version = "0.1.0"
description = ""
readme = "README.md"
requires-python = ">=3.12"
dependencies = []

[dependency-groups]
dev = []

[tool.ruff]
line-length = 120
1 change: 1 addition & 0 deletions template/python-connector/function/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Add any additional Python dependencies here
13 changes: 13 additions & 0 deletions template/python-connector/function/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading