Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added View into output directory #19

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,26 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4


- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
global-json: 'global.json'

- name: Install dependencies
run: dotnet restore
working-directory: ./AutomatedTestingApp

- name: Build
run: |
dotnet build ${{ env.PROJECT_NAME }} --configuration Release --no-restore
working-directory: ${{ env.PROJECT_PATH }}

- name: Publish
run: |
dotnet publish ${{ env.PROJECT_NAME }} --no-build --no-restore --configuration Release --output ./publish
working-directory: ${{ env.PROJECT_PATH }}

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
Expand All @@ -26,4 +45,6 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: hiresm/czechitas:latest
tags: hiresm/czechitas:latest
args: |
--build-arg APP_PATH=./publish
37 changes: 20 additions & 17 deletions AutomatedTestingApp/AutomatedTestingApp/AutomatedTestingApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>


<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.11">
Expand All @@ -21,25 +17,32 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.11" />
</ItemGroup>


<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>


<Content Update="Areas\**\*.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="Views\**\*.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<None Update="Data\AutomatedTestingApp.db">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>



<ItemGroup>
<_ContentIncludedByDefault Remove="Views\Account\Index.cshtml" />
<_ContentIncludedByDefault Remove="Views\Articles\Index.cshtml" />
</ItemGroup>


<Target Name="CopyAreas" AfterTargets="Publish">
<ItemGroup>
<Folder Include="Areas\**\*.cshtml" />
</ItemGroup>
<Copy SourceFiles="@(Folder)" DestinationFolder="$(PublishDir)\Areas\%(RecursiveDir)" />
</Target>
<Target Name="CopyViews" AfterTargets="Publish">
<ItemGroup>
<Folder Include="Views\**\*.cshtml" />
</ItemGroup>
<Copy SourceFiles="@(Folder)" DestinationFolder="$(PublishDir)\Views\%(RecursiveDir)" />
</Target>
</Project>
17 changes: 5 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app

EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["AutomatedTestingApp/AutomatedTestingApp/AutomatedTestingApp.csproj", "AutomatedTestingApp/"]
RUN dotnet restore "AutomatedTestingApp/AutomatedTestingApp.csproj"
COPY . .
WORKDIR "/src/AutomatedTestingApp"

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

COPY ${APP_PATH} ./

ENTRYPOINT ["dotnet", "AutomatedTestingApp.dll"]
7 changes: 7 additions & 0 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -ex

dotnet publish AutomatedTestingApp/AutomatedTestingApp/AutomatedTestingApp.csproj -c Release -o out /p:UseAppHost=false

docker build --build-arg APP_PATH=./out -t hiresm/czechitas:test .
Loading