IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. # Focker
  2. ## Introduction
  3. Focker is a FreeBSD image orchestration tool in the vein of Docker.
  4. ## Installation
  5. In order to use Focker you need a ZFS pool available in your FreeBSD installation.
  6. ### Installing the Python package from PyPi
  7. Run:
  8. ```bash
  9. pip install focker
  10. ```
  11. ### Installing the Python package from GitHub
  12. Run:
  13. ```bash
  14. git clone https://github.com/sadaszewski/focker.git
  15. cd focker/
  16. python setup.py install
  17. ```
  18. or (if you want an uninstaller):
  19. ```bash
  20. git clone https://github.com/sadaszewski/focker.git
  21. cd focker/
  22. python setup.py sdist
  23. pip install dist/focker-0.9.tgz
  24. ```
  25. ### Setting up ZFS
  26. Upon first execution of the `focker` command, Focker will automatically create the necessary directories and ZFS datasets. You just need to exclude the unlikely case that you are already using `/focker` in your filesystem hierarchy. The layout after initialization will look the following:
  27. ```
  28. /focker
  29. /focker/images
  30. /focker/jails
  31. /focker/volumes
  32. ```
  33. `images`, `jails`, and `volumes` have corresponding ZFS datasets with `canmount=off` so that they serve as mountpoint anchors for child entries.
  34. ### Preparing base image
  35. To bootstrap the images system you need to install FreeBSD in jail mode to a ZFS dataset placed in `/focker/images` and provide two user-defined properties - `focker:sha256` and `focker:tags`. One way to achieve this would be the following (using Bash shell):
  36. ```bash
  37. TAGS="freebsd-latest freebsd-$(freebsd-version | cut -d'-' -f1)"
  38. VERSION="FreeBSD $(freebsd-version)"
  39. SHA256=$(echo -n ${VERSION} | sha256)
  40. NAME=${SHA256:0:7}
  41. zfs create -o focker:sha256=${SHA256} -o focker:tags="${TAGS}" zroot/focker/images/${NAME}
  42. bsdinstall jail /focker/images/${NAME}
  43. zfs set readonly=on zroot/focker/images/${NAME}
  44. zfs snapshot zroot/focker/images/${NAME}@1
  45. ```
  46. ## Usage
  47. At this point, Focker is ready to use.
  48. ### `focker` command syntax
  49. The `focker` command is the single entrypoint to all of the Focker's functionality. The overview of its syntax is presented below as a tree where the `focker` command is the root, the first level of descendants represents the choice of Level 1 mode (`image`, `jail`, `volume` or `compose`), the second level - the Level 2 mode (dependent on L1 mode) and the final third level lists required and optional arguments specific to the given combination of L1/L2 modes.
  50. ```
  51. focker
  52. |- image|img|im|i
  53. | |- build|b
  54. | | |- FOCKER_DIR
  55. | | `- --tags|-t TAG [...TAG]
  56. | |- tag|t
  57. | | |- REFERENCE
  58. | | `- TAG [...TAG]
  59. | |- untag|u
  60. | | `- TAG [...TAG]
  61. | |- list|ls|l
  62. | | `- --full-sha256|-f
  63. | |- prune|p
  64. | `- remove|r
  65. | |- REFERENCE
  66. | `- --remove-dependents|-R
  67. |- jail|j
  68. | |- create|c
  69. | | |- IMAGE
  70. | | |- --command|-c COMMAND (default: /bin/sh)
  71. | | |- --env|-e VAR1:VALUE1 [...VARN:VALUEN]
  72. | | |- --mounts|-m FROM1:ON1 [...FROMN:ONN]
  73. | | `- --hostname|-n HOSTNAME
  74. | |- start|s
  75. | | `- REFERENCE
  76. | |- stop|S
  77. | | `- REFERENCE
  78. | |- remove|r
  79. | | `- REFERENCE
  80. | |- exec|e
  81. | | |- REFERENCE
  82. | | `- [...COMMAND]
  83. | |- oneshot|o
  84. | | `- IMAGE
  85. | | `- --env|-e VAR1:VALUE1 [...VARN:VALUEN]
  86. | | `- --mounts|-m FROM1:ON1 [...FROMN:ONN]
  87. | | `- [...COMMAND]
  88. | |- list|ls|l
  89. | | `- --full-sha256|-f
  90. | |- tag|t
  91. | | |- REFERENCE
  92. | | `- TAG [...TAG]
  93. | |- untag|u
  94. | | `- TAG [...TAG]
  95. | `- prune|p
  96. | `- --force|-f
  97. |- volume
  98. | |- create
  99. | | `- --tags|-t TAG [...TAG]
  100. | |- prune
  101. | |- list
  102. | | `- --full-sha256|-f
  103. | |- tag
  104. | | |- REFERENCE
  105. | | `- TAG [...TAG]
  106. | `- untag
  107. | `- TAG [...TAG]
  108. `- compose
  109. |- build
  110. | `- FILENAME
  111. `- run
  112. |- FILENAME
  113. `- COMMAND
  114. ```
  115. Individual combinations are briefly described below:
  116. #### focker image|img|im|i
  117. The `focker image` mode groups commands related to Focker images.
  118. ##### build|b FOCKER_DIR [--tags TAG [...TAG]]
  119. Build a Focker image according to the specification in a Fockerfile present in the specified FOCKER_DIR. Fockerfile syntax is very straightforward and explained below.
  120. ##### tag|t REFERENCE TAG [...TAG]
  121. Applies one or more tags to the given image. REFERENCE can be the SHA256 of an image or one of its existing tags. It can be just a few first characters as long as they are unambiguous.
  122. ##### untag|u TAG [...TAG]
  123. Removes one or more image tags.
  124. ##### list|ls|l [--full-sha256|-f]
  125. Lists existing Focker images, optionally with full SHA256 checksums (instead of the default 7 first characters).
  126. ##### prune|p
  127. Greedily removes existing Focker images without tags and without dependents.
  128. ##### remove|r REFERENCE
  129. Removes the specified image.
  130. #### focker jail|j
  131. The `focker jail` mode groups commands related to Focker-managed jails.
  132. ##### create|c IMAGE [--command|-c COMMAND] [--env|-e VAR1:VALUE1 [...VARN:VALUEN]] [--mounts|-m FROM1:ON1 [...FROMN:ONN]] [--hostname|-n HOSTNAME]
  133. Creates a new Focker-managed jail. A jail consists of a clone of the given `IMAGE` and an entry in `/etc/jail.conf`. The configuration entry uses `exec.prestart` and `exec.start` to specify how the runtime environment (mounts and environmental variables) should be set up. It also calls `COMMAND` as last in `exec.start`. If not specified `COMMAND` defaults to `/bin/sh`. The hostname can be specified using the `HOSTNAME` parameter. Mounts and environment variables are provided as tuples separated by a colon (:). The environmental variable specification consists of variable name followed by variable value. The mount specification consists of the "from path", followed by the "on path". "From path" can be a local system path or a volume name.
  134. ##### start|s REFERENCE
  135. Starts the given jail specified by `REFERENCE`. `REFERENCE` can be the SHA256 of an existing jail or one of its existing tags. It can be just a few first characters as long as they are unambiguous. This command is equivalent of calling `jail -c`.
  136. ##### stop|S REFERENCE
  137. Stops the given jail specified by `REFERENCE`. This command is equivalent to calling `jail -r`.
  138. ##### remove|r REFERENCE
  139. Removes the given jail specified by `REFERENCE`. The jail is stopped if running, any filesystems mounted under its root directory are unmounted, its ZFS dataset and entry in `/etc/jail.conf` are removed.
  140. ##### exec|e REFERENCE [...COMMAND]
  141. Executes given `COMMAND` (or `/bin/sh` if not specified) in the given running jail specified by `REFERENCE`. This command is the equivalent of calling `jexec`.
  142. ##### oneshot|o IMAGE [--env|-e VAR1:VALUE1 [...VARN:VALUEN]] [--mounts|-m FROM1:ON1 [...FROMN:ONN]] [...COMMAND]
  143. Create a new one-time Focker-managed jail. The syntax and logic is identical to `focker jail create`, the difference being that the hostname cannot be specified and that the jail will be automatically removed when the `COMMAND` exits.
  144. Example: `focker jail oneshot freebsd-latest -e FOO:bar -- ls -al`
  145. ##### list|ls|l
  146. Lists Focker-managed jails. For running jails their JIDs will be displayed.
  147. ##### tag REFERENCE TAG [...TAG]
  148. Applies one or more tags to the given jail. REFERENCE can be the SHA256 of a jail or one of its existing tags. It can be just a few first characters as long as they are unambiguous.
  149. ##### untag TAG [...TAG]
  150. Removes one or more jail tags.
  151. ##### prune
  152. Removes existing Focker jails without tags.
  153. #### focker volume
  154. The `focker volume` mode groups commands related to Focker volumes.
  155. ##### create [--tags|-t TAG [...TAG]]
  156. Create a new Focker volume optionally tagged with the given `TAG`s.
  157. ##### prune
  158. Removes existing Focker volumes without tags.
  159. ##### list [--full-sha256|-f]
  160. Lists existing Focker volumes. Full SHA256 is displayed if the `-f` switch is used, otherwise only the first 7 characters will be shown.
  161. ##### tag REFERENCE TAG [...TAG]
  162. Applies one or more tags to the given volume. REFERENCE can be the SHA256 of a volume or one of its existing tags. It can be just a few first characters as long as they are unambiguous.
  163. ##### untag TAG [...TAG]
  164. Removes one or more volume tags.
  165. #### focker compose
  166. The `focker compose` mode groups commands related to Focker composition files - `focker-compose.yml`.
  167. ##### build
  168. ##### run
  169. ### `Fockerfile` syntax
  170. A sample `Fockerfile` is pasted below.
  171. ```yaml
  172. base: freebsd-latest
  173. steps:
  174. - copy:
  175. - [ '/tmp/x', '/etc/x' ]
  176. - [ 'files/y', '/etc/y' ]
  177. - run: |
  178. pkg install -y python3 && \
  179. pkg install -y py37-pip && \
  180. pkg install -y py37-yaml && \
  181. pkg install -y py37-certbot && \
  182. mkdir -p /persist/etc/ssh && \
  183. sed -i '' -e 's/\/etc\/ssh\/ssh_host_/\/persist\/etc\/ssh\/ssh_host_/g' /etc/rc.d/sshd && \
  184. sed -i '' -e 's/\/etc\/ssh\/ssh_host_/\/persist\/etc\/ssh\/ssh_host_/g' /etc/ssh/sshd_config && \
  185. sed -i '' -e 's/#HostKey/HostKey/g' /etc/ssh/sshd_config
  186. ```
  187. ### `focker-compose.yml` syntax
  188. A sample composition file illustrating all of the principles is pasted below.
  189. ```yaml
  190. images:
  191. wordpress-5: /path/to/wordpress_5_focker_dir
  192. jails:
  193. wordpress:
  194. image: wordpress-5
  195. env:
  196. SITE_NAME: Test site
  197. mounts:
  198. wp-volume2: /mnt/volume2
  199. wp-volume1: /mnt/volume1
  200. ip4.addr: 127.0.1.1
  201. interface: lo1
  202. volumes:
  203. wp-volume1: {}
  204. wp-volume2: {}
  205. wp-backup: {}
  206. commands:
  207. backup:
  208. jail: wordpress
  209. command: |
  210. mysqldump >/mnt/volume2/backup.sql
  211. mounts:
  212. wp-backup: /mnt/backup
  213. restore:
  214. jail: wordpress
  215. command: |
  216. mysql </mnt/volume2/backup.sql
  217. mounts:
  218. wp-backup: /mnt/backup
  219. ```
  220. #### Images
  221. #### Jails
  222. #### Volumes
  223. #### Commands