diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..73ed90f --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,20 @@ + +# build +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +WORKDIR /src + +COPY *.csproj . +RUN dotnet restore + +COPY . . +RUN dotnet publish -c Release -o /app/publish + +# run +FROM mcr.microsoft.com/dotnet/aspnet:10.0 +WORKDIR /app +ENV ASPNETCORE_URLS=http://+:8080 +COPY --from=build /app/publish . + +EXPOSE 8080 + +ENTRYPOINT ["dotnet", "agologum-api.dll"] diff --git a/api/Program.cs b/api/Program.cs index ee9d65d..808352b 100644 --- a/api/Program.cs +++ b/api/Program.cs @@ -19,7 +19,7 @@ var summaries = new[] "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; -app.MapGet("/weatherforecast", () => +app.MapGet("api/weatherforecast", () => { var forecast = Enumerable.Range(1, 5).Select(index => new WeatherForecast diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..94ed182 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,20 @@ + +# build vue app +FROM node:current-alpine AS build + +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# serve to nginx +FROM nginx:alpine + +COPY --from=build /app/dist /usr/share/nginx/html + +RUN rm /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/client/nginx.conf b/client/nginx.conf new file mode 100644 index 0000000..d8060ad --- /dev/null +++ b/client/nginx.conf @@ -0,0 +1,12 @@ + +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } +}