Skip to content
Snippets Groups Projects
Dockerfile 1.22 KiB
Newer Older
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
####
# Build locally:
#   docker build -t nshmp-ws-static .
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
####

ARG BUILD_IMAGE=code.usgs.gov:5001/devops/images/usgs/java:11
ARG FROM_IMAGE=code.usgs.gov:5001/devops/images/usgs/java:11

Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
FROM ${BUILD_IMAGE} as builder
# For GitLab CI/CD
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
USER usgs-user

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
USER root

RUN mkdir /asset-output  \
    && chown -R usgs-user:usgs-user /app \
    && chown -R usgs-user:usgs-user /asset-output

USER usgs-user

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