Typicalc/Dockerfile

32 lines
1.2 KiB
Docker
Raw Normal View History

2021-01-26 15:05:33 +00:00
# Stage that builds the application, a prerequisite for the running stage
FROM maven:3-jdk-11 as build
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get update -qq && apt-get install -qq --no-install-recommends nodejs
# Stop running as root at this point
2021-03-11 12:27:36 +00:00
RUN useradd -m typicalc
2021-01-26 15:05:33 +00:00
WORKDIR /usr/src/app/
2021-03-11 12:27:36 +00:00
RUN chown typicalc:typicalc /usr/src/app/
USER typicalc
2021-01-26 15:05:33 +00:00
# Copy pom.xml and prefetch dependencies so a repeated build can continue from the next step with existing dependencies
2021-03-11 12:27:36 +00:00
COPY --chown=typicalc pom.xml ./
2021-01-26 15:05:33 +00:00
RUN mvn dependency:go-offline -Pproduction
# Copy all needed project files to a folder
2021-03-11 12:27:36 +00:00
COPY --chown=typicalc:typicalc src src
COPY --chown=typicalc:typicalc frontend frontend
COPY --chown=typicalc:typicalc package.json pnpm-lock.yaml webpack.config.js ./
2021-01-26 15:05:33 +00:00
# Build the production package, assuming that we validated the version before so no need for running tests again
RUN mvn clean package -DskipTests -Pproduction
# Running stage: the part that is used for running the application
FROM openjdk:11
COPY --from=build /usr/src/app/target/*.jar /usr/app/app.jar
2021-03-11 12:27:36 +00:00
RUN useradd -m typicalc
USER typicalc
2021-01-26 15:05:33 +00:00
EXPOSE 8080
CMD java -jar /usr/app/app.jar