# Use an aidoop nodejs base image
FROM hatiolab/operato-env:latest

# install usb, glx, cmake
RUN apt-get update \
  && apt-get install -y libusb-1.0-0 \
  && apt-get install -y libgl1-mesa-glx \
  && apt-get install -y cmake 

# # install python3 & opecv ui
# RUN apt-get install -y python3-pip \
#   && apt-get -y install libgtk-3-dev \
#   && apt-get -y install libjpeg-dev libtiff5-dev libpng-dev \
#   && apt-get -y install libavcodec-dev libavformat-dev libswscale-dev \
#   && apt-get -y install libdc1394-22-dev libxvidcore-dev libx264-dev \
#   && apt-get -y install libxine2-dev libv4l-dev v4l-utils \
#   && apt-get -y install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

# install poco 1.8 to use doosan robot api
RUN wget https://github.com/pocoproject/poco/archive/refs/tags/poco-1.8.0-release.tar.gz && tar xvfz poco-1.8.0-release.tar.gz && \
  cd poco-poco-1.8.0-release && mkdir cmake-build && cd cmake-build  && cmake .. && cmake --build . --config Release && \
  make install
RUN cp /opt/oracle/poco-poco-1.8.0-release/cmake-build/lib/libPoco* /usr/local/lib/
RUN echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/poco-poco-1.8.0-release/cmake-build/lib' >> ~/.bashrc && ldconfig

WORKDIR /app

# copy application & configuration files
COPY . .

# run node install command
RUN yarn install

# Make port 3000 available to the world outside this container
EXPOSE 3000

CMD [ "yarn", "run", "serve" ]
