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