Stavros Kanarakis | f6668af | 2019-04-22 18:41:18 +0300 | [diff] [blame^] | 1 | FROM openjdk:8-jre-alpine |
| 2 | |
| 3 | ARG PROJECT_BUILD_DIR_NAME |
| 4 | ARG FINAL_JAR |
| 5 | ARG DEPENDENCIES_DIR |
| 6 | ARG DOCKER_ARTIFACT_DIR |
| 7 | |
| 8 | #Add a new user and group to allow container to be run as non-root |
| 9 | RUN addgroup -S bbs-ep && adduser -S -G bbs-ep bbs-ep |
| 10 | |
| 11 | #Copy dependencies and executable jar |
| 12 | WORKDIR ${DOCKER_ARTIFACT_DIR} |
| 13 | COPY ${PROJECT_BUILD_DIR_NAME}/${FINAL_JAR} . |
| 14 | #Overcome Docker limitation to put ARG inside ENTRYPOINT |
| 15 | RUN ln -s ${FINAL_JAR} bbs-ep.jar |
| 16 | COPY ${PROJECT_BUILD_DIR_NAME}/${DEPENDENCIES_DIR} ./${DEPENDENCIES_DIR} |
| 17 | |
| 18 | EXPOSE 8100 |
| 19 | |
| 20 | USER bbs-ep:bbs-ep |
| 21 | ENTRYPOINT ["java", "-jar", "bbs-ep.jar"] |