1
+ # Set to linux or name of OS
2
+ ARG GO_OS
3
+
4
+ # Set to arch name of your system
5
+ ARG GO_ARCH
6
+
7
+ # Terraform Version
8
+ ARG TERRAFORM_VERSION=0.12.0
9
+
10
+ # Provider Version
11
+ ARG VERSION
12
+
13
+ # Grab the Terraform binary
14
+ FROM hashicorp/terraform:$TERRAFORM_VERSION AS terraform
15
+
16
+ # Building Libvirt Plugin Docker
17
+ FROM golang:stretch as libvirt
18
+
19
+ ARG VERSION
20
+ ENV VERSION=$VERSION
21
+
22
+ # Install Needed Packages
23
+ RUN apt-get update \
24
+ && apt-get upgrade -y \
25
+ && apt-get install \
26
+ -y --no-install-recommends \
27
+ git make pkg-config gcc libc-dev libvirt-dev \
28
+ && rm -rf /var/lib/apt/lists/*
29
+
30
+ # Pull Go lint for building
31
+ RUN go get -u golang.org/x/lint/golint
32
+
33
+ # Make directory
34
+ RUN mkdir -p $GOPATH/src/github.com/dmacvicar/
35
+
36
+ # Set Work Directory for Clone
37
+ WORKDIR $GOPATH/src/github.com/dmacvicar/
38
+
39
+ # Clone Project
40
+ RUN git clone https://github.com/dmacvicar/terraform-provider-libvirt.git
41
+
42
+ # Set Workdir for bin build
43
+ WORKDIR $GOPATH/src/github.com/dmacvicar/terraform-provider-libvirt
44
+
45
+ # Checkout Version and download go dependencies
46
+ RUN git checkout $VERSION && env GO111MODULE=on go mod download
47
+
48
+ # Build and move the Binary
49
+ RUN make build && mv terraform-provider-libvirt $GOPATH/bin/
50
+
51
+ # Base Image
52
+ FROM ubuntu:18.04
53
+
54
+ ARG GO_OS
55
+ ENV GO_OS=$GO_OS
56
+ ARG GO_ARCH
57
+ ENV GO_ARCH=$GO_ARCH
58
+
59
+ # Set working directory
60
+ WORKDIR /root/
61
+
62
+ # Make Directory for Provider Binaries
63
+ RUN mkdir -p /root/.terraform.d/plugins/${GO_OS}_${GO_ARCH}/
64
+
65
+ # Copy binaries from containers
66
+ COPY --from=terraform /bin/terraform /bin/
67
+ COPY --from=libvirt /go/bin/terraform-provider-libvirt /root/.terraform.d/plugins/${GO_OS}_${GO_ARCH}/
68
+
69
+ # Install Dependencies
70
+ # libvirt0 is needed to run the provider. xsltproc needed to use XML/XSLT. mkisofs needed to use cloud init images
71
+ # ca-certificates to avoid terraform init 509 error. openssh-client to talk to remote libvirt server
72
+ RUN apt-get update \
73
+ && apt-get upgrade -y \
74
+ && apt-get install \
75
+ -y --no-install-recommends \
76
+ libvirt0 xsltproc mkisofs ca-certificates openssh-client \
77
+ && rm -rf /var/lib/apt/lists/*
78
+
79
+ # Copy Terraform Files
80
+ # COPY libvirt.tf /root/
81
+
82
+ # Terraform commands
83
+ # RUN terraform init
84
+
85
+ ENTRYPOINT /bin/bash
0 commit comments