Skip to content
Snippets Groups Projects
Dockerfile 1.12 KiB
Newer Older
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/amazoncorretto:11
ARG FROM_IMAGE=usgs/amazoncorretto:11
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed

FROM ${BUILD_IMAGE} as builder
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
# TODO: Token needed until nshmp-lib is public
ARG GITLAB_TOKEN=null
ARG CI_JOB_TOKEN=null
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
ARG CI_PROJECT_URL=null
ARG CI_COMMIT_BRANCH=null
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
WORKDIR /app
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
COPY . .
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
RUN ./gradlew assemble
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed

####
# Run service
####
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
FROM ${FROM_IMAGE}
# Which service to run: hazard or aashto
ENV SERVICE="hazard"
# Web service context path
ENV CONTEXT_PATH "/"
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
ENV JAVA_OPTS=""
# Path to the NetCDF file to use
ENV NETCDF_FILE ${SERVICE}-example.nc

Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
WORKDIR /app
COPY --from=builder /app/src/aashto/build/libs/aashto-all.jar aashto.jar
COPY --from=builder /app/src/aashto/src/main/resources/aashto-example.nc .

COPY --from=builder /app/src/hazard/build/libs/hazard-all.jar hazard.jar
COPY --from=builder /app/src/hazard/src/main/resources/hazard-example.nc .
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 \
    "${SERVICE}".jar \
    "-Dmicronaut.server.context-path=${CONTEXT_PATH}" \
    -netcdf=${NETCDF_FILE}
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed

EXPOSE 8080