diff --git a/README.md b/README.md index e96053f1e4..1b5eafd6e7 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,22 @@ # Creating an application with a Python code sample -**Note:** The Python code sample 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 Sample `devfile.yaml`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/v2.0.0/devfile.yaml) +- [Python Sample `Dockerfile`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/v2.0.0/docker/Dockerfile) +- [Parent Python Stack `devfile.yaml`](https://github.com/devfile/registry/blob/main/stacks/python/3.0.0/devfile.yaml) -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. -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. -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. +This code sample inherits the components and commands of the specified parent devfile. The sample devfile overrides and extends parts of the parent devfile, in this case parts of the `deploy` component. + +1. The parent `devfile.yaml` file has an [`build` component](https://github.com/devfile/registry/blob/main/stacks/python/3.0.0/devfile.yaml#L39-L45) that points to your `Dockerfile`. +2. The [`docker/Dockerfile`](https://github.com/devfile-samples/devfile-sample-python-basic/blob/v2.0.0/docker/Dockerfile) contains the instructions you need to build the code sample as a container image. +3. The `devfile.yaml` [`deploy` component](https://github.com/devfile-samples/devfile-sample-python-basic/blob/v2.0.0/devfile.yaml#L25-L37) overrides the parent `deploy` and points to a `deploy.yaml` file that contains instructions for deploying the built container image. +4. The parent `devfile.yaml` [`deploy` command](https://github.com/devfile/registry/blob/main/stacks/python/3.0.0/devfile.yaml#L82-L89) completes the [outerloop](https://devfile.io/docs/2.2.0/innerloop-vs-outerloop) deployment phase by pointing to the `build` and `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 b4572435c9..6cb1698acd 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: 2.0.0 provider: Red Hat tags: - Python @@ -20,38 +20,19 @@ metadata: parent: id: python registryUrl: 'https://registry.devfile.io' -components: - - name: image-build - image: - imageName: python-image:latest - dockerfile: - uri: docker/Dockerfile - buildContext: . - rootRequired: false - - name: kubernetes-deploy - attributes: - deployment/replicas: 1 - deployment/cpuRequest: 10m - deployment/memoryRequest: 50Mi - deployment/container-port: 8081 - kubernetes: - uri: deploy.yaml - endpoints: - - name: http-8081 - targetPort: 8081 - 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 + version: 3.0.0 + components: + - name: deploy + attributes: + deployment/replicas: 1 + deployment/cpuRequest: 10m + deployment/memoryRequest: 50Mi + deployment/container-port: 8080 + kubernetes: + uri: kubernetes/deploy.yaml + endpoints: + - name: http-8080 + targetPort: 8080 + path: / + secure: true + diff --git a/docker/Dockerfile b/docker/Dockerfile index 89eca32856..c879f303ff 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/deploy.yaml b/kubernetes/deploy.yaml similarity index 76% rename from deploy.yaml rename to kubernetes/deploy.yaml index a8a92259d1..0bccf23cd4 100644 --- a/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