Skip to content

Commit a333970

Browse files
author
Jim Crowley
committed
Fixed bug in openSUSE all in one container. Added quickstart section. Made build containers a different section. Added build argument section. Remove unneeded words
1 parent 40203d6 commit a333970

File tree

6 files changed

+53
-54
lines changed

6 files changed

+53
-54
lines changed

contrib/Alpine/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ container.
66
of `glibc`.
77

88

9-
## All-in-One Container Usage
10-
Building Container:
11-
9+
## All-in-One Container Build Example
1210
```console
1311
docker build -f Dockerfile_all_in_one -t terraform:development-alpine . --build-arg VERSION=v0.5.2 --build-arg GO_OS=linux --build-arg GO_ARCH=amd64 --build-arg TERRAFORM_VERSION=0.11.14
1412
```
1513

1614

17-
## Build-Dependent Container Usage
15+
## Build-Dependent Container Build Example
1816
Build appropriate `Build` container, in this case it would be `Dockerfile_musl`:
1917

2018
```cosnole

contrib/Build/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ the benefit of storing the binary in the container, thus you could use a `docker
99
on your local system.
1010

1111
## General Usage
12-
As stated before in the general [README](../), these containers have build args. `VERSION` controls what
13-
build/version of the terraform libvirt provider you are going to compile. You can set `VERSION` to any branch or tag of
14-
the repo. If you set `VERSION` to `v0.5.2` it would build that specific branch/tag of the project. Another common
15-
branch to set it to would be `master`.
16-
12+
As stated before in the general [README](../), these containers have build arguments.
1713

1814
To build the two containers use these commands:
1915

contrib/Debian/README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
# Debian Based Container
2-
This container is build from a `Debian` based distribution, in this case we are using `Ubuntu`. This container has
3-
all the "bloat" of a normal Ubuntu instance. Thus you will find common packages already installed like `nano`, `gcc`,
4-
etc. This option would be good for people who want to test the functionality of the terraform libvirt provider.
2+
This container is build from a `Debian` based distribution, in this case we are using `Ubuntu`.
53

64
**NOTE**: If pulling from the `build` containers, make sure to pull from the `glibc` container.
75

86

9-
## All-in-One Container Usage
10-
Building Container:
11-
7+
## All-in-One Container Build Example
128
```console
139
docker build -f Dockerfile_all_in_one -t terraform:development-ubuntu . --build-arg VERSION=v0.5.2 --build-arg GO_OS=linux --build-arg GO_ARCH=amd64 --build-arg TERRAFORM_VERSION=0.11.14
1410
```
1511

1612

17-
## Build-Dependent Container Usage
13+
## Build-Dependent Container Build Example
1814
Build appropriate `Build` container, in this case it would be `Dockerfile_glibc`:
1915

2016
```cosnole

contrib/README.md

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# 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.
54

65
Please refer to the distro's `README.md` for specific instructions.
76

@@ -10,62 +9,70 @@ folder will compile the terraform libvirt provider for you. Please refer to the
109
information and instructions.
1110

1211
## Table of Content
12+
13+
**Distro Containers**
1314
- [Alpine Containers](Alpine/)
14-
- [Build Containers](Build/)
1515
- [Debian Conainers](Debian/)
1616
- [openSUSE Containers](openSUSE/)
1717

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+
```
1835

1936
## General Usage
2037
There are two types of containers you'll find for each distro, `All-in-One` and `Build-Dependent`.
2138

2239
### All-in-One v.s Build-Dependent Containers
2340
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
2643
quickly, but might lead to confusion down the road if plan on using multiple versions of the terraform libvirt provider.
2744

2845
The `Build-Dependent` container relies on another Dockerfile which contains the build of the plugin. To use this
2946
container you need to first build the appropriate build Dockerfile and tag it correctly. Once that is done, you are
3047
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`.
3350

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:
3653

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
3958

59+
### Examples
60+
`Build` containers examples:
4061

41-
42-
Build Examples:
4362
```console
4463
docker build -f Dockerfile_glibc -t provider-libvirt:v0.5.2-glibc . --build-arg VERSION=v0.5.2
4564
```
4665

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`.
4967

5068
```console
5169
docker build -f Dockerfile_glibc -t provider-libvirt:master-glibc . --build-arg VERSION=master
5270
```
5371

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.
6673

74+
`distro` containers examples:
6775

68-
Docker Build Examples:
6976
```console
7077
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
7178
```
@@ -84,7 +91,7 @@ This command builds a distro container, tags it as `terraform:development-debian
8491
Terraform currently does support other architectures other then `amd64`, thus running on other architectures like
8592
`s390x` can be troublesome.
8693

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
8895
on any architectures that support GO and should not need modification.
8996

9097
In the distro containers you should see a line like:
@@ -118,14 +125,14 @@ ENTRYPOINT ["terraform"]
118125
```
119126

120127
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.
122129

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.
125132

126133
### 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.
129136

130137
- Most `remote` libvirt systems require SSH Key auth. To generate a new SSH Key in Dockerfile use the following code:
131138
```dockerfile

contrib/openSUSE/Dockerfile_all_in_one

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ ARG GO_OS
44
# Set to arch name of your system
55
ARG GO_ARCH
66

7+
# Terraform Version
8+
ARG TERRAFORM_VERSION=0.12.0
9+
710
# Provider Version
811
ARG VERSION
912

contrib/openSUSE/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ support.
55
**NOTE**: If pulling from the `build` containers, make sure to pull from the `glibc` container.
66

77

8-
## All-in-One Container Usage
9-
Building Container:
8+
## All-in-One Container Build Example
109

1110
```console
1211
docker build -f Dockerfile_all_in_one -t terraform:development-tumbleweed . --build-arg VERSION=v0.5.2 --build-arg GO_OS=linux --build-arg GO_ARCH=amd64 --build-arg TERRAFORM_VERSION=0.11.14
1312
```
1413

1514

16-
## Build-Dependent Container Usage
15+
## Build-Dependent Container Build Example
1716
Build appropriate `Build` container, in this case it would be `Dockerfile_glibc`:
1817

1918
```cosnole

0 commit comments

Comments
 (0)