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 to build and run a Spring Boot application.
The first stage, named "builder", uses the Maven image as the base image and sets the working directory to
/workdir/server. It copies thepom.xmlfile and runs themvn dependency:go-offlinecommand to download the project dependencies and cache them in the local repository. Then, it copies the source code and runsmvn installto build the application.The second stage, named "dev-envs", sets up the development environment by installing git and creating a non-root user named "vscode". It also adds the user "vscode" to the "docker" group to allow Docker commands to be executed within the container.
The third stage, named "prepare-production", creates a directory named
/workdir/server/target/dependencyand extracts the dependencies from the built JAR file into that directory.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.