Casah
Casah
CC#
Created by Casah on 12/24/2024 in #help
Need help with the deployment of my asp.NET core api
By searching a bit, i found that i can use traefik to create a gateway so i have this docker compose file:
version: '3.7'

services:
# Ton serveur principal
vamosvamosserver:
build:
context: ./VamosVamosServer
dockerfile: Dockerfile
container_name: api
labels:
- "traefik.http.routers.api.rule=Host(`localhost`)"
- "traefik.http.services.api.loadbalancer.server.port=8080"
networks:
- web
depends_on:
- db

reverse-proxy:
image: traefik:v2.9
container_name: reverse-proxy
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.myresolver.acme.httpChallenge.entryPoint=web"
- "--certificatesresolvers.myresolver.acme.email=xxxx"
- "--certificatesresolvers.myresolver.acme.storage=/etc/traefik/acme.json"
ports:
- "80:80"
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
networks:
- web
version: '3.7'

services:
# Ton serveur principal
vamosvamosserver:
build:
context: ./VamosVamosServer
dockerfile: Dockerfile
container_name: api
labels:
- "traefik.http.routers.api.rule=Host(`localhost`)"
- "traefik.http.services.api.loadbalancer.server.port=8080"
networks:
- web
depends_on:
- db

reverse-proxy:
image: traefik:v2.9
container_name: reverse-proxy
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.myresolver.acme.httpChallenge.entryPoint=web"
- "--certificatesresolvers.myresolver.acme.email=xxxx"
- "--certificatesresolvers.myresolver.acme.storage=/etc/traefik/acme.json"
ports:
- "80:80"
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
networks:
- web
and this Dockerfile;
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["VamosVamosServer/VamosVamosServer.csproj", "VamosVamosServer/"]
RUN dotnet restore "VamosVamosServer/VamosVamosServer.csproj"
COPY . .
WORKDIR "/src/VamosVamosServer"
RUN dotnet build "VamosVamosServer.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "VamosVamosServer.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "VamosVamosServer.dll"]
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["VamosVamosServer/VamosVamosServer.csproj", "VamosVamosServer/"]
RUN dotnet restore "VamosVamosServer/VamosVamosServer.csproj"
COPY . .
WORKDIR "/src/VamosVamosServer"
RUN dotnet build "VamosVamosServer.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "VamosVamosServer.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "VamosVamosServer.dll"]
I still get the error though
4 replies