Skip to content

Add a 2.2.2 devfile version and set https endpoint to Python stack #358

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

Merged
merged 2 commits into from
Apr 12, 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
63 changes: 63 additions & 0 deletions stacks/python/2.2.0/devfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
schemaVersion: 2.2.2
metadata:
name: python
displayName: Python
description: "Python (version 3.9.x) is an interpreted, object-oriented, high-level programming language with dynamic semantics.
Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together."
icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/python.svg
tags:
- Python
- Pip
- Flask
projectType: Python
language: Python
provider: Red Hat
version: 2.2.0
starterProjects:
- name: flask-example
description:
'Flask is a web framework, it’s a Python module that lets you develop web applications easily.
It’s has a small and easy-to-extend core: it’s a microframework that doesn’t include an ORM (Object Relational Manager) or such features.'
git:
remotes:
origin: https://github.com/devfile-samples/python-ex
components:
- name: py
container:
image: registry.access.redhat.com/ubi9/python-39:1-172
args: ['tail', '-f', '/dev/null']
mountSources: true
endpoints:
- name: https-python
targetPort: 8080
protocol: https
- exposure: none
name: debug
targetPort: 5858
env:
- name: DEBUG_PORT
value: '5858'
commands:
- id: pip-install-requirements
exec:
commandLine: pip install -r requirements.txt
workingDir: ${PROJECT_SOURCE}
group:
kind: build
isDefault: true
component: py
- id: run-app
exec:
commandLine: 'python app.py'
workingDir: ${PROJECT_SOURCE}
component: py
group:
kind: run
isDefault: true
- id: debug-py
exec:
commandLine: 'pip install debugpy && python -m debugpy --listen 0.0.0.0:${DEBUG_PORT} app.py'
workingDir: ${PROJECT_SOURCE}
component: py
group:
kind: debug
91 changes: 91 additions & 0 deletions stacks/python/3.1.0/devfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
schemaVersion: 2.2.2
metadata:
name: python
displayName: Python
description: "Python (version 3.9.x) is an interpreted, object-oriented, high-level programming language with dynamic semantics.
Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together."
icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/python.svg
tags:
- Python
- Pip
- Flask
projectType: Python
language: Python
provider: Red Hat
version: 3.1.0
starterProjects:
- name: flask-example
description:
'Flask is a web framework, it’s a Python module that lets you develop web applications easily.
It’s has a small and easy-to-extend core: it’s a microframework that doesn’t include an ORM (Object Relational Manager) or such features.'
git:
remotes:
origin: https://github.com/devfile-samples/python-ex
components:
- name: py
container:
image: registry.access.redhat.com/ubi9/python-39:1-172
args: ['tail', '-f', '/dev/null']
mountSources: true
endpoints:
- name: https-python
targetPort: 8080
protocol: https
- exposure: none
name: debug
targetPort: 5858
env:
- name: DEBUG_PORT
value: '5858'
- name: build
image:
imageName: python-image:latest
dockerfile:
uri: docker/Dockerfile
buildContext: .
rootRequired: false
- name: deploy
kubernetes:
uri: kubernetes/deploy.yaml
endpoints:
- name: https-8081
targetPort: 8081
protocol: https
commands:
- id: pip-install-requirements
exec:
commandLine: pip install -r requirements.txt
workingDir: ${PROJECT_SOURCE}
group:
kind: build
isDefault: true
component: py
- id: run-app
exec:
commandLine: 'python app.py'
workingDir: ${PROJECT_SOURCE}
component: py
group:
kind: run
isDefault: true
- id: debug-py
exec:
commandLine: 'pip install debugpy && python -m debugpy --listen 0.0.0.0:${DEBUG_PORT} app.py'
workingDir: ${PROJECT_SOURCE}
component: py
group:
kind: debug
- id: build-image
apply:
component: build
- id: deployk8s
apply:
component: deploy
- id: deploy
composite:
commands:
- build-image
- deployk8s
group:
kind: deploy
isDefault: true
20 changes: 20 additions & 0 deletions stacks/python/3.1.0/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM registry.access.redhat.com/ubi9/python-39:latest

# By default, listen on port 8081
EXPOSE 8081/tcp
ENV FLASK_PORT=8081

# Set the working directory in the container
WORKDIR /projects

# Copy the dependencies file to the working directory
COPY requirements.txt .

# Install any dependencies
RUN pip install -r requirements.txt

# Copy the content of the local src directory to the working directory
COPY . .

# Specify the command to run on container start
CMD [ "python", "./app.py" ]
41 changes: 41 additions & 0 deletions stacks/python/3.1.0/kubernetes/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
kind: Service
apiVersion: v1
metadata:
name: my-python
spec:
ports:
- name: http-8081
port: 8081
protocol: TCP
targetPort: 8081
selector:
app: python-app
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: my-python
spec:
replicas: 1
selector:
matchLabels:
app: python-app
template:
metadata:
labels:
app: python-app
spec:
containers:
- name: my-python
image: python-image:latest
ports:
- name: http
containerPort: 8081
protocol: TCP
resources:
requests:
memory: "50Mi"
cpu: "10m"
limits:
memory: "100Mi"
cpu: "100m"
2 changes: 2 additions & 0 deletions stacks/python/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ displayName: Python
icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/python.svg
versions:
- version: 2.1.0
- version: 2.2.0
default: true # should have one and only one default version
- version: 3.0.0
- version: 3.1.0