| FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS dev |
| |
| RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller |
| # Install required packages |
| RUN apk add --no-cache build-base=0.5-r3 |
| |
| #adding git |
| #RUN apk add --no-cache bash=5.1.16-r0 |
| |
| #chnaging the working dir to tmp |
| WORKDIR /tmp |
| ENV LD_LIBRARY_PATH=/usr/local/lib |
| |
| # Set the working directory |
| WORKDIR /go/src/voltha-go-controller |
| # Copy required files |
| COPY database ./database |
| COPY vendor ./vendor |
| COPY voltha-go-controller ./voltha-go-controller |
| COPY internal ./internal |
| COPY log ./log |
| COPY infra ./infra |
| COPY go.mod ./ |
| COPY go.sum ./ |
| |
| |
| WORKDIR /go/src/voltha-go-controller/voltha-go-controller |
| #RUN go build |
| #Set CGO_ENABLED flag to 0 to avoid DNS issue in alpine release |
| RUN CGO_ENABLED=0 go build -a -v -o /app/voltha-go-controller |
| |
| WORKDIR /go/src/voltha-go-controller/voltha-go-controller/cli |
| RUN CGO_ENABLED=0 go build -a -v -o /app/vgcctl |
| |
| FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS prod |
| |
| RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller |
| |
| RUN apk add --no-cache bash=5.1.16-r0 |
| # Set the working directory |
| WORKDIR /app |
| |
| # Copy required files |
| COPY --from=dev /app/voltha-go-controller /app |
| COPY --from=dev /app/vgcctl /app |
| |
| RUN chown -R voltha-go-controller.voltha-go-controller /app/voltha-go-controller /usr/local/bin/ |
| RUN apk add --no-cache openssh=8.4_p1-r4 |
| RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config |
| |
| RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/init.d/sshd |
| ENV NOTVISIBLE "in users profile" |
| RUN echo "export VISIBLE=now" >> /etc/profile |
| |
| EXPOSE 22 |