blob: f1db82e9ca196de6d818e9e77a16f5c11ee6c1f1 [file] [log] [blame]
Naveen Sampath04696f72022-06-13 15:19:14 +05301FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS dev
2
3RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller
4# Install required packages
5RUN apk add --no-cache build-base=0.5-r3
6
7#adding git
8#RUN apk add --no-cache bash=5.1.16-r0
9
10#chnaging the working dir to tmp
11WORKDIR /tmp
12ENV LD_LIBRARY_PATH=/usr/local/lib
13
14# Set the working directory
15WORKDIR /home/voltha-go-controller
16# Copy required files
17COPY . /home/voltha-go-controller/
18
19
20WORKDIR /home/voltha-go-controller/voltha-go-controller
21#RUN go build
22#Set CGO_ENABLED flag to 0 to avoid DNS issue in alpine release
23RUN CGO_ENABLED=0 go build -a -v
24
25WORKDIR /home/voltha-go-controller/voltha-go-controller/cli/
26RUN CGO_ENABLED=0 go build -a -v -o vgcctl
27
28FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS prod
29
30RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller
31
32RUN apk add --no-cache bash=5.1.16-r0
33# Set the working directory
34WORKDIR /home/voltha-go-controller
35
36# Copy required files
37COPY --from=dev /home/voltha-go-controller/voltha-go-controller/voltha-go-controller /home/voltha-go-controller/
38COPY --from=dev /home/voltha-go-controller/voltha-go-controller/cli/vgcctl /home/voltha-go-controller/
39COPY entryscript.sh /home/voltha-go-controller/
40
41RUN chown -R voltha-go-controller.voltha-go-controller /home/voltha-go-controller/ /usr/local/bin/
42RUN chmod +x /home/voltha-go-controller/entryscript.sh
43RUN apk add --no-cache openssh=8.4_p1-r4
44RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
45
46RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/init.d/sshd
47ENV NOTVISIBLE "in users profile"
48RUN echo "export VISIBLE=now" >> /etc/profile
49
50EXPOSE 22
51
52CMD ["/home/voltha-go-controller/entryscript.sh"]