update build scripts
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
41
Dockerfile
41
Dockerfile
@@ -1,35 +1,30 @@
|
|||||||
FROM maven:3-eclipse-temurin-21-jammy AS build
|
# Stage that builds the application, a prerequisite for the running stage
|
||||||
|
FROM eclipse-temurin:21-jdk-noble AS build
|
||||||
|
|
||||||
# Install nodejs
|
RUN apt-get update -qq
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install -y ca-certificates curl gnupg
|
|
||||||
RUN mkdir -p /etc/apt/keyrings
|
|
||||||
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
|
||||||
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install nodejs -y
|
|
||||||
|
|
||||||
# Stop running as root at this point
|
# Stop running as root at this point
|
||||||
RUN useradd -m vaadin
|
RUN useradd -m app
|
||||||
WORKDIR /usr/src/app/
|
WORKDIR /usr/src/app/
|
||||||
RUN chown vaadin:vaadin /usr/src/app/
|
RUN chown app:app /usr/src/app/
|
||||||
USER vaadin
|
USER app
|
||||||
|
|
||||||
# Copy pom.xml and prefetch dependencies so a repeated build can continue from the next step with existing dependencies
|
|
||||||
COPY --chown=vaadin pom.xml ./
|
|
||||||
|
|
||||||
# Copy all needed project files to a folder
|
# Copy all needed project files to a folder
|
||||||
COPY --chown=vaadin:vaadin src src
|
COPY --chown=app ./.mvn/ .mvn
|
||||||
|
COPY --chown=app ./mvnw ./pom.xml ./app.json ./
|
||||||
|
COPY --chown=app ./src ./src
|
||||||
|
|
||||||
# Build the production package, assuming that we validated the version before so no need for running tests again
|
# Build the production package
|
||||||
RUN mvn clean package -DskipTests -Pproduction --batch-mode
|
RUN ./mvnw --batch-mode clean verify -DskipTests
|
||||||
|
|
||||||
# Running stage: the part that is used for running the application
|
# Running stage: the part that is used for running the application
|
||||||
FROM eclipse-temurin:21-jre-jammy
|
FROM eclipse-temurin:21-jre-noble
|
||||||
COPY --from=build /usr/src/app/target/*.jar /usr/app/website.jar
|
|
||||||
|
|
||||||
RUN useradd -m vaadin
|
RUN useradd -m app
|
||||||
USER vaadin
|
USER app
|
||||||
|
|
||||||
|
COPY --chown=app --from=build /usr/src/app/target/*.jar /usr/app/website.jar
|
||||||
|
|
||||||
|
HEALTHCHECK CMD curl --fail http://localhost:5000/actuator/health/liveness || exit 1
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
CMD ["java", "-jar", "/usr/app/website.jar"]
|
CMD ["java", "-jar", "/usr/app/website.jar"]
|
||||||
|
Reference in New Issue
Block a user