SIGN IN SIGN UP
TykTechnologies / tyk UNCLAIMED

Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols

0 0 0 Go
[TT-13217] Add updated dockerfile for python, test with 5.3.0/5.3.6-rc4 (#6750) ### **User description** Adds a testing dockerfile to run gateway in a python env. Since introducing distroless, the package manager to install python wasn't available. The dockerfile solution is to add gateway to an image containing python. ```Dockerfile ARG BASE_IMAGE FROM ${BASE_IMAGE} AS base FROM python:3.11-bookworm COPY --from=base /opt/tyk-gateway/ /opt/tyk-gateway/ RUN pip install setuptools && pip install google && pip install 'protobuf==4.24.4' EXPOSE 8080 80 443 ENV PYTHON_VERSION=3.11 ENV PORT=8080 WORKDIR /opt/tyk-gateway/ ENTRYPOINT ["/opt/tyk-gateway/tyk" ] CMD [ "--conf=/opt/tyk-gateway/tyk.conf" ] ``` ___ ### **PR Type** Enhancement, Tests ___ ### **Description** - Introduced a new Dockerfile to create a Python environment for Tyk Gateway, enabling the installation of Python dependencies and running Tyk Gateway with a configuration file. - Added a Taskfile to automate the building and testing of the Dockerfile, including tasks to verify Python and Tyk Gateway versions. - Supported testing with multiple Tyk Gateway versions (5.3.0 and 5.3.6-rc4) to ensure compatibility. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>Dockerfile</strong><dd><code>Add Dockerfile for testing Tyk Gateway with Python environment</code></dd></summary> <hr> docs/plugins/python/Dockerfile <li>Added a new Dockerfile to create a Python environment for Tyk Gateway.<br> <li> Configured the Dockerfile to install Python dependencies such as <br><code>setuptools</code>, <code>google</code>, and <code>protobuf</code>.<br> <li> Defined environment variables and exposed necessary ports.<br> <li> Set up entrypoint and command for running Tyk Gateway with a <br>configuration file.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6750/files#diff-04aa0c9ea8439431d9cccd4427ca7ed04e5ea23b9185a33117ecd6d12527cbee">+16/-0</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>Taskfile.yml</strong><dd><code>Add Taskfile for building and testing Dockerfile</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> docs/plugins/python/Taskfile.yml <li>Added a Taskfile to build and test the Dockerfile for Tyk Gateway with <br>Python.<br> <li> Included tasks to build Docker images with specified base images and <br>platforms.<br> <li> Added commands to verify Python version and Tyk Gateway version in the <br>built image.<br> <li> Supported testing with multiple Tyk Gateway versions (5.3.0 and <br>5.3.6-rc4).<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6750/files#diff-83d3e8ea6db5ced12e49e2e8fab60545aa92ce4ae8e5b7b5a4b09749e139fb67">+34/-0</a>&nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information --------- Co-authored-by: Tit Petric <tit@tyk.io>
2024-12-13 11:51:11 +01:00
# yamllint disable rule:line-length
---
version: "3"
# Taskfile tests the provided Dockerfile, see `test` for more details.
# This confirms a python environment, not end to end as it doesn't confirm
# gateway python plugin loading works. We're missing acceptance tests.
vars:
base: '{{.BASE_IMAGE | default "tykio/tyk-gateway:v5.3.6-rc4"}}'
image: internal/tyk-gateway
platform: '{{.BUILD_PLATFORM | default "linux/amd64"}}'
tasks:
build:
desc: "Build docker images"
vars:
tags: latest
args: --rm --build-arg BASE_IMAGE={{.base}} --platform {{.platform}} -q --no-cache --pull
cmds:
- for:
var: tags
as: tag
cmd: docker build {{.args}} -t {{.image}}:{{.tag}} -f Dockerfile .
test:
desc: "Print python version"
cmds:
- BASE_IMAGE=tykio/tyk-gateway:v5.3.6-rc4 task build
- docker run --rm --entrypoint=/bin/bash {{.image}} -c "python -V"
- docker run --rm --entrypoint=/bin/bash {{.image}} -c "/opt/tyk-gateway/tyk version"
- BASE_IMAGE=tykio/tyk-gateway:v5.3.0 task build
- docker run --rm --entrypoint=/bin/bash {{.image}} -c "python -V"
- docker run --rm --entrypoint=/bin/bash {{.image}} -c "/opt/tyk-gateway/tyk version"