|
| 1 | +FROM alpine:3.18 |
| 2 | + |
| 3 | +# boilerplate labels required by validation when pushing to ACR, ECR & GCR |
| 4 | +LABEL org.opencontainers.image.source="https://github.com/snowflakedb/snowflake-connector-python" |
| 5 | +LABEL com.snowflake.owners.email= "[email protected]" |
| 6 | +LABEL com.snowflake.owners.slack="triage-snow-drivers-warsaw-dl" |
| 7 | +LABEL com.snowflake.owners.team="Snow Drivers" |
| 8 | +LABEL com.snowflake.owners.jira_area="Developer Platform" |
| 9 | +LABEL com.snowflake.owners.jira_component="Python Driver" |
| 10 | +# fake layers label to pass the validation |
| 11 | +LABEL com.snowflake.ugcbi.layers="sha256:850959b749c07b254308a4d1a84686fd7c09fcb94aeae33cc5748aa07e5cb232,sha256:b79d3c4628a989cbb8bc6f0bf0940ff33a68da2dca9c1ffbf8cfb2a27ac8d133,sha256:1cbcc0411a84fbce85e7ee2956c8c1e67b8e0edc81746a33d9da48c852037c3e,sha256:07e89b796f91d37255c6eec926b066d6818f3f2edc344a584d1b9566f77e1c27,sha256:84ff92691f909a05b224e1c56abb4864f01b4f8e3c854e4bb4c7baf1d3f6d652,sha256:3ab72684daee4eea64c3ae78a43ea332b86358446b6f2904dca4b634712e1537" |
| 12 | + |
| 13 | +RUN apk add --no-cache \ |
| 14 | + bash \ |
| 15 | + git \ |
| 16 | + make \ |
| 17 | + g++ \ |
| 18 | + zlib-dev \ |
| 19 | + openssl-dev \ |
| 20 | + libffi-dev \ |
| 21 | + jq |
| 22 | + |
| 23 | +ENV HOME="/home/driveruser" |
| 24 | + |
| 25 | +# Create a group with GID=1000 and a user with UID=1000 |
| 26 | +RUN addgroup -g 1000 drivergroup && \ |
| 27 | + adduser -u 1000 -G drivergroup -D driveruser |
| 28 | + |
| 29 | +# Set permissions for the non-root user |
| 30 | +RUN mkdir -p ${HOME} && \ |
| 31 | + chown -R driveruser:drivergroup ${HOME} |
| 32 | + |
| 33 | +# Switch to the non-root user |
| 34 | +USER driveruser |
| 35 | +WORKDIR ${HOME} |
| 36 | + |
| 37 | +# Set environment variables |
| 38 | +ENV PYENV_ROOT="${HOME}/.pyenv" |
| 39 | +ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}" |
| 40 | + |
| 41 | + |
| 42 | +# Install pyenv |
| 43 | +RUN git clone --depth=1 https://github.com/pyenv/pyenv.git ${PYENV_ROOT} |
| 44 | + |
| 45 | +# Build arguments for Python versions and Snowflake connector versions |
| 46 | +ARG MATRIX_VERSION='{"3.13.4": ["3.15.0", "3.13.2", "3.14.0", "3.12.3", "3.12.1", "3.12.4", "3.11.0", "3.12.2", "3.6.0", "3.7.0"], "3.9.22": ["3.15.0", "3.13.2", "3.14.0", "3.12.3", "3.12.1", "3.12.4", "3.11.0", "3.12.2", "3.6.0", "3.7.0"]}' |
| 47 | + |
| 48 | + |
| 49 | +# Install Python versions from ARG MATRIX_VERSION |
| 50 | +RUN eval "$(pyenv init --path)" && \ |
| 51 | + for python_version in $(echo $MATRIX_VERSION | jq -r 'keys[]'); do \ |
| 52 | + pyenv install $python_version || echo "Failed to install Python $python_version"; \ |
| 53 | + done |
| 54 | + |
| 55 | +# Create virtual environments for each combination of Python and Snowflake connector versions |
| 56 | +RUN for python_version in $(echo $MATRIX_VERSION | jq -r 'keys[]'); do \ |
| 57 | + for connector_version in $(echo $MATRIX_VERSION | jq -r ".\"${python_version}\"[]"); do \ |
| 58 | + venv_path="${HOME}/venvs/python_${python_version}_connector_${connector_version}"; \ |
| 59 | + $PYENV_ROOT/versions/$python_version/bin/python -m venv $venv_path && \ |
| 60 | + $venv_path/bin/pip install --upgrade pip && \ |
| 61 | + $venv_path/bin/pip install snowflake-connector-python==$connector_version; \ |
| 62 | + done; \ |
| 63 | +done |
| 64 | + |
| 65 | +# Copy the prober script into the container |
| 66 | +RUN mkdir -p prober/probes/ |
| 67 | +COPY __init__.py prober |
| 68 | +COPY setup.py prober |
| 69 | +COPY entrypoint.sh prober |
| 70 | +COPY probes/* prober/probes |
| 71 | + |
| 72 | +# Install /prober in editable mode for each virtual environment |
| 73 | +RUN for venv in ${HOME}/venvs/*; do \ |
| 74 | + source $venv/bin/activate && \ |
| 75 | + pip install -e ${HOME}/prober && \ |
| 76 | + deactivate; \ |
| 77 | +done |
0 commit comments