From edc0fb1dd8cef0780e542ce5b97f451c7f5bfbfa Mon Sep 17 00:00:00 2001 From: thepetk Date: Mon, 9 Oct 2023 16:19:46 +0100 Subject: [PATCH 1/7] Update devfile parent to 3.0.0 Signed-off-by: thepetk --- README.md | 2 +- devfile.yaml | 48 ++++++++++++++------------- docker/Dockerfile | 6 ++-- deploy.yaml => kubernetes/deploy.yaml | 0 4 files changed, 29 insertions(+), 27 deletions(-) rename deploy.yaml => kubernetes/deploy.yaml (100%) diff --git a/README.md b/README.md index e96053f1e..b5ba6e0c7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Creating an application with a Python code sample -**Note:** The Python code sample uses the **8081** HTTP port. +**Note:** The Python code sample version `1.0.2` uses the **8080** HTTP port. 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: diff --git a/devfile.yaml b/devfile.yaml index b4572435c..77a3c62e7 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -8,7 +8,7 @@ metadata: 'Python 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.' language: Python - version: 1.0.1 + version: 1.0.2 provider: Red Hat tags: - Python @@ -20,38 +20,40 @@ metadata: parent: id: python registryUrl: 'https://registry.devfile.io' -components: - - name: image-build + version: 3.0.0 + commands: + - id: build-image + apply: + component: build + - id: deployk8s + apply: + component: deploy + - id: deploy + composite: + commands: + - build-image + - deployk8s + group: + kind: deploy + isDefault: true + components: + - name: build image: imageName: python-image:latest dockerfile: uri: docker/Dockerfile buildContext: . rootRequired: false - - name: kubernetes-deploy + - name: deploy attributes: deployment/replicas: 1 deployment/cpuRequest: 10m deployment/memoryRequest: 50Mi - deployment/container-port: 8081 + deployment/container-port: 8080 kubernetes: - uri: deploy.yaml + uri: kubernetes/deploy.yaml endpoints: - - name: http-8081 - targetPort: 8081 + - name: http-8080 + targetPort: 8080 path: / -commands: - - id: build-image - apply: - component: image-build - - id: deployk8s - apply: - component: kubernetes-deploy - - id: deploy - composite: - commands: - - build-image - - deployk8s - group: - kind: deploy - isDefault: true + diff --git a/docker/Dockerfile b/docker/Dockerfile index 89eca3285..274925853 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,8 @@ FROM registry.access.redhat.com/ubi9/python-39:1-117.1684741281 -# By default, listen on port 8081 -EXPOSE 8081/tcp -ENV FLASK_PORT=8081 +# By default, listen on port 8080 +EXPOSE 8080/tcp +ENV FLASK_PORT=8080 # Set the working directory in the container WORKDIR /projects diff --git a/deploy.yaml b/kubernetes/deploy.yaml similarity index 100% rename from deploy.yaml rename to kubernetes/deploy.yaml From 750aa40206f36884509d0fe4327fc7afded6d226 Mon Sep 17 00:00:00 2001 From: thepetk Date: Mon, 9 Oct 2023 16:27:53 +0100 Subject: [PATCH 2/7] Update ports in deploy.yaml Signed-off-by: thepetk --- kubernetes/deploy.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kubernetes/deploy.yaml b/kubernetes/deploy.yaml index a8a92259d..0bccf23cd 100644 --- a/kubernetes/deploy.yaml +++ b/kubernetes/deploy.yaml @@ -17,7 +17,7 @@ spec: image: python-image:latest ports: - name: http - containerPort: 8081 + containerPort: 8080 protocol: TCP resources: requests: @@ -29,10 +29,10 @@ apiVersion: v1 metadata: name: my-python spec: -ports: - - name: http-8081 - port: 8081 - protocol: TCP - targetPort: 8081 -selector: - app: python-app + ports: + - name: http-8080 + port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: python-app From d9a484a0045f26d85160b3739874a14efc8c47cd Mon Sep 17 00:00:00 2001 From: thepetk Date: Wed, 18 Oct 2023 14:50:24 +0100 Subject: [PATCH 3/7] Update devfile version Signed-off-by: thepetk --- devfile.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devfile.yaml b/devfile.yaml index 77a3c62e7..525e1b042 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -8,7 +8,7 @@ metadata: 'Python 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.' language: Python - version: 1.0.2 + version: 2.0.0 provider: Red Hat tags: - Python From 728c7830b77982ebded9b38c78dba17d91425f2c Mon Sep 17 00:00:00 2001 From: thepetk Date: Wed, 18 Oct 2023 14:51:25 +0100 Subject: [PATCH 4/7] Update readme.md Signed-off-by: thepetk --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b5ba6e0c7..aae24b561 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Creating an application with a Python code sample -**Note:** The Python code sample version `1.0.2` uses the **8080** HTTP port. +**Note:** The Python code sample version `2.0.0` uses the **8080** HTTP port. 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: From cb2e6cc4d05327f17a81d81c969f66d0c6537e08 Mon Sep 17 00:00:00 2001 From: thepetk Date: Tue, 7 Nov 2023 15:36:13 +0000 Subject: [PATCH 5/7] Finalize devfile version Signed-off-by: thepetk --- README.md | 2 +- app.py | 2 +- devfile.yaml | 28 +++------------------------- docker/Dockerfile | 6 +++--- kubernetes/deploy.yaml | 8 ++++---- 5 files changed, 12 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index aae24b561..e44e34940 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Creating an application with a Python code sample -**Note:** The Python code sample version `2.0.0` uses the **8080** HTTP port. +**Note:** The Python code sample version `2.0.0` uses the **8081** HTTP port. 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: diff --git a/app.py b/app.py index c0f3d87d8..8372852df 100644 --- a/app.py +++ b/app.py @@ -8,7 +8,7 @@ def hello(): return "Hello World!" if __name__ == '__main__': - port = os.environ.get('FLASK_PORT') or 8080 + port = os.environ.get('FLASK_PORT') or 8081 port = int(port) app.run(port=port,host='0.0.0.0') \ No newline at end of file diff --git a/devfile.yaml b/devfile.yaml index 525e1b042..942ea5a66 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -21,39 +21,17 @@ parent: id: python registryUrl: 'https://registry.devfile.io' version: 3.0.0 - commands: - - id: build-image - apply: - component: build - - id: deployk8s - apply: - component: deploy - - id: deploy - composite: - commands: - - build-image - - deployk8s - group: - kind: deploy - isDefault: true components: - - name: build - image: - imageName: python-image:latest - dockerfile: - uri: docker/Dockerfile - buildContext: . - rootRequired: false - name: deploy attributes: deployment/replicas: 1 deployment/cpuRequest: 10m deployment/memoryRequest: 50Mi - deployment/container-port: 8080 + deployment/container-port: 8081 kubernetes: uri: kubernetes/deploy.yaml endpoints: - - name: http-8080 - targetPort: 8080 + - name: http-8081 + targetPort: 8081 path: / diff --git a/docker/Dockerfile b/docker/Dockerfile index 274925853..89eca3285 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,8 @@ FROM registry.access.redhat.com/ubi9/python-39:1-117.1684741281 -# By default, listen on port 8080 -EXPOSE 8080/tcp -ENV FLASK_PORT=8080 +# By default, listen on port 8081 +EXPOSE 8081/tcp +ENV FLASK_PORT=8081 # Set the working directory in the container WORKDIR /projects diff --git a/kubernetes/deploy.yaml b/kubernetes/deploy.yaml index 0bccf23cd..b7fe06d64 100644 --- a/kubernetes/deploy.yaml +++ b/kubernetes/deploy.yaml @@ -17,7 +17,7 @@ spec: image: python-image:latest ports: - name: http - containerPort: 8080 + containerPort: 8081 protocol: TCP resources: requests: @@ -30,9 +30,9 @@ metadata: name: my-python spec: ports: - - name: http-8080 - port: 8080 + - name: http-8081 + port: 8081 protocol: TCP - targetPort: 8080 + targetPort: 8081 selector: app: python-app From 4651d75d8607be68bee0295ab347d9df617c1406 Mon Sep 17 00:00:00 2001 From: thepetk Date: Tue, 7 Nov 2023 15:38:03 +0000 Subject: [PATCH 6/7] Revert update to port --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 8372852df..c0f3d87d8 100644 --- a/app.py +++ b/app.py @@ -8,7 +8,7 @@ def hello(): return "Hello World!" if __name__ == '__main__': - port = os.environ.get('FLASK_PORT') or 8081 + port = os.environ.get('FLASK_PORT') or 8080 port = int(port) app.run(port=port,host='0.0.0.0') \ No newline at end of file From a3479e060ddf8e865327da0c0b42fb8581ebffd7 Mon Sep 17 00:00:00 2001 From: thepetk Date: Mon, 27 Nov 2023 12:55:23 +0000 Subject: [PATCH 7/7] Update port to 8080 Signed-off-by: thepetk --- README.md | 13 +++++++------ devfile.yaml | 6 +++--- docker/Dockerfile | 10 +++++----- kubernetes/deploy.yaml | 8 ++++---- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index e44e34940..bee2955fa 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Creating an application with a Python code sample -**Note:** The Python code sample version `2.0.0` uses the **8081** HTTP port. +**Note:** The Python code sample version `2.0.0` uses the **8080** HTTP port. 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: -* [Python `devfile.yaml`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/devfile.yaml) -* [Python `Dockerfile`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/docker/Dockerfile) +- [Python `devfile.yaml`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/devfile.yaml) +- [Python `Dockerfile`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/main/docker/Dockerfile) 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`. 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. @@ -13,6 +13,7 @@ Before you begin creating an application with this `devfile` code sample, it's h 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. ### Additional resources -* For more information about Python, see [Python](https://www.python.org/). -* For more information about devfiles, see [Devfile.io](https://devfile.io/). -* For more information about Dockerfiles, see [Dockerfile reference](https://docs.docker.com/engine/reference/builder/). \ No newline at end of file + +- For more information about Python, see [Python](https://www.python.org/). +- For more information about devfiles, see [Devfile.io](https://devfile.io/). +- For more information about Dockerfiles, see [Dockerfile reference](https://docs.docker.com/engine/reference/builder/). diff --git a/devfile.yaml b/devfile.yaml index 942ea5a66..ae4d3c9f4 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -27,11 +27,11 @@ parent: deployment/replicas: 1 deployment/cpuRequest: 10m deployment/memoryRequest: 50Mi - deployment/container-port: 8081 + deployment/container-port: 8080 kubernetes: uri: kubernetes/deploy.yaml endpoints: - - name: http-8081 - targetPort: 8081 + - name: http-8080 + targetPort: 8080 path: / diff --git a/docker/Dockerfile b/docker/Dockerfile index 89eca3285..c879f303f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,8 @@ FROM registry.access.redhat.com/ubi9/python-39:1-117.1684741281 -# By default, listen on port 8081 -EXPOSE 8081/tcp -ENV FLASK_PORT=8081 +# By default, listen on port 8080 +EXPOSE 8080/tcp +ENV FLASK_PORT=8080 # Set the working directory in the container WORKDIR /projects @@ -13,9 +13,9 @@ COPY . . # Install any dependencies RUN \ if [ -f requirements.txt ]; \ - then pip install -r requirements.txt; \ + then pip install -r requirements.txt; \ elif [ `ls -1q *.txt | wc -l` == 1 ]; \ - then pip install -r *.txt; \ + then pip install -r *.txt; \ fi # Specify the command to run on container start diff --git a/kubernetes/deploy.yaml b/kubernetes/deploy.yaml index b7fe06d64..0bccf23cd 100644 --- a/kubernetes/deploy.yaml +++ b/kubernetes/deploy.yaml @@ -17,7 +17,7 @@ spec: image: python-image:latest ports: - name: http - containerPort: 8081 + containerPort: 8080 protocol: TCP resources: requests: @@ -30,9 +30,9 @@ metadata: name: my-python spec: ports: - - name: http-8081 - port: 8081 + - name: http-8080 + port: 8080 protocol: TCP - targetPort: 8081 + targetPort: 8080 selector: app: python-app