From bac079d2713faf50aaa6c8e426a31477760f7e27 Mon Sep 17 00:00:00 2001 From: Lauro Correia Silveira Date: Tue, 19 Dec 2023 10:57:59 +0100 Subject: [PATCH] Added port configuration to deploy on railway --- Dockerfile | 3 --- .../infraestructure/railway/RailwayConfig.java | 13 +++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/alura/aluraflixapi/infraestructure/railway/RailwayConfig.java diff --git a/Dockerfile b/Dockerfile index 8c4f3d8..1d586a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,6 @@ RUN mvn clean package -DskipTests FROM eclipse-temurin:21-jre-alpine WORKDIR /alura-flix-api -ARG DATABASE_PRO -ARG DATABASE_TEST -ARG JWT_SECRET COPY --from=build target/*.jar alura-flix-api.jar EXPOSE 8080 diff --git a/src/main/java/com/alura/aluraflixapi/infraestructure/railway/RailwayConfig.java b/src/main/java/com/alura/aluraflixapi/infraestructure/railway/RailwayConfig.java new file mode 100644 index 0000000..913d972 --- /dev/null +++ b/src/main/java/com/alura/aluraflixapi/infraestructure/railway/RailwayConfig.java @@ -0,0 +1,13 @@ +package com.alura.aluraflixapi.infraestructure.railway; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class RailwayConfig { + + @Bean + String getPort(){ + return System.getenv("PORT"); + } +}