-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
executable file
·107 lines (79 loc) · 2.91 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
FROM centos:7.1.1503
ENV REFRESHED_AT 2017-06-03
ARG PROGRAM_NAME="unknown"
ARG BUILD_VERSION=0.0.0
ARG BUILD_ITERATION=0
# --- YUM installs ------------------------------------------------------------
# Avoid "Error: libselinux conflicts with fakesystemd-1-17.el7.centos.noarch"
RUN yum -y swap fakesystemd systemd && \
yum -y install systemd-devel
RUN yum -y update
# --- Install Go --------------------------------------------------------------
ENV GO_VERSION=1.8.3
# Install dependencies.
RUN yum -y install \
git \
tar \
wget
# Install "go".
RUN wget https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz && \
tar -C /usr/local/ -xzf go${GO_VERSION}.linux-amd64.tar.gz
# --- Install Ruby 2.4.0 ------------------------------------------------------
# Install dependencies.
RUN yum -y install \
curl \
gcc \
make \
rpm-build \
ruby-devel \
which
# Install Ruby Version Manager (RVM)
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
RUN curl -L get.rvm.io | bash -s stable
# Install Ruby 2.4.0
ENV PATH /usr/local/rvm/gems/ruby-2.4.0/bin:/usr/local/rvm/gems/ruby-2.4.0@global/bin:/usr/local/rvm/rubies/ruby-2.4.0/bin:/usr/local/rvm/bin:$PATH
RUN rvm install 2.4.0
# --- Install Effing Package Manager (FPM) ------------------------------------
RUN gem install fpm --version 1.8.1
# --- Compile go program ------------------------------------------------------
ENV HOME="/root"
ENV GOPATH="${HOME}/gocode"
ENV PATH="${PATH}:/usr/local/go/bin:${GOPATH}/bin"
ENV GO_PACKAGE="github.com/docktermj/${PROGRAM_NAME}"
# Install dependencies.
RUN go get github.com/docopt/docopt-go
RUN go get github.com/hashicorp/go-plugin
# Copy local files from the Git repository.
COPY . ${GOPATH}/src/${GO_PACKAGE}
# Build plugins
RUN go install ${GO_PACKAGE}/plugin/greeter/greeter-english
RUN go install ${GO_PACKAGE}/plugin/greeter/greeter-german
RUN go install ${GO_PACKAGE}/plugin/greeter/greeter-italian
RUN go install ${GO_PACKAGE}/plugin/hello/hello-english
RUN go install ${GO_PACKAGE}/plugin/hello/hello-german
RUN go install ${GO_PACKAGE}/plugin/hello/hello-italian
# Build go program.
RUN go install \
-ldflags "-X main.programName=${PROGRAM_NAME} -X main.buildVersion=${BUILD_VERSION} -X main.buildIteration=${BUILD_ITERATION}" \
${GO_PACKAGE}
# --- Package as RPM and DEB --------------------------------------------------
WORKDIR /output
# RPM package.
RUN fpm \
--input-type dir \
--output-type rpm \
--name ${PROGRAM_NAME} \
--version ${BUILD_VERSION} \
--iteration ${BUILD_ITERATION} \
/root/gocode/bin/=/usr/bin
# DEB package.
RUN fpm \
--input-type dir \
--output-type deb \
--name ${PROGRAM_NAME} \
--version ${BUILD_VERSION} \
--iteration ${BUILD_ITERATION} \
/root/gocode/bin/=/usr/bin
# --- Epilog ------------------------------------------------------------------
RUN yum clean all
CMD ["/bin/bash"]