Unverified Commit 41043319 authored by Christine Kim's avatar Christine Kim Committed by GitHub
Browse files

Dockerize FastAPI (#35)



* wip docker

* added AWS stuff

* reduce service to q

* some changes

* some fixes and updates

* garbage

* Add forward slash

* Update Dockerfile

* moved things around

* Add kernels key

* Update accessing kernelset

* Bug fixes

* Add trycatch

* fix dockerfile typo

* add filter

* some test fixes

* update test kernel paths

* possible test fix

* working tests + inventory upgrades

* added highfive

---------

Co-authored-by: default avatarKelvin <krodriguez@usgs.gov>
Co-authored-by: default avataracpaquette <acpaquette@usgs.gov>
parent 57f802a5
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -46,9 +46,7 @@ option (SPICEQL_BUILD_LIB "Build the SpiceQL Library" ON)
if(SPICEQL_BUILD_LIB)

  set(JSON_BuildTests OFF CACHE INTERNAL "")
  set(REDIS_PLUS_PLUS_BUILD_TEST OFF CACHE INTERNAL "")

  add_subdirectory("submodules/redis-plus-plus")
  add_subdirectory("submodules/gularkfilesystem")
  add_subdirectory("submodules/json")
  
@@ -56,7 +54,7 @@ if(SPICEQL_BUILD_LIB)
  find_package(fmt REQUIRED)
  find_package(cereal REQUIRED)
  find_package(spdlog REQUIRED)
  find_package(hiredis REQUIRED)
  find_package(HighFive REQUIRED)

  set(SPICEQL_INSTALL_INCLUDE_DIR "include/SpiceQL")
  set(SPICEQL_SRC_FILES   ${CMAKE_CURRENT_SOURCE_DIR}/SpiceQL/src/spiceql.cpp 
@@ -67,7 +65,7 @@ if(SPICEQL_BUILD_LIB)
                          ${CMAKE_CURRENT_SOURCE_DIR}/SpiceQL/src/memoized_functions.cpp
                          ${CMAKE_CURRENT_SOURCE_DIR}/SpiceQL/src/config.cpp
                          ${CMAKE_CURRENT_SOURCE_DIR}/SpiceQL/src/inventory.cpp
                          ${CMAKE_CURRENT_SOURCE_DIR}/SpiceQL/src/database.cpp)
                          ${CMAKE_CURRENT_SOURCE_DIR}/SpiceQL/src/inventoryimpl.cpp)


  set(SPICEQL_HEADER_FILES ${SPICEQL_BUILD_INCLUDE_DIR}/spiceql.h
@@ -78,7 +76,7 @@ if(SPICEQL_BUILD_LIB)
                           ${SPICEQL_BUILD_INCLUDE_DIR}/query.h
                           ${SPICEQL_BUILD_INCLUDE_DIR}/config.h
                           ${SPICEQL_BUILD_INCLUDE_DIR}/inventory.h
                           ${SPICEQL_BUILD_INCLUDE_DIR}/database.h)
                           ${SPICEQL_BUILD_INCLUDE_DIR}/inventoryimpl.h)

  set(SPICEQL_PRIVATE_HEADER_FILES ${SPICEQL_BUILD_INCLUDE_DIR}/memo.h)

@@ -121,14 +119,12 @@ if(SPICEQL_BUILD_LIB)
  target_compile_definitions(SpiceQL PRIVATE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE 
                                     PUBLIC -D_SOURCE_PREFIX="${CMAKE_CURRENT_SOURCE_DIR}")
  
  message(STATUS "redis++ inc: "  ${HIREDIS_INCLUDE_DIRS})
target_include_directories(SpiceQL
                            PUBLIC
                            $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/SpiceQL/include>
                            $<INSTALL_INTERFACE:include>
                            PRIVATE
                            ${CMAKE_CURRENT_SOURCE_DIR}/submodules/BTree/include/
                            ${CMAKE_CURRENT_SOURCE_DIR}/submodules/redis-plus-plus/src/
                            cereal
                            )

@@ -137,9 +133,9 @@ if(SPICEQL_BUILD_LIB)
                        fmt::fmt-header-only
                        nlohmann_json::nlohmann_json
                        PRIVATE
                        redis++ 
                        cspice
                        spdlog::spdlog_header_only
                        HighFive
                        )
   
  install(TARGETS SpiceQL LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

Dockerfile

0 → 100644
+54 −0
Original line number Diff line number Diff line
FROM condaforge/miniforge3

SHELL ["/bin/bash", "-c"]

# Clone SpiceQL repo instead of copying?
#git clone git@github.com:DOI-USGS/SpiceQL.git /repo

# RUN git clone https://github.com/chkim-usgs/SpiceQL.git /repo --recursive --branch docker
# RUN echo $(ls /repo)
# RUN chmod -R 755 /repo

RUN apt-get update && apt-get install build-essential -y

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install nginx curl -y 
COPY fastapi/config/nginx.conf /etc/nginx/nginx.conf

# CMD ["/bin/bash"]
# RUN /bin/bash -c "source activate spiceql"

 RUN mkdir /repo    
 COPY . /repo
 RUN echo $(ls /repo)
 RUN chmod -R 755 /repo

# Set repo root env
ENV SPICEQL_REPO_ROOT /repo

RUN mamba env create -f ${SPICEQL_REPO_ROOT}/environment.yml -n spiceql && \
    source /opt/conda/etc/profile.d/conda.sh && \
    conda init && \
    conda activate spiceql && \
    # conda install -c conda-forge spiceql && \
    echo "source activate spiceql" > ~/.bashrc && \ 
    conda activate spiceql && \ 
    cd $SPICEQL_REPO_ROOT && mkdir -p build && cd build && \ 
    cmake .. -DCMAKE_BUILD_TYPE=Release DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DSPICEQL_BUILD_TESTS=OFF -DSPICEQL_BUILD_DOCS=OFF -GNinja && \ 
    ninja install 

RUN cd ${SPICEQL_REPO_ROOT}/fastapi
ENV PATH /opt/conda/envs/spiceql/bin:$PATH


WORKDIR ${SPICEQL_REPO_ROOT}/fastapi

EXPOSE 8080

COPY Entrypoint.sh /
RUN chmod +x /Entrypoint.sh

RUN mkdir /mnt/isisdata/

ENTRYPOINT ["/bin/bash", "/Entrypoint.sh"]
+3 −1
Original line number Diff line number Diff line
@@ -40,7 +40,9 @@
      "iak": {
        "kernels": "apollo16MetricAddendum[0-9]{3}.ti"
      },
      "deps" : ["/apollo16"]
      "pck" : { 
        "deps" : ["/base/pck"]
      }
    },
    "panoramic": {
      "ik": {
+1 −2
Original line number Diff line number Diff line
@@ -15,8 +15,7 @@
            "kernels": ["naif[0-9]{4}.tls$"]
        },
        "pck": {
            "kernels": ["PCK[0-9]{5}.TPC$"],
            "deps" : ["/base/pck"]
            "kernels": ["pck0000[0-9].tpc", "PCK[0-9]{5}.TPC$"]
        },
        "sclk": {
            "kernels": ["SMART1_[0-9]{6}_STEP.TSC$"]
+3 −3
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@
            "kernels": ["naif0009.tls$"]
        },
        "pck": {
            "kernels": ["pck00010_msgr_v23_europa2020.tpc$"]
            "kernels": ["pck00010_msgr_v23_europa2020.tpc$"],
            "deps" : ["/base/pck"]
        },
        "sclk": {
            "kernels": ["vg1[0-9]{5}.tsc$"]
@@ -30,7 +31,6 @@
            "reconstructed": {
                "kernels": ["vg1_sat.bsp$", "vg1_jup.bsp$", "vg1_[a-z]{3}_version[0-9]{1}_type[0-9]{1}_iss_sedr.bc$","vgr1_jup230.bsp$", "vgr1_sat336.bsp$"]
            }
        },
        "deps" : ["/base/pck"]
        }
    }
}
 No newline at end of file
Loading