# SPDX-License-Identifier: MulanPSL-2.0+
# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.

FROM openeuler/openeuler:22.03

COPY openEuler.repo /etc/yum.repos.d/
RUN yum -y update && \
    yum -y install gcc make openssl-devel gcc-c++ wget rpm-sign gnupg2 createrepo_c

# download the source file may take a long time, can prepare download it and use
# the following line instead of command wget
#   COPY ruby-2.7.6.tar.gz /
RUN wget --no-check-certificate https://cache.ruby-china.com/pub/ruby/2.7/ruby-2.7.6.tar.gz -P /
RUN cd / && tar xzvf ruby-2.7.6.tar.gz && cd ruby-2.7.6 && ./configure && make -j 96 && make install

RUN gem sources -r https://rubygems.org/ -a https://gems.ruby-china.com/ && \
    gem install sinatra logger json-schema elasticsearch:7.11.1

COPY cbs /c/cbs

RUN cd /c/cbs/container/publisher/pk12_rsasign && make
RUN cp /c/cbs/container/publisher/pk12_rsasign/pk12_rsasign /bin/

RUN groupadd -g 1090 lkp && useradd -m -u 1090 -g 1090 lkp

RUN chown -R lkp:lkp /c/cbs && chown -R 750 /c/cbs

RUN yum remove gcc cpp -y

WORKDIR /c/cbs/container/publisher
