-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from hackcoderr/non-root-img
Make Non-root docker image for cat server
- Loading branch information
Showing
6 changed files
with
36 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
ARG VERSION="0.0.1-SNAPSHOT" | ||
|
||
FROM maven:3-openjdk-11-slim as dependencies | ||
# Using maven base image in builder stage to build Java code | ||
FROM maven:3-openjdk-11-slim as builder | ||
|
||
WORKDIR /usr/share/app | ||
COPY pom.xml . | ||
# Downloads all packages defined in pom.xml | ||
RUN mvn clean package | ||
|
||
FROM dependencies as builder | ||
|
||
WORKDIR /usr/share/app | ||
COPY pom.xml . | ||
COPY src src | ||
# Build the source code to generate the fatjar | ||
RUN mvn clean package -Dmaven.test.skip=true | ||
|
||
|
||
# Java Runtime as the base for final image | ||
FROM openjdk:11-jre-slim-buster | ||
|
||
ARG VERSION | ||
ENV JAR="iudx.catalogue.server-dev-${VERSION}-fat.jar" | ||
|
||
WORKDIR /usr/share/app | ||
# Copying openapi docs | ||
COPY docs docs | ||
# Copying dev fatjar from builder stage to final image | ||
COPY --from=builder /usr/share/app/target/${JAR} ./fatjar.jar | ||
EXPOSE 8080 | ||
EXPOSE 8443 | ||
# Creating a non-root user | ||
RUN useradd -r -u 1001 -g root catuser | ||
# Setting non-root user to use when container starts | ||
USER catuser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
ARG VERSION="0.0.1-SNAPSHOT" | ||
|
||
FROM maven:3-openjdk-11-slim as dependencies | ||
# Maven base image for building the java code | ||
FROM maven:3-openjdk-11-slim as builder | ||
|
||
WORKDIR /usr/share/app | ||
COPY pom.xml . | ||
# Downloads packages defined in pom.xml | ||
RUN mvn clean package | ||
|
||
FROM dependencies as builder | ||
|
||
WORKDIR /usr/share/app | ||
COPY pom.xml . | ||
COPY src src | ||
# Build the source code to generate fat jar | ||
RUN mvn clean package -Dmaven.test.skip=true | ||
|
||
|
||
# Java runtime as final base image | ||
FROM openjdk:11-jre-slim-buster | ||
|
||
ARG VERSION | ||
ENV JAR="iudx.catalogue.server-cluster-${VERSION}-fat.jar" | ||
|
||
WORKDIR /usr/share/app | ||
# Copying openapi docs | ||
COPY docs docs | ||
# Copying cluster fatjar from builder image stage to final image | ||
COPY --from=builder /usr/share/app/target/${JAR} ./fatjar.jar | ||
# HTTP cat server port | ||
EXPOSE 8080 | ||
# HTTPS cat server port | ||
EXPOSE 8443 | ||
# Metrics http server port | ||
EXPOSE 9000 | ||
# creating a non-root user | ||
RUN useradd -r -u 1001 -g root catuser | ||
# Setting non-root user to use when container starts | ||
USER catuser |
This file was deleted.
Oops, something went wrong.