blob: a0a2554c6f07710d27b5cb385d0d5d8ceb57b9d4 [file] [log] [blame]
Matt Jeanneret8b823f62019-05-11 11:01:28 -04001# Copyright 2016 the original author or authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Phaneendra Manda4c62c802019-03-06 21:37:49 +053015# -------------
16# Build stage
17
Matt Jeanneret8b823f62019-05-11 11:01:28 -040018FROM golang:1.12-alpine3.9 AS build-env
Phaneendra Manda4c62c802019-03-06 21:37:49 +053019
20# Install required packages
21RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
22
Phaneendra Manda4c62c802019-03-06 21:37:49 +053023# Prepare directory structure
Matt Jeanneret8b823f62019-05-11 11:01:28 -040024RUN ["mkdir", "-p", "/build"]
Phaneendra Manda4c62c802019-03-06 21:37:49 +053025RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
26RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord"]
William Kurkianea869482019-04-09 15:16:11 -040027RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha-openolt-adapter"]
Phaneendra Manda4c62c802019-03-06 21:37:49 +053028
William Kurkianea869482019-04-09 15:16:11 -040029WORKDIR $GOPATH/src/github.com/opencord/voltha-openolt-adapter
Phaneendra Manda4c62c802019-03-06 21:37:49 +053030
William Kurkianea869482019-04-09 15:16:11 -040031COPY adaptercore ./adaptercore
32COPY config ./config
33COPY vendor ./vendor
34COPY *.go ./
Phaneendra Manda4c62c802019-03-06 21:37:49 +053035
36# Build openolt
Matt Jeanneret8b823f62019-05-11 11:01:28 -040037RUN go build -o /build/openolt
Phaneendra Manda4c62c802019-03-06 21:37:49 +053038
39# -------------
40# Image creation stage
41
Matt Jeanneret8b823f62019-05-11 11:01:28 -040042FROM alpine:3.9.4
Phaneendra Manda4c62c802019-03-06 21:37:49 +053043
44# Set the working directory
45WORKDIR /app
46
47# Copy required files
Matt Jeanneret8b823f62019-05-11 11:01:28 -040048COPY --from=build-env /build/openolt /app/
Phaneendra Manda4c62c802019-03-06 21:37:49 +053049
Matt Jeanneret8b823f62019-05-11 11:01:28 -040050# Label image
51ARG org_label_schema_version=unknown
52ARG org_label_schema_vcs_url=unknown
53ARG org_label_schema_vcs_ref=unknown
54ARG org_label_schema_build_date=unknown
55ARG org_opencord_vcs_commit_date=unknown
56
57LABEL org.label-schema.schema-version=1.0 \
58 org.label-schema.name=voltha-openolt-adapter-go \
59 org.label-schema.version=$org_label_schema_version \
60 org.label-schema.vcs-url=$org_label_schema_vcs_url \
61 org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
62 org.label-schema.build-date=$org_label_schema_build_date \
63 org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date