blob: 6fbac5da987c1ab013b5f1ece6b87f5c93717f26 [file] [log] [blame]
Scott Baker14c8f182019-05-22 18:05:29 -07001# Portions copyright 2019-present Open Networking Foundation
2# Original copyright 2019-present Ciena Corporation
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# docker build -t xosproject/mock-xos:candidate .
17
18FROM xosproject/grpc-mock:1.0.0 as build
19MAINTAINER Open Networking Foundation
20
Scott Baker24f57ea2020-04-27 10:46:08 -070021RUN apk add --update git python3 py-pip make
Scott Baker14c8f182019-05-22 18:05:29 -070022
23WORKDIR /xos
24RUN mkdir /xos/v1
25RUN git clone https://github.com/opencord/xos /opt/tmp_xos && mv /opt/tmp_xos/xos /opt/xos && mv /opt/tmp_xos/lib /opt/xos/lib && cp /opt/tmp_xos/VERSION /opt/xos
Scott Baker24f57ea2020-04-27 10:46:08 -070026RUN cd /opt/xos/lib/xos-genx && python3 setup.py install
Scott Baker14c8f182019-05-22 18:05:29 -070027RUN cd /opt/xos/coreapi/protos && make rebuild-protos
28
29RUN cp -r /opt/xos/coreapi/protos/*.proto /xos/v1
30
31COPY clean.sh /xos/clean.sh
32RUN /xos/clean.sh
33
Scott Baker24f57ea2020-04-27 10:46:08 -070034# TODO: Ugly hack to fix xos.proto and utility.proto
35#
36# Something is broken in grpc-mock. It is not processing the import statements
37# in xos.proto or utility.proto that import common.proto and therefore it cannot
38# find the ID and Query messages. Until we understand what is wrong, work around this
39# by stripping off the first four lines of common.proto, and appending it to
40# xos.proto and utility.proto.
41
42WORKDIR /xos/v1
43RUN tail -n +4 common.proto > common.suffix
44RUN mv xos.proto xos.orig && cat xos.orig common.suffix > xos.proto && sed -i '/import.*common.proto/d' xos.proto
45RUN mv utility.proto utility.orig && cat utility.orig common.suffix > utility.proto && sed -i '/import.*common.proto/d' utility.proto
46
47# end Ugly hack to fix xos.proto and utility.proto
48
Scott Baker14c8f182019-05-22 18:05:29 -070049FROM xosproject/grpc-mock:1.0.0
50ENV GRPC_MOCK_COMPARE=sparse
51
52WORKDIR /xos
53COPY --from=build /xos /xos
54COPY mock.sh clean.sh mock-v1.js data.json /xos/
55RUN chmod 755 /xos/mock.sh /xos/clean.sh
56
57ENTRYPOINT ["/xos/mock.sh"]