syntax=docker/dockerfile:1.4 FROM --platform=$BUILDPLATFORM…
- User
syntax=docker/dockerfile:1.4
FROM --platform=$BUILDPLATFORM maven:3.8.5-eclipse-temurin-17 AS builder WORKDIR /workdir/server COPY pom.xml /workdir/server/pom.xml RUN mvn dependency:go-offline
COPY src /workdir/server/src RUN mvn install
FROM builder AS dev-envs RUN <<EOF apt-get update apt-get install -y --no-install-recommends git EOF
RUN <<EOF useradd -s /bin/bash -m vscode groupadd docker usermod -aG docker vscode EOF
install Docker tools (cli, buildx, compose)
COPY --from=gloursdocker/docker / / CMD ["mvn", "spring-boot:run"]
FROM builder as prepare-production RUN mkdir -p target/dependency WORKDIR /workdir/server/target/dependency RUN jar -xf ../*.jar
FROM eclipse-temurin:17-jre-focal
EXPOSE 8080 VOLUME /tmp ARG DEPENDENCY=/workdir/server/target/dependency COPY --from=prepare-production {DEPENDENCY}/META-INF /app/META-INF COPY --from=prepare-production ${DEPENDENCY}/BOOT-INF/classes /app ENTRYPOINT ["java","-cp","app:app/lib/*","com.company.project.Application"]
- Assistant
This Dockerfile defines a multi-stage build process for a Spring Boot application.
-
The builder stage uses the Maven image to build the application. It copies the
pom.xmlfile and runsmvn dependency:go-offlineto download all the necessary dependencies. Then, it copies the source code and runsmvn installto build the application. -
The dev-envs stage installs additional development environment tools like Git and creates a user for VS Code with Docker access.
-
The prepare-production stage creates a directory for the application dependencies and extracts them from the built JAR file.
-
The final stage uses the Eclipse Temurin JRE image as the base image. It exposes port 8080 and sets the volume for
/tmp. It copies the application dependencies and entry point script from the prepare-production stage. The entry point command runs the application using the classcom.company.project.Application.
Overall, this Dockerfile builds the Spring Boot application, prepares the runtime environment, and sets up the application to be run in a production environment.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.