Skip to content

Commit

Permalink
Add build process for machine
Browse files Browse the repository at this point in the history
  • Loading branch information
rstropek committed Nov 22, 2020
1 parent b519424 commit 372107c
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Build Microservice Demo App
name: Build Microservice Demo App (API)

on:
push:
branches:
- main
paths-ignore:
- "NetCoreMicroserviceSample/NetCoreMicroserviceSample.Machine/**"
env:
DOTNET_VERSION: '5.0'
NODE_VERSION: '14.x'
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/build-machine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build Microservice Demo App (Machine)

on:
push:
branches:
- main
paths-ignore:
- "NetCoreMicroserviceSample/NetCoreMicroserviceSample.Api/**"
- "NetCoreMicroserviceSample/NetCoreMicroserviceSample.UserInterface/**"
env:
DOTNET_VERSION: '5.0'
MACHINE_PATH: './NetCoreMicroserviceSample/NetCoreMicroserviceSample.Machine'
CONFIG: 'Debug'

jobs:
build:
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@master

- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: ${{ env.MACHINE_PATH }}/..
file: ${{ env.MACHINE_PATH }}/Dockerfile
push: true
tags: rstropek/net-core-microservice-sample-machine:latest
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY NetCoreMicroserviceSample.Machine/*.csproj NetCoreMicroserviceSample.Machine/
RUN cd NetCoreMicroserviceSample.Machine && dotnet restore

# copy everything else and build app
COPY . .
RUN cd NetCoreMicroserviceSample.Machine && dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
WORKDIR /app
COPY --from=build /app/NetCoreMicroserviceSample.Machine/out ./
ENTRYPOINT ["dotnet", "NetCoreMicroserviceSample.Machine.dll"]
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.33.1" />
<PackageReference Include="LettuceEncrypt" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
if (Configuration.GetValue<bool>("UseLetsEncrypt", false))
{
services.AddLettuceEncrypt();
}

string domain = $"{Configuration["Oidc:Domain"]}";
services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
},
"Oidc": {
"Domain": "https://demo.identityserver.io",
"Audience": "api",
"Audience": "api",
"ClientId": "interactive.confidential",
"ClientSecret": "secret"
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"UseLetsEncrypt": true,
"LettuceEncrypt": {
"AcceptTermsOfService": true,
"UseStagingServer": true,
"DomainNames": [ "machine-microservice-training.westeurope.azurecontainer.io" ],
"EmailAddress": "[email protected]"
}
}

0 comments on commit 372107c

Please sign in to comment.