[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Getting started with buildpacks\n\nKf supports a variety of buildpacks. This document covers some starter examples for using them.\n\nBefore you begin\n----------------\n\n- You should have Kf running on a cluster.\n- You should have run `kf target -s \u003cspace-name\u003e` to target your space.\n\nJava (v2) Buildpack\n-------------------\n\nUse [spring initializr](https://start.spring.io/) to create a Java 8 maven project with a spring web dependency and JAR packaging. Download it, extract it, and once extracted you can generate a JAR. \n\n ./mvnw package\n\nPush the JAR to Kf with the Java v2 buildpack. \n\n kf push java-v2 --path target/helloworld-0.0.1-SNAPSHOT.jar\n\nJava (v3) Buildpack\n-------------------\n\nUse [spring initializr](https://start.spring.io/) to create a Java 8 maven project with a spring web dependency and JAR packaging. Download it, extract it, and once extracted, push to Kf with the cloud native buildpack. \n\n kf push java-v3 --stack org.cloudfoundry.stacks.cflinuxfs3\n\nPython (v2) Buildpack\n---------------------\n\nCreate a new directory with files as shown in the following structure. \n\n tree\n .\n ├── Procfile\n ├── requirements.txt\n └── server.py\n\n cat Procfile\n web: python server.py\n\n cat requirements.txt\n Flask\n\n cat server.py\n from flask import Flask\n import os\n app = Flask(__name__)\n @app.route('/')\n def hello_world():\n return 'Hello, World!'\n if __name__ == \"__main__\":\n port = int(os.getenv(\"PORT\", 8080))\n app.run(host='0.0.0.0', port=port)\n\nPush the Python flask app using v2 buildpacks. \n\n kf push python --buildpack python\\_buildpack\n\nPython (v3) Buildpack\n---------------------\n\n(same as above)\n\nPush the Python flask app using cloud native buildpacks. \n\n kf push pythonv3 --stack org.cloudfoundry.stacks.cflinuxfs3\n\nStaticfile (v2) Buildpack\n-------------------------\n\nCreate a new directory that holds your source code.\n\nAdd an `index.html` file with this content. \n\n \u003c!DOCTYPE html\u003e\n\n \u003chtml lang=\"en\"\u003e\n\n \u003chead\u003e\u003ctitle\u003eHello, world!\u003c/title\u003e\u003c/head\u003e\n\n \u003cbody\u003e\u003ch1\u003eHello, world!\u003c/h1\u003e\u003c/body\u003e\n\n \u003c/html\u003e\n\nPush the static content with the staticfile buildpack. \n\n kf push staticsite --buildpack staticfile\\_buildpack\n\nRelated documents\n=================\n\n- [Customizing buildbacks](/migrate/kf/docs/2.1/how-to/customizing-buildpacks)"]]