Scott Baker | 14c8f18 | 2019-05-22 18:05:29 -0700 | [diff] [blame] | 1 | # 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 | |
| 18 | FROM xosproject/grpc-mock:1.0.0 as build |
| 19 | MAINTAINER Open Networking Foundation |
| 20 | |
Scott Baker | 24f57ea | 2020-04-27 10:46:08 -0700 | [diff] [blame^] | 21 | RUN apk add --update git python3 py-pip make |
Scott Baker | 14c8f18 | 2019-05-22 18:05:29 -0700 | [diff] [blame] | 22 | |
| 23 | WORKDIR /xos |
| 24 | RUN mkdir /xos/v1 |
| 25 | RUN 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 Baker | 24f57ea | 2020-04-27 10:46:08 -0700 | [diff] [blame^] | 26 | RUN cd /opt/xos/lib/xos-genx && python3 setup.py install |
Scott Baker | 14c8f18 | 2019-05-22 18:05:29 -0700 | [diff] [blame] | 27 | RUN cd /opt/xos/coreapi/protos && make rebuild-protos |
| 28 | |
| 29 | RUN cp -r /opt/xos/coreapi/protos/*.proto /xos/v1 |
| 30 | |
| 31 | COPY clean.sh /xos/clean.sh |
| 32 | RUN /xos/clean.sh |
| 33 | |
Scott Baker | 24f57ea | 2020-04-27 10:46:08 -0700 | [diff] [blame^] | 34 | # 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 | |
| 42 | WORKDIR /xos/v1 |
| 43 | RUN tail -n +4 common.proto > common.suffix |
| 44 | RUN mv xos.proto xos.orig && cat xos.orig common.suffix > xos.proto && sed -i '/import.*common.proto/d' xos.proto |
| 45 | RUN 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 Baker | 14c8f18 | 2019-05-22 18:05:29 -0700 | [diff] [blame] | 49 | FROM xosproject/grpc-mock:1.0.0 |
| 50 | ENV GRPC_MOCK_COMPARE=sparse |
| 51 | |
| 52 | WORKDIR /xos |
| 53 | COPY --from=build /xos /xos |
| 54 | COPY mock.sh clean.sh mock-v1.js data.json /xos/ |
| 55 | RUN chmod 755 /xos/mock.sh /xos/clean.sh |
| 56 | |
| 57 | ENTRYPOINT ["/xos/mock.sh"] |