Skip to content

Commit

Permalink
Move to Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
elotoja committed Dec 26, 2023
1 parent 31bf814 commit bb42488
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 37 deletions.
30 changes: 30 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
15 changes: 6 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish and push the container image
run: |
dotnet publish --os linux --arch x64 -p:PublishProfile=DefaultContainer -c Release

- name: Build the Docker image
run: docker build -t ghcr.io/${{ github.repository_owner }}/${{ github.repository_name }}:latest .

- name: Push the container image
run: docker push ghcr.io/${{ github.repository_owner }}/${{ github.repository_name }}:latest
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/Quizer.Api/Quizer.Api.csproj", "./src/Quizer.Api/"]
COPY ["src/Quizer.Contracts/Quizer.Contracts.csproj", "./src/Quizer.Contracts/"]
COPY ["src/Quizer.Application/Quizer.Application.csproj", "./src/Quizer.Application/"]
COPY ["src/Quizer.Domain/Quizer.Domain.csproj", "./src/Quizer.Domain/"]
COPY ["src/Quizer.Infrastructure/Quizer.Infrastructure.csproj", "./src/Quizer.Infrastructure/"]
RUN dotnet restore "./src/Quizer.Api/Quizer.Api.csproj"
COPY . .
WORKDIR "/src/Quizer.Api"
RUN dotnet build "./Quizer.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Quizer.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Quizer.Api.dll"]
13 changes: 13 additions & 0 deletions appsettings.Production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"JwtSettings": {
"Secret": "",
"Issuer": "quizer.elotoja.com",
"Audience": "quizer.elotoja.com"
},
"Swagger": {
"Enabled": true
},
"ConnectionStrings": {
"DefaultConnection": ""
}
}
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ services:
image: ghcr.io/quizer-app/quizer:latest
container_name: quizer
volumes:
- ./appsettings.json:/home/runner/work/Quizer/Quizer/src/Quizer.Api/appsettings.Production.json
restart: unless-stopped
- ./appsettings.json:/app/src/Quizer.Api/appsettings.Production.json
restart: unless-stopped
7 changes: 0 additions & 7 deletions src/Quizer.Api/Quizer.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<UserSecretsId>d5aba78c-3529-4cb4-8caf-891dfecd83de</UserSecretsId>
<ContainerImageTags>latest</ContainerImageTags>
<ContainerRegistry>ghcr.io</ContainerRegistry>
<ContainerRepository>quizer-app/quizer</ContainerRepository>
</PropertyGroup>

<ItemGroup>
<ContainerPort Include="80" Type="tcp" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Mapster.DependencyInjection" Version="1.0.1" />
Expand Down
6 changes: 0 additions & 6 deletions src/Quizer.Validation/IValidatorAssemblyMarker.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/Quizer.Validation/Quizer.Validation.csproj

This file was deleted.

0 comments on commit bb42488

Please sign in to comment.