Skip to content

Commit 96a4828

Browse files
authored
Create version 2.0.0 for python sample (#35)
* Update devfile parent to 3.0.0 Signed-off-by: thepetk <[email protected]> * Update ports in deploy.yaml Signed-off-by: thepetk <[email protected]> * Update devfile version Signed-off-by: thepetk <[email protected]> * Update readme.md Signed-off-by: thepetk <[email protected]> * Finalize devfile version Signed-off-by: thepetk <[email protected]> * Revert update to port * Update port to 8080 Signed-off-by: thepetk <[email protected]> --------- Signed-off-by: thepetk <[email protected]>
1 parent c4f07d1 commit 96a4828

File tree

4 files changed

+29
-48
lines changed

4 files changed

+29
-48
lines changed

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# Creating an application with a Python code sample
22

3-
**Note:** The Python code sample uses the **8081** HTTP port.
3+
**Note:** The Python code sample version `2.0.0` uses the **8080** HTTP port.
44

55
Before you begin creating an application with this `devfile` code sample, it's helpful to understand the relationship between the `devfile` and `Dockerfile` and how they contribute to your build. You can find these files at the following URLs:
66

7-
* [Python `devfile.yaml`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/devfile.yaml)
8-
* [Python `Dockerfile`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/docker/Dockerfile)
7+
- [Python `devfile.yaml`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/devfile.yaml)
8+
- [Python `Dockerfile`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/docker/Dockerfile)
99

1010
1. The `devfile.yaml` file has an [`image-build` component](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/devfile.yaml#L24-L30) that points to your `Dockerfile`.
1111
2. The [`docker/Dockerfile`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/docker/Dockerfile) contains the instructions you need to build the code sample as a container image.
1212
3. The `devfile.yaml` [`kubernetes-deploy` component](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/devfile.yaml#L31-L44) points to a `deploy.yaml` file that contains instructions for deploying the built container image.
1313
4. The `devfile.yaml` [`deploy` command](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/devfile.yaml#L46-L59) completes the [outerloop](https://devfile.io/docs/2.2.0/innerloop-vs-outerloop) deployment phase by pointing to the `image-build` and `kubernetes-deploy` components to create your application.
1414

1515
### Additional resources
16-
* For more information about Python, see [Python](https://www.python.org/).
17-
* For more information about devfiles, see [Devfile.io](https://devfile.io/).
18-
* For more information about Dockerfiles, see [Dockerfile reference](https://docs.docker.com/engine/reference/builder/).
16+
17+
- For more information about Python, see [Python](https://www.python.org/).
18+
- For more information about devfiles, see [Devfile.io](https://devfile.io/).
19+
- For more information about Dockerfiles, see [Dockerfile reference](https://docs.docker.com/engine/reference/builder/).

devfile.yaml

+9-29
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ metadata:
88
'Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.
99
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.'
1010
language: Python
11-
version: 1.0.1
11+
version: 2.0.0
1212
provider: Red Hat
1313
tags:
1414
- Python
@@ -20,38 +20,18 @@ metadata:
2020
parent:
2121
id: python
2222
registryUrl: 'https://registry.devfile.io'
23-
components:
24-
- name: image-build
25-
image:
26-
imageName: python-image:latest
27-
dockerfile:
28-
uri: docker/Dockerfile
29-
buildContext: .
30-
rootRequired: false
31-
- name: kubernetes-deploy
23+
version: 3.0.0
24+
components:
25+
- name: deploy
3226
attributes:
3327
deployment/replicas: 1
3428
deployment/cpuRequest: 10m
3529
deployment/memoryRequest: 50Mi
36-
deployment/container-port: 8081
30+
deployment/container-port: 8080
3731
kubernetes:
38-
uri: deploy.yaml
32+
uri: kubernetes/deploy.yaml
3933
endpoints:
40-
- name: http-8081
41-
targetPort: 8081
34+
- name: http-8080
35+
targetPort: 8080
4236
path: /
43-
commands:
44-
- id: build-image
45-
apply:
46-
component: image-build
47-
- id: deployk8s
48-
apply:
49-
component: kubernetes-deploy
50-
- id: deploy
51-
composite:
52-
commands:
53-
- build-image
54-
- deployk8s
55-
group:
56-
kind: deploy
57-
isDefault: true
37+

docker/Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
FROM registry.access.redhat.com/ubi9/python-39:1-117.1684741281
22

3-
# By default, listen on port 8081
4-
EXPOSE 8081/tcp
5-
ENV FLASK_PORT=8081
3+
# By default, listen on port 8080
4+
EXPOSE 8080/tcp
5+
ENV FLASK_PORT=8080
66

77
# Set the working directory in the container
88
WORKDIR /projects
@@ -13,9 +13,9 @@ COPY . .
1313
# Install any dependencies
1414
RUN \
1515
if [ -f requirements.txt ]; \
16-
then pip install -r requirements.txt; \
16+
then pip install -r requirements.txt; \
1717
elif [ `ls -1q *.txt | wc -l` == 1 ]; \
18-
then pip install -r *.txt; \
18+
then pip install -r *.txt; \
1919
fi
2020

2121
# Specify the command to run on container start

deploy.yaml renamed to kubernetes/deploy.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
image: python-image:latest
1818
ports:
1919
- name: http
20-
containerPort: 8081
20+
containerPort: 8080
2121
protocol: TCP
2222
resources:
2323
requests:
@@ -29,10 +29,10 @@ apiVersion: v1
2929
metadata:
3030
name: my-python
3131
spec:
32-
ports:
33-
- name: http-8081
34-
port: 8081
35-
protocol: TCP
36-
targetPort: 8081
37-
selector:
38-
app: python-app
32+
ports:
33+
- name: http-8080
34+
port: 8080
35+
protocol: TCP
36+
targetPort: 8080
37+
selector:
38+
app: python-app

0 commit comments

Comments
 (0)