diff --git a/GeradoresWS/Dockerfile b/Dockerfile similarity index 75% rename from GeradoresWS/Dockerfile rename to Dockerfile index 09268d4..5a77da7 100644 --- a/GeradoresWS/Dockerfile +++ b/Dockerfile @@ -2,14 +2,18 @@ FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base WORKDIR /app -EXPOSE 80 +EXPOSE 8080 EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /src + COPY ["GeradoresWS/GeradoresWS.csproj", "GeradoresWS/"] +COPY ["GeradoresService/GeradoresService.csproj", "GeradoresService/"] + RUN dotnet restore "GeradoresWS/GeradoresWS.csproj" COPY . . + WORKDIR "/src/GeradoresWS" RUN dotnet build "GeradoresWS.csproj" -c Release -o /app/build @@ -19,4 +23,9 @@ RUN dotnet publish "GeradoresWS.csproj" -c Release -o /app/publish /p:UseAppHost FROM base AS final WORKDIR /app COPY --from=publish /app/publish . + +# Set environment variables +ENV ASPNETCORE_URLS=http://+:8080 +ENV ASPNETCORE_ENVIRONMENT=Production + ENTRYPOINT ["dotnet", "GeradoresWS.dll"] \ No newline at end of file diff --git a/GeradoresWS/Program.cs b/GeradoresWS/Program.cs index 022ea55..edd379c 100644 --- a/GeradoresWS/Program.cs +++ b/GeradoresWS/Program.cs @@ -10,11 +10,9 @@ builder.Services.AddSwaggerGen(); var app = builder.Build(); // Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) -{ - app.UseSwagger(); - app.UseSwaggerUI(); -} +app.UseSwagger(); +app.UseSwaggerUI(); + app.UseHttpsRedirection(); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d4b49eb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: "3" +services: + geradoresws: + build: . + ports: + - "5000:8080" + networks: + - app-network + + geradoresfe: + build: ./geradoresfe + ports: + - "3000:3000" + depends_on: + - geradoresws + environment: + - REACT_APP_API_URL=http://localhost:5000/ + networks: + - app-network + + +networks: + app-network: + driver: bridge \ No newline at end of file diff --git a/geradoresfe/Dockerfile b/geradoresfe/Dockerfile index c13f01f..192c0f0 100644 --- a/geradoresfe/Dockerfile +++ b/geradoresfe/Dockerfile @@ -1,13 +1,8 @@ FROM node:20-alpine - WORKDIR /app - COPY package.json . - RUN npm install - COPY . . - +ENV REACT_APP_API_URL=http://localhost:5015/ EXPOSE 3000 - CMD ["npm", "start"] \ No newline at end of file diff --git a/geradoresfe/src/Api/GeradorApi.tsx b/geradoresfe/src/Api/GeradorApi.tsx index 9cac19a..bfbc091 100644 --- a/geradoresfe/src/Api/GeradorApi.tsx +++ b/geradoresfe/src/Api/GeradorApi.tsx @@ -1,6 +1,6 @@ import axios, { AxiosResponse } from 'axios'; -const API_URL = 'http://localhost:32769/'; +const API_URL = process.env.REACT_APP_API_URL; class GeradorService { static async GenerateNIF(type: string | null): Promise { diff --git a/geradoresfe/src/components/GeradorNIF.tsx b/geradoresfe/src/components/GeradorNIF.tsx index 9c9acb5..3c04710 100644 --- a/geradoresfe/src/components/GeradorNIF.tsx +++ b/geradoresfe/src/components/GeradorNIF.tsx @@ -67,7 +67,7 @@ export default function GeradorNIF() { - ); +