blob: aa454f3e0998e0e8e272cfb9e4a354ce1eb35802 [file] [log] [blame]
# -----------------------------------------------------------------------
# Copyright 2017-2024 Open Networking Foundation Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -----------------------------------------------------------------------
# SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
FROM golang:1.23.1-alpine3.20 AS dev
RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller && \
apk add --no-cache build-base=0.5-r3
#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 golang:1.23.1-alpine3.20 AS prod
RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller && \
apk add --no-cache bash=5.2.26-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/ && \
apk add --no-cache openssh=9.7_p1-r5
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
EXPOSE 22
# [EOF]