-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
526aa12
commit 167d002
Showing
3 changed files
with
58 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,41 @@ | ||
FROM java:8 | ||
VOLUME /tmp | ||
# Copia o .jar para dentro do container | ||
ADD ./target/casafacilimoveis-0.0.1-SNAPSHOT.jar app.jar | ||
# Expõe a porta 8080 | ||
### BUILD image | ||
FROM maven:3-jdk-11 as builder | ||
#Copy Custom Maven settings | ||
#COPY settings.xml /root/.m2/ | ||
# create app folder for sources | ||
RUN mkdir -p /build | ||
WORKDIR /build | ||
COPY pom.xml /build | ||
#Download all required dependencies into one layer | ||
RUN mvn -B dependency:resolve dependency:resolve-plugins | ||
#RUN mvn dependency:resolve-plugins | ||
#Copy source code | ||
COPY src /build/src | ||
# Build application | ||
RUN mvn package -DskipTests | ||
|
||
### BUILD image | ||
FROM openjdk:8 as runtime | ||
EXPOSE 8080 | ||
# Executa | ||
RUN bash -c 'touch /app.jar' | ||
# Passa os comandos para o docker logo quando subir | ||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] | ||
#Set app home folder | ||
ENV APP_HOME /app | ||
#Possibility to set JVM options (https://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html) | ||
ENV JAVA_OPTS="" | ||
|
||
#Create base app folder | ||
RUN mkdir $APP_HOME | ||
#Create folder to save configuration files | ||
RUN mkdir $APP_HOME/config | ||
#Create folder with application logs | ||
RUN mkdir $APP_HOME/log | ||
|
||
VOLUME $APP_HOME/log | ||
VOLUME $APP_HOME/config | ||
|
||
WORKDIR $APP_HOME | ||
#Copy executable jar file from the builder image | ||
COPY --from=builder /build/target/*.jar app.jar | ||
|
||
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar app.jar" ] | ||
#Second option using shell form: | ||
#ENTRYPOINT exec java $JAVA_OPTS -jar app.jar $0 $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM maven:3.5.4-jdk-10-slim | ||
# Pasta de trabalho | ||
WORKDIR /usr/src/java-code | ||
# Copia o back-end para a pasta java-code | ||
COPY . /usr/src/java-code/ | ||
# Executa o comando package pulando os testes | ||
RUN mvn package -DskipTests | ||
|
||
# Defini a pasta de trabalho | ||
WORKDIR /usr/src/java-app | ||
# Executa a cópia do jar gerado para o app.jar | ||
RUN cp /usr/src/java-code/target/*.jar ./app.jar | ||
# Expões a porta 8080 | ||
EXPOSE 8080 | ||
# Executa os comandos quando o app subir | ||
CMD ["java", "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters