gopkg.in/openshift/source-to-image.v1@v1.2.0/pkg/create/templates/readme.go (about) 1 package templates 2 3 // Readme is a default README laid down by s2i create 4 const Readme = ` 5 # Creating a basic S2I builder image 6 7 ## Getting started 8 9 ### Files and Directories 10 | File | Required? | Description | 11 |------------------------|-----------|--------------------------------------------------------------| 12 | Dockerfile | Yes | Defines the base builder image | 13 | s2i/bin/assemble | Yes | Script that builds the application | 14 | s2i/bin/usage | No | Script that prints the usage of the builder | 15 | s2i/bin/run | Yes | Script that runs the application | 16 | s2i/bin/save-artifacts | No | Script for incremental builds that saves the built artifacts | 17 | test/run | No | Test script for the builder image | 18 | test/test-app | Yes | Test application source code | 19 20 #### Dockerfile 21 Create a *Dockerfile* that installs all of the necessary tools and libraries that are needed to build and run our application. This file will also handle copying the s2i scripts into the created image. 22 23 #### S2I scripts 24 25 ##### assemble 26 Create an *assemble* script that will build our application, e.g.: 27 - build python modules 28 - bundle install ruby gems 29 - setup application specific configuration 30 31 The script can also specify a way to restore any saved artifacts from the previous image. 32 33 ##### run 34 Create a *run* script that will start the application. 35 36 ##### save-artifacts (optional) 37 Create a *save-artifacts* script which allows a new build to reuse content from a previous version of the application image. 38 39 ##### usage (optional) 40 Create a *usage* script that will print out instructions on how to use the image. 41 42 ##### Make the scripts executable 43 Make sure that all of the scripts are executable by running *chmod +x s2i/bin/** 44 45 #### Create the builder image 46 The following command will create a builder image named {{.ImageName}} based on the Dockerfile that was created previously. 47 ` + 48 "```\n" + 49 "docker build -t {{.ImageName}} .\n" + 50 "```\n" + 51 `The builder image can also be created by using the *make* command since a *Makefile* is included. 52 53 Once the image has finished building, the command *s2i usage {{.ImageName}}* will print out the help info that was defined in the *usage* script. 54 55 #### Testing the builder image 56 The builder image can be tested using the following commands: 57 ` + 58 "```\n" + 59 "docker build -t {{.ImageName}}-candidate .\n" + 60 "IMAGE_NAME={{.ImageName}}-candidate test/run\n" + 61 "```\n" + 62 `The builder image can also be tested by using the *make test* command since a *Makefile* is included. 63 64 #### Creating the application image 65 The application image combines the builder image with your applications source code, which is served using whatever application is installed via the *Dockerfile*, compiled using the *assemble* script, and run using the *run* script. 66 The following command will create the application image: 67 ` + 68 "```\n" + 69 "s2i build test/test-app {{.ImageName}} {{.ImageName}}-app\n" + 70 "---> Building and installing application from source...\n" + 71 "```\n" + 72 `Using the logic defined in the *assemble* script, s2i will now create an application image using the builder image as a base and including the source code from the test/test-app directory. 73 74 #### Running the application image 75 Running the application image is as simple as invoking the docker run command: 76 ` + 77 "```\n" + 78 "docker run -d -p 8080:8080 {{.ImageName}}-app\n" + 79 "```\n" + 80 `The application, which consists of a simple static web page, should now be accessible at [http://localhost:8080](http://localhost:8080). 81 82 #### Using the saved artifacts script 83 Rebuilding the application using the saved artifacts can be accomplished using the following command: 84 ` + 85 "```\n" + 86 "s2i build --incremental=true test/test-app nginx-centos7 nginx-app\n" + 87 "---> Restoring build artifacts...\n" + 88 "---> Building and installing application from source...\n" + 89 "```\n" + 90 `This will run the *save-artifacts* script which includes the custom code to backup the currently running application source, rebuild the application image, and then re-deploy the previously saved source using the *assemble* script. 91 `