blob: d05d6e50831c5b82d0bd6f0028d2b312f2586ce0 [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
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053015WORKDIR /go/src/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053016# Copy required files
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053017COPY database ./database
18COPY vendor ./vendor
19COPY voltha-go-controller ./voltha-go-controller
20COPY internal ./internal
21COPY log ./log
22COPY infra ./infra
23COPY go.mod ./
24COPY go.sum ./
Naveen Sampath04696f72022-06-13 15:19:14 +053025
26
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053027WORKDIR /go/src/voltha-go-controller/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053028#RUN go build
29#Set CGO_ENABLED flag to 0 to avoid DNS issue in alpine release
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053030RUN CGO_ENABLED=0 go build -a -v -o /app/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053031
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053032WORKDIR /go/src/voltha-go-controller/voltha-go-controller/cli
33RUN CGO_ENABLED=0 go build -a -v -o /app/vgcctl
Naveen Sampath04696f72022-06-13 15:19:14 +053034
35FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS prod
36
37RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller
38
39RUN apk add --no-cache bash=5.1.16-r0
40# Set the working directory
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053041WORKDIR /app
Naveen Sampath04696f72022-06-13 15:19:14 +053042
43# Copy required files
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053044COPY --from=dev /app/voltha-go-controller /app
45COPY --from=dev /app/vgcctl /app
Naveen Sampath04696f72022-06-13 15:19:14 +053046
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053047RUN chown -R voltha-go-controller.voltha-go-controller /app/voltha-go-controller /usr/local/bin/
Naveen Sampath04696f72022-06-13 15:19:14 +053048RUN apk add --no-cache openssh=8.4_p1-r4
49RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
50
51RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/init.d/sshd
52ENV NOTVISIBLE "in users profile"
53RUN echo "export VISIBLE=now" >> /etc/profile
54
55EXPOSE 22