Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support set python version when build python runner image #784

Merged
merged 2 commits into from
Nov 22, 2024
Merged
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
2 changes: 1 addition & 1 deletion .ci/tests/integration-oauth2/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ setup:
- name: build images
command: |
chmod +x images/build.sh images/samples/build.sh
PULSAR_IMAGE_TAG=3.2.2.1 PULSAR_IMAGE=streamnative/sn-platform KIND_PUSH=true images/build.sh
PULSAR_IMAGE_TAG=3.2.2.1 PULSAR_IMAGE=streamnative/sn-platform PYTHON_VERSION=3.10 KIND_PUSH=true images/build.sh
PULSAR_IMAGE_TAG=3.2.2.1 KIND_PUSH=true images/samples/build.sh

- name: install helm
Expand Down
2 changes: 1 addition & 1 deletion .ci/tests/integration-oauth2/e2e_with_downloader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ setup:
- name: build images
command: |
chmod +x images/build.sh images/samples/build.sh
PULSAR_IMAGE_TAG=3.2.2.1 PULSAR_IMAGE=streamnative/sn-platform KIND_PUSH=true images/build.sh
PULSAR_IMAGE_TAG=3.2.2.1 PULSAR_IMAGE=streamnative/sn-platform PYTHON_VERSION=3.9 KIND_PUSH=true images/build.sh
PULSAR_IMAGE_TAG=3.2.2.1 KIND_PUSH=true images/samples/build.sh

- name: install helm
Expand Down
2 changes: 1 addition & 1 deletion .ci/tests/integration/e2e_with_tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ setup:
- name: build images
command: |
chmod +x images/build.sh images/samples/build.sh
PULSAR_IMAGE_TAG=3.2.2.1 PULSAR_IMAGE=streamnative/sn-platform KIND_PUSH=true images/build.sh
PULSAR_IMAGE_TAG=3.2.2.1 PULSAR_IMAGE=streamnative/sn-platform PYTHON_VERSION=3.11 KIND_PUSH=true images/build.sh
PULSAR_IMAGE_TAG=3.2.2.1 KIND_PUSH=true images/samples/build.sh

- name: install helm
Expand Down
3 changes: 2 additions & 1 deletion images/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set -e

PULSAR_IMAGE=${PULSAR_IMAGE:-"streamnative/sn-platform"}
PULSAR_IMAGE_TAG=${PULSAR_IMAGE_TAG:-"2.7.1"}
PYTHON_VERSION=${PYTHON_VERSION:-"3.12"}
DOCKER_REPO=${DOCKER_REPO:-"streamnative"}
RUNNER_BASE="pulsar-functions-runner-base"
PULSARCTL_RUNNER_BASE="pulsar-functions-pulsarctl-runner-base"
Expand Down Expand Up @@ -48,7 +49,7 @@ docker tag ${PULSARCTL_JAVA_RUNNER} "${DOCKER_REPO}"/${PULSARCTL_JAVA_RUNNER}:"$

echo "build python runner"
docker build --platform linux/amd64 -t ${PYTHON_RUNNER} images/pulsar-functions-python-runner --build-arg PULSAR_IMAGE="$PULSAR_IMAGE" --build-arg PULSAR_IMAGE_TAG="$PULSAR_IMAGE_TAG" --progress=plain
docker build --platform linux/amd64 -t ${PULSARCTL_PYTHON_RUNNER} images/pulsar-functions-python-runner -f images/pulsar-functions-python-runner/pulsarctl.Dockerfile --build-arg PULSAR_IMAGE="$PULSAR_IMAGE" --build-arg PULSAR_IMAGE_TAG="$PULSAR_IMAGE_TAG" --progress=plain
docker build --platform linux/amd64 -t ${PULSARCTL_PYTHON_RUNNER} images/pulsar-functions-python-runner -f images/pulsar-functions-python-runner/pulsarctl.Dockerfile --build-arg PULSAR_IMAGE="$PULSAR_IMAGE" --build-arg PULSAR_IMAGE_TAG="$PULSAR_IMAGE_TAG" --build-arg PYTHON_VERSION="$PYTHON_VERSION" --progress=plain
docker tag ${PYTHON_RUNNER} "${DOCKER_REPO}"/${PYTHON_RUNNER}:"${RUNNER_TAG}"
docker tag ${PULSARCTL_PYTHON_RUNNER} "${DOCKER_REPO}"/${PULSARCTL_PYTHON_RUNNER}:"${RUNNER_TAG}"

Expand Down
31 changes: 29 additions & 2 deletions images/pulsar-functions-python-runner/pulsarctl.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
ARG PULSAR_IMAGE
ARG PULSAR_IMAGE_TAG
ARG PYTHON_VERSION=3.12
FROM ${PULSAR_IMAGE}:${PULSAR_IMAGE_TAG} as pulsar
FROM pulsar-functions-pulsarctl-runner-base:latest

FROM python:${PYTHON_VERSION}-alpine

ENV GID=10001
ENV UID=10000
ENV USER=pulsar
RUN addgroup -g $GID pulsar
RUN adduser -u $UID -G pulsar -D -g '' $USER

RUN mkdir -p /pulsar/bin/ \
&& mkdir -p /pulsar/lib/ \
&& mkdir -p /pulsar/conf/ \
&& mkdir -p /pulsar/instances/ \
&& mkdir -p /pulsar/connectors/ \
&& mkdir -p /pulsar/logs/ \
&& mkdir -p /pulsar/tmp/ \
&& mkdir -p /pulsar/examples/ \
&& chown -R $UID:$GID /pulsar \
&& chmod -R g=u /pulsar \
&& apk update && apk add --no-cache wget bash \
&& wget https://github.com/streamnative/pulsarctl/releases/latest/download/pulsarctl-amd64-linux.tar.gz -P /pulsar/bin/ \
&& tar -xzf /pulsar/bin/pulsarctl-amd64-linux.tar.gz -C /pulsar/bin/ \
&& rm -rf /pulsar/bin/pulsarctl-amd64-linux.tar.gz \
&& chmod +x /pulsar/bin/pulsarctl-amd64-linux/pulsarctl \
&& ln -s /pulsar/bin/pulsarctl-amd64-linux/pulsarctl /usr/local/bin/pulsarctl

WORKDIR /pulsar

COPY --from=pulsar --chown=$UID:$GID /pulsar/bin /pulsar/bin
COPY --from=pulsar --chown=$UID:$GID /pulsar/instances/python-instance /pulsar/instances/python-instance
Expand All @@ -20,7 +47,7 @@ ENV PULSAR_CLIENT_PYTHON_VERSION=3.5.0
COPY --from=pulsar --chown=$UID:$GID /pulsar/README /pulsar/cpp-clien* /pulsar/cpp-client/

RUN apk update \
&& apk add --no-cache python3 python3-dev tk-dev curl ca-certificates\
&& apk add --no-cache tk-dev curl ca-certificates\
&& mkdir -p /etc/pki/tls/certs && cp /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt \
&& curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& mv /usr/lib/python3.*/EXTERNALLY-MANAGED /tmp/EXTERNALLY-MANAGED.old \
Expand Down
Loading