Unbale to deploy spring boot app via docker

Hey,

Could you take a look at this topic and let me know if it helped?

Jérémy, Render Support

Yes. I provide my own docker file. And it works

sorry i make a confusion
Well i was not able to make it run on render.
so i switch to https://railway.app/
this is my docker file for railway plateforme
also pay attention on your application package name. in my case it is com.msparc
also pay attention on your spring active profile
(Attachment Dockerfile is missing)

syntax=docker/dockerfile:experimental

########Maven build stage########
FROM maven:3.6-jdk-11 as maven_build
WORKDIR /app

#copy pom
COPY pom.xml .

#copy source
COPY src ./src

build the app and download dependencies only when these are new (thanks to the cache)

#RUN --mount=type=cache,target=/root/.m2 mvn clean package -Dmaven.test.skip
RUN mvn clean package -Dmaven.test.skip

split the built app into multiple layers to improve layer rebuild

RUN mkdir -p target/docker-packaging && cd target/docker-packaging && jar -xf …/*.jar

########JRE run stage########
FROM openjdk:11.0-jre
ENV PORT=
WORKDIR /app

#copy built app layer by layer
ARG DOCKER_PACKAGING_DIR=/app/target/docker-packaging
COPY --from=maven_build ${DOCKER_PACKAGING_DIR}/BOOT-INF/lib /app/lib
COPY --from=maven_build ${DOCKER_PACKAGING_DIR}/BOOT-INF/classes /app/classes
COPY --from=maven_build ${DOCKER_PACKAGING_DIR}/META-INF /app/META-INF

#run the app
CMD java -cp .:classes:lib/*
-Djava.security.egd=file:/dev/./urandom
com.msparc.MsParcApplication
–spring.profiles.active=cloud
–server.port=$PORT

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.