github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/Documentation/examples/build-container/README.md (about) 1 # Build container examples 2 3 This directory includes two examples of scripts that build ACI images. 4 One is a generic [PostgreSQL][postgresql] image and the other is an example [Play Framework][play-framework] app that connects to a PostgreSQL database. 5 The example Play Framework app expects a PostgreSQL database, so both images can be used in a single pod to make the example run. 6 7 ## PostgreSQL 8 9 The PostgreSQL image is based on [Alpine Linux][alpine-linux] and defines two mounts, one for a PostgreSQL data directory that will be used if present, and another for an SQL script that can be used to initialize the database. 10 By default, if no data is found in the PostgreSQL data directory, a database named `rkt` will be created with user and password set to `rkt` too. 11 Then, the initialization SQL script will run. 12 If a PostgreSQL data directory is found in the corresponding mount, it will be used instead. 13 14 ## Example Play Framework app 15 16 This is a very simple [example Play Framework app][play-framework-example] that just prints the number of times a page is retrieved. 17 This value is stored in a PostgreSQL database. 18 19 ## Build the images 20 21 You can build the images by running their build scripts. 22 They use [containers/build][containers-build] so you'll need to get the [latest release][build-release]. 23 Assuming a privileged shell is running in this directory. 24 25 ``` 26 # (cd postgres && ./build-postgres.sh) 27 [...] 28 # (cd play-example && ./build-play-example.sh) 29 [...] 30 ``` 31 32 Once they're done building you should have an ACI image on each directory: 33 34 ``` 35 # ls */*.aci 36 play-example/play-latest-linux-amd64.aci postgres/postgres-latest-linux-amd64.aci 37 ``` 38 39 ## Run the example 40 41 You simply need to run rkt with a volume pointing to the play example SQL customization script. 42 Assuming a privileged shell is running in this directory: 43 44 ``` 45 # rkt --insecure-options=image \ 46 run \ 47 --volume custom-sql,kind=host,source=$PWD/play-example/custom.sql \ 48 postgres/postgres-latest-linux-amd64.aci \ 49 play-example/play-latest-linux-amd64.aci 50 ``` 51 52 After it is running and initialized, you need to retrieve the pod IP address and you can access it on port 9000: 53 54 ``` 55 # rkt list 56 UUID APP IMAGE NAME STATE CREATED STARTED NETWORKS 57 a94b94eb postgres example.com/postgres running 11 seconds ago 11 seconds ago default:ip4=172.16.28.26 58 play-example example.com/play-example:17.10 59 # curl 172.16.28.26:9000 60 [...] 61 This page has been retrieved 0 times. 62 [...] 63 # curl 172.16.28.26:9000 64 [...] 65 This page has been retrieved 1 times. 66 [...] 67 ``` 68 69 [postgresql]: https://www.postgresql.org 70 [play-framework]: https://www.playframework.com 71 [alpine-linux]: https://alpinelinux.org 72 [play-framework-example]: https://github.com/ics-software-engineering/play-example-postgresql 73 [containers-build]: https://github.com/containers/build 74 [build-release]: https://github.com/containers/build/releases