Skip to content
Snippets Groups Projects
Dockerfile 1.41 KiB
Newer Older
  • Learn to ignore specific revisions
  • Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ####
    # Build locally:
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    #       --build-arg gitlab_token=<token>
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    #       -t nshmp-ws-static .
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ####
    
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ARG BUILD_IMAGE=usgs/java:11
    ARG FROM_IMAGE=usgs/java:11
    
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ARG project=nshmp-ws-static
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ARG workdir=/app/${project}
    ARG libs_dir=${workdir}/build/libs
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ARG jar_file=${libs_dir}/${project}.jar
    
    ####
    # Build war file
    ####
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    FROM ${BUILD_IMAGE} as builder
    
    ARG gitlab_token=null
    ARG ci_job_token=null
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ARG libs_dir
    ARG jar_file
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    # TODO: Token needed until nshmp-lib is public
    
    ENV GITLAB_TOKEN ${gitlab_token}
    ENV CI_JOB_TOKEN ${ci_job_token}
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    WORKDIR ${workdir}
    
    COPY build.gradle .
    COPY .git .git
    COPY gradle gradle
    COPY gradle.properties .
    COPY gradlew .
    COPY settings.gradle .
    COPY src src
    COPY openapi.properties .
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    RUN ./gradlew assemble \
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
        && mv ${libs_dir}/*-all.jar ${jar_file}
    
    ####
    # Run service
    ####
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    FROM ${FROM_IMAGE}
    
    # The NetCDF file to read in
    ARG netcdf_file="src/main/resources/default.nc"
    
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    # The NSHM to use
    
    # Available NSHM to run:
    #   - CONUS_2018A
    ENV NSHM "CONUS_2018A"
    
    
    ENV CONTEXT_PATH "/"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ENV JAVA_OPTS=""
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    
    ARG jar_file
    ARG project
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ARG workdir
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ENV PROJECT ${project}
    ENV NETCDF_FILE ${netcdf_file}
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    WORKDIR ${workdir}
    
    COPY --from=builder ${jar_file} ${project}.jar
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    COPY ${NETCDF_FILE} ${NETCDF_FILE}
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    ENTRYPOINT /usr/bin/java \
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
        ${JAVA_OPTS} \
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
        -jar \
        ${PROJECT}.jar \
    
        "-Dmicronaut.server.context-path=${CONTEXT_PATH}" \
        -nshm=${NSHM} \
        -netcdf=${NETCDF_FILE}
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    
    EXPOSE 8080