1
1
# Community Driven Docker Examples
2
- These docker containers are meant to serve as an isolated develop/deployment environment. Each docker container has the
3
- terraform libvirt provider built and placed in the custom plugins folder. The most common use case for these containers
4
- is to run your terraform environment in a isolate container talking to a ` remote ` libvirt system.
2
+ These docker containers are meant to serve as an isolated development environment. The most common use case for these
3
+ containers is to run your terraform environment in a isolate container talking to a ` remote ` libvirt system.
5
4
6
5
Please refer to the distro's ` README.md ` for specific instructions.
7
6
@@ -10,62 +9,70 @@ folder will compile the terraform libvirt provider for you. Please refer to the
10
9
information and instructions.
11
10
12
11
## Table of Content
12
+
13
+ ** Distro Containers**
13
14
- [ Alpine Containers] ( Alpine/ )
14
- - [ Build Containers] ( Build/ )
15
15
- [ Debian Conainers] ( Debian/ )
16
16
- [ openSUSE Containers] ( openSUSE/ )
17
17
18
+ ** Build Containers**
19
+ - [ Build Containers] ( Build/ )
20
+
21
+
22
+ ## Quickstart
23
+ 1 . Grab the all-in-one container for the distro you want, in this case we are using ` openSUSE `
24
+ ``` console
25
+ git clone https://github.com/dmacvicar/terraform-provider-libvirt.git; cd ./terraform-provider-libvirt/contrib/openSUSE/
26
+ ```
27
+ 2. Build the all-in-one container
28
+ ```console
29
+ docker build -f Dockerfile_all_in_one -t terraform:development-tumbleweed . --build-arg GO_OS=linux --build-arg GO_ARCH=amd64
30
+ ```
31
+ 3. Run the docker container
32
+ ```console
33
+ docker run -it terraform:development-tumbleweed /bin/bash
34
+ ```
18
35
19
36
## General Usage
20
37
There are two types of containers you'll find for each distro, `All-in-One` and `Build-Dependent`.
21
38
22
39
### All-in-One v.s Build-Dependent Containers
23
40
The `All-in-One` container is a single Dockerfile that you can build and run. The Dockerfile takes advantage of
24
- Docker's multi-stage build functionality. It allows you to build a binary or object in a "sub container" and then
25
- access the binary or object in your "main container". This Dockerfile is useful if you want to get up and running
41
+ Docker's multi-stage build functionality. It allows you to build a binary object in a "sub container" and then
42
+ access the binary object in your "main container". This Dockerfile is useful if you want to get up and running
26
43
quickly, but might lead to confusion down the road if plan on using multiple versions of the terraform libvirt provider.
27
44
28
45
The `Build-Dependent` container relies on another Dockerfile which contains the build of the plugin. To use this
29
46
container you need to first build the appropriate build Dockerfile and tag it correctly. Once that is done, you are
30
47
able to reference it inside the `Build-Dependent`'s Dockerfile. This design is useful when you are dealing with
31
- multiple versions of the terraform libvirt provider such as a stable build , ` 0.5.2 ` , which works with Terraform ` 0.11.X `
32
- and the less stable branch, ` master ` , which currently works with Terraform ` 0.12.x ` .
48
+ multiple versions of the terraform libvirt provider such as, `0.5.2`, which works with Terraform `0.11.X`
49
+ and the latest branch, `master`, which currently works with Terraform `0.12.x`.
33
50
34
- ### Build Args
35
- There are a couple build args to be aware of when building these various containers.
51
+ ### Build Argument Reference
52
+ The following arguments are supported:
36
53
37
- For the ` Build ` containers, you will only need to worry about the ` VERSION ` arg. The ` VERSION ` arg lets you build a specific
38
- branch/tag of the terraform libvirt provider.
54
+ - `VERSION` - (Required) A name of a branch or tag of the terraform libvirt plugin to build
55
+ - `TERRAFORM_VERSION` - (Optional) - A tag of the official docker terraform image to pull from
56
+ - `GO_ARCH` - (Required) The GO name of your given architecture
57
+ - `GO_OS` - (Required) The GO name of your given OS
39
58
59
+ ### Examples
60
+ `Build` containers examples:
40
61
41
-
42
- Build Examples:
43
62
```console
44
63
docker build -f Dockerfile_glibc -t provider-libvirt:v0.5.2-glibc . --build-arg VERSION=v0.5.2
45
64
```
46
65
47
- This command would checkout the tag ` v0.5.2 ` , thus building the terraform libvirt provider with the given code in
48
- ` v0.5.2 ` .
66
+ This command would checkout the tag ` v0.5.2 ` .
49
67
50
68
``` console
51
69
docker build -f Dockerfile_glibc -t provider-libvirt:master-glibc . --build-arg VERSION=master
52
70
```
53
71
54
- This command would checkout the ` master ` branch, thus building the latest code.
55
-
56
- For the ` distro ` containers there are three build args, ` TERRAFORM_VERSION ` , ` GO_ARCH ` , and ` GO_OS ` .
57
-
58
- The build arg, ` TERRAFORM_VERSION ` , lets you select which terraform version you want to run. By default this is set to
59
- ` 0.12.0 ` , but can be overwritten by setting it in a Docker ` build-arg ` .
60
-
61
- The ` GO_ARCH ` and ` GO_OS ` need to be passed in when building the container as they do ** not** have defaults. The purpose
62
- of these args are to allow multiple architectures to run these docker containers, see
63
- [ below] ( #Running-on-non-supported-Terraform-Architectures ) . If you are unsure of what your ` GO_ARCH ` and ` GO_OS `
64
- should be please refer to [ this] ( https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63 ) . For most users
65
- running on ` amd64 ` , use ` GO_OS=linux ` and ` GO_ARCH=amd64 ` .
72
+ This command would checkout the ` master ` branch.
66
73
74
+ ` distro ` containers examples:
67
75
68
- Docker Build Examples:
69
76
``` console
70
77
docker build -f Dockerfile_build_dependent -t terraform:development-tumbleweed . --build-arg GO_OS=linux --build-arg GO_ARCH=amd64 --build-arg TERRAFORM_VERSION=0.11.14
71
78
```
@@ -84,7 +91,7 @@ This command builds a distro container, tags it as `terraform:development-debian
84
91
Terraform currently does support other architectures other then ` amd64 ` , thus running on other architectures like
85
92
` s390x ` can be troublesome.
86
93
87
- Luckily, the docker containers only need a slight modification to run on ` s390x ` . ** Note** : The ` Build ` containers will run
94
+ The docker containers only needs a slight modification to run on ` s390x ` . ** Note** : The ` Build ` containers will run
88
95
on any architectures that support GO and should not need modification.
89
96
90
97
In the distro containers you should see a line like:
@@ -118,14 +125,14 @@ ENTRYPOINT ["terraform"]
118
125
```
119
126
120
127
With this Dockerfile built, you now need to swap the ` FROM hashicorp/terraform:$TERRAFORM_VERSION AS terraform ` with
121
- your images tag.
128
+ your images name and tag.
122
129
123
- ** Note** : Even if you get the terraform binary built for your respective architecture you might need to built other
124
- providers you utilize in your terraform files, as the default providers are not built for unsupported architectures.
130
+ ** Note** : Even if you get the terraform binary built for your respective architecture, you might need to built other
131
+ providers you utilize in your terraform files. As the default providers are not built for unsupported architectures.
125
132
126
133
### Tips and Tricks
127
- - The use of Docker Volumes helps transfer Terraform config files back and forth between your local system and the docker
128
- container.
134
+ - The use of Docker Volumes helps transfer Terraform config files back and forth between your local system and the
135
+ docker container.
129
136
130
137
- Most ` remote ` libvirt systems require SSH Key auth. To generate a new SSH Key in Dockerfile use the following code:
131
138
``` dockerfile
0 commit comments