Skip to content

Commit

Permalink
Build containers, simplify build
Browse files Browse the repository at this point in the history
  • Loading branch information
dam5s committed Feb 14, 2024
1 parent 0ae26aa commit 1e486d9
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 205 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.idea
bin
obj
build
*.DotSettings.user
21 changes: 0 additions & 21 deletions Build/Build.fsproj

This file was deleted.

27 changes: 0 additions & 27 deletions Build/src/Deploy.fs

This file was deleted.

46 changes: 0 additions & 46 deletions Build/src/DotNet.fs

This file was deleted.

6 changes: 0 additions & 6 deletions Build/src/Fantomas.fs

This file was deleted.

22 changes: 0 additions & 22 deletions Build/src/Program.fs

This file was deleted.

56 changes: 0 additions & 56 deletions Build/src/Support.fs

This file was deleted.

8 changes: 6 additions & 2 deletions Damo.Io.Blog/Damo.Io.Blog.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
</ItemGroup>

<ItemGroup>
<Content Include="posts/**/*">
<None Include="deployment\**\*"/>
</ItemGroup>

<ItemGroup>
<Content Include="posts\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="resources/**/*">
<Content Include="resources\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions Damo.Io.Blog/deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /workspace

COPY . .

RUN dotnet restore

WORKDIR /workspace/Damo.Io.Blog

RUN dotnet run

FROM nginx

COPY --from=build /workspace/Damo.Io.Blog/build/public /usr/share/nginx/html
5 changes: 1 addition & 4 deletions Damo.Io.Blog/src/BlogGenerator/Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ module Build =
|> (fun xml -> xml.Save $"%s{publicPath}/rss.xml")
|> always posts

let private generateHerokuConfig _ =
"""{"root": "public/"}""" |> File.writeString false $"%s{buildPath}/static.json"

let run _ =
cleanupBuildDir ()
copyResources ()
Expand All @@ -91,4 +88,4 @@ module Build =
|> generateTagPages
|> generateIndex
|> generateRssFeed
|> generateHerokuConfig
|> ignore
4 changes: 4 additions & 0 deletions Damo.Io.Server/Damo.Io.Server.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<Compile Include="src\Program.fs" />
</ItemGroup>

<ItemGroup>
<None Include="deployment\**\*" />
</ItemGroup>

<ItemGroup>
<Content Include="www\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
19 changes: 19 additions & 0 deletions Damo.Io.Server/deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /workspace

COPY . .

RUN dotnet restore

WORKDIR /workspace/Damo.Io.Server

RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine

WORKDIR /app

COPY --from=build /workspace/Damo.Io.Server/out .

CMD ["dotnet", "Damo.Io.Server.dll"]
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
.PHONY: restore build lint format
.PHONY: restore clean check format damo.io.server.container damo.io.blog.container dev

restore:
dotnet tool restore
dotnet restore

build:
dotnet run --project Build
clean:
dotnet clean

lint:
dotnet run --project Build lint
check:
dotnet fantomas --check .
dotnet test

format:
dotnet run --project Build format
dotnet fantomas .

damo.io.server.container:
docker build -t damo.io.server -f Damo.Io.Server/deployment/Dockerfile .

damo.io.blog.container:
docker build -t damo.io.blog -f Damo.Io.Blog/deployment/Dockerfile .

dev:
dotnet watch run --project Damo.Io.Server
16 changes: 1 addition & 15 deletions SoManyFeeds.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
#
#
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Damo.Io.Server", "Damo.Io.Server\Damo.Io.Server.fsproj", "{A7157346-F377-4B8A-8CF2-1DB962115171}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Build", "Build\Build.fsproj", "{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FeedsProcessing", "FeedsProcessing\FeedsProcessing.fsproj", "{B4BC8FCB-9682-43BA-8676-680224209DA5}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FeedsProcessing.Tests", "FeedsProcessing.Tests\FeedsProcessing.Tests.fsproj", "{55BB409D-D281-4C3A-A108-5D4517F2E894}"
Expand Down Expand Up @@ -47,18 +45,6 @@ Global
{55BB409D-D281-4C3A-A108-5D4517F2E894}.Release|x64.Build.0 = Release|x64
{55BB409D-D281-4C3A-A108-5D4517F2E894}.Release|x86.ActiveCfg = Release|x86
{55BB409D-D281-4C3A-A108-5D4517F2E894}.Release|x86.Build.0 = Release|x86
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Debug|x64.ActiveCfg = Debug|x64
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Debug|x64.Build.0 = Debug|x64
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Debug|x86.ActiveCfg = Debug|x86
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Debug|x86.Build.0 = Debug|x86
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Release|Any CPU.Build.0 = Release|Any CPU
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Release|x64.ActiveCfg = Release|x64
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Release|x64.Build.0 = Release|x64
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Release|x86.ActiveCfg = Release|x86
{48AB536C-C4D7-4A79-88CD-92DB6CCB3A95}.Release|x86.Build.0 = Release|x86
{E437D872-2D9A-4752-9A38-B52078E6D3A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E437D872-2D9A-4752-9A38-B52078E6D3A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E437D872-2D9A-4752-9A38-B52078E6D3A5}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down

0 comments on commit 1e486d9

Please sign in to comment.