Skip to content
Snippets Groups Projects
Dockerfile 1.41 KiB
Newer Older
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
####
# Build locally:
#   docker build
#       --build-arg git_username=<user@name.com>
#       --build-arg git_password=<git-api-token>
#       -t nshmp-netcdf .
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
####

Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
ARG project=nshmp-netcdf
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
####
FROM usgs/centos:8 as builder

ENV LANG="en_US.UTF-8"

ARG git_username
ARG git_password
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
ARG libs_dir
ARG jar_file
ARG workdir

ENV GIT_NSHMP_USERNAME ${git_username}
ENV GIT_NSHMP_PASSWORD ${git_password}
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
WORKDIR ${workdir}
RUN yum install -y java-11-openjdk which git
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
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 --no-daemon assemble \
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
    && mv ${libs_dir}/*-all.jar ${jar_file}

####
# Run service
####
FROM usgs/centos:8

ENV LANG "en_US.UTF-8"

# 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
ENV NSHM "CONUS_2018"
ENV CONTEXT_PATH "/"
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}
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
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

RUN yum install -y java-11-openjdk-headless

EXPOSE 8080
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
ENTRYPOINT /usr/bin/java -jar ${PROJECT}.jar \
    "-Dmicronaut.server.context-path=${CONTEXT_PATH}" \
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
    -nshm=${NSHM} \
    -netcdf=${NETCDF_FILE}