Fixed issue with Web Docker image not getting proper environment variable substitution
As ReactJS does not seem to support reading environment variables from Docker runtime variables, we'll pull it instead from buildtime. Also added copying of nginx config file in the Dockerfile Modified API Dockerfile to accept WebUri for CORS, also removed duplicate setting of CORS in Program.cs
This commit is contained in:
@ -13,6 +13,7 @@ ENV ASPNETCORE_Authentication__Auth0__Domain=
|
|||||||
ENV ASPNETCORE_Authentication__Auth0__Identifier=
|
ENV ASPNETCORE_Authentication__Auth0__Identifier=
|
||||||
ENV ASPNETCORE_ConnectionStrings__YABAReadOnlyDbConnectionString=
|
ENV ASPNETCORE_ConnectionStrings__YABAReadOnlyDbConnectionString=
|
||||||
ENV ASPNETCORE_ConnectionStrings__YABAReadWriteDbConnectionString=
|
ENV ASPNETCORE_ConnectionStrings__YABAReadWriteDbConnectionString=
|
||||||
|
ENV ASPNETCORE_WebClient__Url=
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
|
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|||||||
@ -120,13 +120,8 @@ app.MapControllers();
|
|||||||
app.UseMiddleware<AddCustomClaimsMiddleware>();
|
app.UseMiddleware<AddCustomClaimsMiddleware>();
|
||||||
app.UseMiddleware<AddCustomLoggingPropertiesMiddleware>();
|
app.UseMiddleware<AddCustomLoggingPropertiesMiddleware>();
|
||||||
|
|
||||||
app.UseCors(x => x
|
|
||||||
.AllowAnyOrigin()
|
|
||||||
.AllowAnyMethod()
|
|
||||||
.AllowAnyHeader());
|
|
||||||
|
|
||||||
var webClientUrl = configuration.GetSection("WebClient").GetValue<string>("Url");
|
var webClientUrl = configuration.GetSection("WebClient").GetValue<string>("Url");
|
||||||
app.UseCors(x => x.AllowAnyHeader().AllowAnyMethod().WithOrigins(webClientUrl));
|
app.UseCors(x => x.WithOrigins(webClientUrl).AllowAnyMethod().AllowAnyHeader());
|
||||||
app.MapHealthChecks("/Pulse");
|
app.MapHealthChecks("/Pulse");
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|||||||
@ -41,6 +41,6 @@
|
|||||||
"Enrich": ["FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId"]
|
"Enrich": ["FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId"]
|
||||||
},
|
},
|
||||||
"WebClient": {
|
"WebClient": {
|
||||||
"Url": "https://localhost:3000"
|
"Url": "http://localhost:3000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,22 +1,15 @@
|
|||||||
FROM node:17-alpine as builder
|
FROM node:17-alpine as builder
|
||||||
|
|
||||||
# Set the environment variables
|
# Set the environment variables
|
||||||
ENV API_BASE_URL=
|
ARG REACT_APP_API_BASE_URL
|
||||||
ENV AUTH0_DOMAIN=
|
ARG REACT_APP_AUTH0_DOMAIN
|
||||||
ENV AUTH0_CLIENT_ID=
|
ARG REACT_APP_AUTH0_CLIENT_ID
|
||||||
ENV AUTH0_CALLBACK_URL=
|
ARG REACT_APP_AUTH0_CALLBACK_URL
|
||||||
ENV AUTH0_AUDIENCE=
|
ARG REACT_APP_AUTH0_AUDIENCE
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json .
|
COPY package.json .
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
RUN echo 'DEBUG': $API_BASE_URL
|
|
||||||
RUN echo 'DEBUG': $AUTH0_DOMAIN
|
|
||||||
RUN echo 'DEBUG': $AUTH0_CLIENT_ID
|
|
||||||
RUN echo 'DEBUG': $AUTH0_CALLBACK_URL
|
|
||||||
RUN echo 'DEBUG': $AUTH0_AUDIENCE
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
@ -24,5 +17,6 @@ FROM nginx:mainline-alpine
|
|||||||
WORKDIR /usr/share/nginx/html
|
WORKDIR /usr/share/nginx/html
|
||||||
RUN rm -rf ./*
|
RUN rm -rf ./*
|
||||||
COPY --from=builder /app/build .
|
COPY --from=builder /app/build .
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
ENTRYPOINT ["nginx", "-g", "daemon off;"]
|
ENTRYPOINT ["nginx", "-g", "daemon off;"]
|
||||||
Reference in New Issue
Block a user