blob: 559255b5b9f5588e441b3b5805809a64451307ef [file] [log] [blame]
Joey Armstrongec895f82024-04-25 14:26:07 -04001# -----------------------------------------------------------------------
2# Copyright 2017-2024 Open Networking Foundation Contributors
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# -----------------------------------------------------------------------
16# SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors
17# SPDX-License-Identifier: Apache-2.0
18# -----------------------------------------------------------------------
19
mgouda560ac2b2025-11-18 12:21:46 +053020FROM golang:1.25.3-alpine3.22 AS dev
Naveen Sampath04696f72022-06-13 15:19:14 +053021
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053022RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller && \
23 apk add --no-cache build-base=0.5-r3
Naveen Sampath04696f72022-06-13 15:19:14 +053024
25#chnaging the working dir to tmp
26WORKDIR /tmp
27ENV LD_LIBRARY_PATH=/usr/local/lib
28
29# Set the working directory
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053030WORKDIR /go/src/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053031# Copy required files
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053032COPY database ./database
33COPY vendor ./vendor
34COPY voltha-go-controller ./voltha-go-controller
35COPY internal ./internal
36COPY log ./log
37COPY infra ./infra
38COPY go.mod ./
39COPY go.sum ./
Naveen Sampath04696f72022-06-13 15:19:14 +053040
41
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053042WORKDIR /go/src/voltha-go-controller/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053043#RUN go build
44#Set CGO_ENABLED flag to 0 to avoid DNS issue in alpine release
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053045RUN CGO_ENABLED=0 go build -a -v -o /app/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053046
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053047WORKDIR /go/src/voltha-go-controller/voltha-go-controller/cli
48RUN CGO_ENABLED=0 go build -a -v -o /app/vgcctl
Naveen Sampath04696f72022-06-13 15:19:14 +053049
mgouda560ac2b2025-11-18 12:21:46 +053050FROM golang:1.25.3-alpine3.22 AS prod
Naveen Sampath04696f72022-06-13 15:19:14 +053051
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053052RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller && \
mgoudabb017dc2025-10-29 19:53:34 +053053 apk add --no-cache bash=5.2.37-r0
Naveen Sampath04696f72022-06-13 15:19:14 +053054# Set the working directory
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053055WORKDIR /app
Naveen Sampath04696f72022-06-13 15:19:14 +053056
57# Copy required files
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053058COPY --from=dev /app/voltha-go-controller /app
59COPY --from=dev /app/vgcctl /app
Naveen Sampath04696f72022-06-13 15:19:14 +053060
mgoudabb017dc2025-10-29 19:53:34 +053061RUN chown -R voltha-go-controller:voltha-go-controller /app/voltha-go-controller /usr/local/bin/ && \
62 apk add --no-cache openssh=10.0_p1-r9
Naveen Sampath04696f72022-06-13 15:19:14 +053063
mgoudabb017dc2025-10-29 19:53:34 +053064ENV NOTVISIBLE="in users profile"
Naveen Sampath04696f72022-06-13 15:19:14 +053065RUN echo "export VISIBLE=now" >> /etc/profile
66
67EXPOSE 22
Joey Armstrongec895f82024-04-25 14:26:07 -040068
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053069# [EOF]