forked from IBM/packer-plugin-ibmcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
91 lines (77 loc) · 2.84 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Base image
FROM ubuntu:latest
LABEL maintainer = "[email protected]"
ENV GO_VERSION 1.17.2
ENV PACKER_VERSION 1.7.6
ARG GO_VERSION
ARG PACKER_VERSION
ENV GO_VERSION ${GO_VERSION}
ENV PACKER_VERSION ${PACKER_VERSION}
ENV HOME /root
RUN set -ex \
&& apt-get -y update \
&& apt-get -y install apt-utils curl git unzip vim \
&& mkdir -p /packer-plugin-ibmcloud
# Set the working directory
WORKDIR /packer-plugin-ibmcloud
###########################################################
RUN echo "[Step 1]: Install go and set go Environment variables"
###########################################################
ENV GO_TAR go${GO_VERSION}.linux-amd64.tar.gz
ENV GO_URL https://golang.org/dl/$GO_TAR
RUN set -ex \
&& curl -OL $GO_URL \
&& tar -C /usr/local -xzf $GO_TAR \
&& mkdir -p $HOME/go/src/github.com \
&& rm -rf $GO_TAR
RUN echo "Setting go Environment variables..."
ENV GOPATH $HOME/go
ENV GOROOT /usr/local/go
ENV PATH $PATH:$GOPATH/bin:$GOROOT/bin
RUN set -ex \
&& cd $HOME \
&& echo export GOPATH=$GOPATH >> .profile \
&& echo export GOROOT=$GOROOT >> .profile \
&& echo export PATH=$PATH >> .profile
RUN echo "go Installation Successfully Completed."
###########################################################
RUN echo "[Step 2]: Setup Ansible"
###########################################################
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -y install ansible
# Fix "winrm or requests is not installed: No module named winrm"
RUN apt -y install python3-pip
RUN pip3 install --ignore-installed "pywinrm>=0.2.2"
RUN echo "Ansible Installation Successfully Completed."
###########################################################
RUN echo "[Step 3]: Install Packer and set Packer's Environment variables"
###########################################################
ENV PACKER_ZIP packer_${PACKER_VERSION}_linux_amd64.zip
ENV PACKER_URL https://releases.hashicorp.com/packer/$PACKER_VERSION/$PACKER_ZIP
RUN set -ex \
&& curl -OL $PACKER_URL \
&& mkdir -p /usr/local/packer \
&& unzip $PACKER_ZIP -d /usr/local/packer \
&& rm -rf $PACKER_ZIP
RUN echo "Setting Packer Environment variables..."
ENV PACKERPATH /usr/local/packer
ENV PATH $PATH:$PACKERPATH
RUN set -ex \
&& cd $HOME \
&& echo export PATH=$PATH >> .profile
RUN echo "Packer Installation Successfully Completed."
###########################################################
RUN echo "[Step 4]: Build IBM Cloud Packer Plugin binary"
###########################################################
COPY . ./
RUN set -ex \
&& cd ./ \
&& go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@latest \
&& go mod tidy \
&& go mod vendor \
&& go generate ./builder/ibmcloud/... \
&& go mod vendor \
&& go build .
RUN echo "IBM Cloud Packer Plugin binary Successfully Created."
# Comment below line to make container interactive
ENTRYPOINT ["/usr/local/packer/packer"]