From 4b5f0c2b9607afe84dfbb1da8e1f551ebecb4673 Mon Sep 17 00:00:00 2001 From: FUH22860 <101731147+FUH22860@users.noreply.github.com> Date: Thu, 22 Jun 2023 22:46:35 +0200 Subject: [PATCH] Feature/docker (#31) * Add Docker capabilities Changed launchSettings Added Dockerfile && docker-compose with traefik labels * Relocate launchSettings.json * Delete workflows Not needed anymore * Add Docker for WebApi Added docker-compose && Dockerfile * Fix minor mistakes --------- Co-authored-by: ProfessionalUwU --- .github/workflows/main.yml | 29 ----------------------- Dockerfile | 6 +++++ docker-compose.yml | 22 +++++++++++++++++ src/WebApi/Dockerfile | 6 +++++ src/WebApi/Properties/launchSettings.json | 2 +- src/WebApi/docker-compose.yml | 23 ++++++++++++++++++ src/y4f/Properties/launchSettings.json | 2 +- 7 files changed, 59 insertions(+), 31 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 src/WebApi/Dockerfile create mode 100644 src/WebApi/docker-compose.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 2682011..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Deploy blazor to GitHub Pages - -on: - push: - branches: [ "dev" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 7.0 - - name: Publish - run: dotnet publish --configuration Release -o release --nologo --runtime linux-x64 --self-contained src/y4f/y4f.csproj - - name: Commit wwwroot to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages - FOLDER: release/wwwroot - - name: Change base-tag in index.html from / to y4f - run: sed -i 's///g' release/wwwroot/index.html - - name: Add .nojekyll file - run: touch release/wwwroot/.nojekyll diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..94047e0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 +WORKDIR /App +COPY . ./ +RUN dotnet restore +EXPOSE 5248 +CMD /usr/bin/dotnet run --project /App/src/y4f/y4f.csproj \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d0ac136 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: "3.4" +services: + y4f: + build: . + ports: + - "5248:5248" + labels: + - traefik.docker.network=traefik + - traefik.enable=true + - traefik.http.routers.y4f.entrypoints=web-secure + - traefik.http.routers.y4f.rule=Host(`y4f.hopeless-cloud.xyz`) + - traefik.http.routers.y4f.tls=true + - traefik.http.routers.y4f.tls.certResolver=default + networks: + - default + - traefik + restart: unless-stopped +networks: + default: + name: y4f-default + traefik: + external: true \ No newline at end of file diff --git a/src/WebApi/Dockerfile b/src/WebApi/Dockerfile new file mode 100644 index 0000000..2759424 --- /dev/null +++ b/src/WebApi/Dockerfile @@ -0,0 +1,6 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 +WORKDIR /App +COPY . ./ +RUN dotnet restore +EXPOSE 5226 +CMD /usr/bin/dotnet run --project /App/WebApi.csproj \ No newline at end of file diff --git a/src/WebApi/Properties/launchSettings.json b/src/WebApi/Properties/launchSettings.json index 5bfc5a7..5b7e490 100644 --- a/src/WebApi/Properties/launchSettings.json +++ b/src/WebApi/Properties/launchSettings.json @@ -14,7 +14,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "http://localhost:5226", + "applicationUrl": "http://0.0.0.0:5226", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/WebApi/docker-compose.yml b/src/WebApi/docker-compose.yml new file mode 100644 index 0000000..04d4301 --- /dev/null +++ b/src/WebApi/docker-compose.yml @@ -0,0 +1,23 @@ +version: "3.4" +services: + y4f-webapi: + build: . + ports: + - "5226:5226" + labels: + - traefik.docker.network=traefik + - traefik.enable=true + - traefik.http.routers.y4f-webapi.entrypoints=web-secure + - traefik.http.routers.y4f-webapi.rule=Host(`api.y4f.hopeless-cloud.xyz`) + - traefik.http.routers.y4f-webapi.tls=true + - traefik.http.routers.y4f-webapi.tls.certResolver=default + networks: + - default + - traefik + restart: unless-stopped +networks: + default: + name: y4f-default + external: true + traefik: + external: true \ No newline at end of file diff --git a/src/y4f/Properties/launchSettings.json b/src/y4f/Properties/launchSettings.json index a42f794..1219d03 100644 --- a/src/y4f/Properties/launchSettings.json +++ b/src/y4f/Properties/launchSettings.json @@ -13,7 +13,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "applicationUrl": "http://localhost:5248", + "applicationUrl": "http://0.0.0.0:5248", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }