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 |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 15 | WORKDIR /go/src/voltha-go-controller |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 16 | # Copy required files |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 17 | COPY database ./database |
| 18 | COPY vendor ./vendor |
| 19 | COPY voltha-go-controller ./voltha-go-controller |
| 20 | COPY internal ./internal |
| 21 | COPY log ./log |
| 22 | COPY infra ./infra |
| 23 | COPY go.mod ./ |
| 24 | COPY go.sum ./ |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 25 | |
| 26 | |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 27 | WORKDIR /go/src/voltha-go-controller/voltha-go-controller |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 28 | #RUN go build |
| 29 | #Set CGO_ENABLED flag to 0 to avoid DNS issue in alpine release |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 30 | RUN CGO_ENABLED=0 go build -a -v -o /app/voltha-go-controller |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 31 | |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 32 | WORKDIR /go/src/voltha-go-controller/voltha-go-controller/cli |
| 33 | RUN CGO_ENABLED=0 go build -a -v -o /app/vgcctl |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 34 | |
| 35 | FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS prod |
| 36 | |
| 37 | RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller |
| 38 | |
| 39 | RUN apk add --no-cache bash=5.1.16-r0 |
| 40 | # Set the working directory |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 41 | WORKDIR /app |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 42 | |
| 43 | # Copy required files |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 44 | COPY --from=dev /app/voltha-go-controller /app |
| 45 | COPY --from=dev /app/vgcctl /app |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 46 | |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 47 | RUN chown -R voltha-go-controller.voltha-go-controller /app/voltha-go-controller /usr/local/bin/ |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 48 | RUN apk add --no-cache openssh=8.4_p1-r4 |
| 49 | RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config |
| 50 | |
| 51 | RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/init.d/sshd |
| 52 | ENV NOTVISIBLE "in users profile" |
| 53 | RUN echo "export VISIBLE=now" >> /etc/profile |
| 54 | |
| 55 | EXPOSE 22 |