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 <andre.fuhry@hopeless-cloud.xyz>
This commit is contained in:
FUH22860 2023-06-22 22:46:35 +02:00 committed by GitHub
parent cc4ffab409
commit 4b5f0c2b96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 59 additions and 31 deletions

View File

@ -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/<base href="\/" \/>/<base href="\/y4f\/" \/>/g' release/wwwroot/index.html
- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll

6
Dockerfile Normal file
View File

@ -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

22
docker-compose.yml Normal file
View File

@ -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

6
src/WebApi/Dockerfile Normal file
View File

@ -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

View File

@ -14,7 +14,7 @@
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger", "launchUrl": "swagger",
"applicationUrl": "http://localhost:5226", "applicationUrl": "http://0.0.0.0:5226",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -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

View File

@ -13,7 +13,7 @@
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5248", "applicationUrl": "http://0.0.0.0:5248",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }