chore: add per-project Dockerfile

This commit is contained in:
Oliver Booth 2023-08-13 16:38:56 +01:00
parent 9475205196
commit be44fb4b4b
Signed by: oliverbooth
GPG Key ID: B89D139977693FED
4 changed files with 35 additions and 18 deletions

View File

@ -0,0 +1,20 @@
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 ["OliverBooth.Blog/OliverBooth.Blog.csproj", "OliverBooth.Blog/"]
RUN dotnet restore "OliverBooth.Blog/OliverBooth.Blog.csproj"
COPY . .
WORKDIR "/src/OliverBooth.Blog"
RUN dotnet build "OliverBooth.Blog.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "OliverBooth.Blog.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "OliverBooth.Blog.dll"]

View File

@ -1,4 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OliverBooth", "OliverBooth\OliverBooth.csproj", "{A58A6FA3-480C-400B-822A-3786741BF39C}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OliverBooth", "OliverBooth\OliverBooth.csproj", "{A58A6FA3-480C-400B-822A-3786741BF39C}"
EndProject EndProject
@ -11,7 +11,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.dockerignore = .dockerignore .dockerignore = .dockerignore
docker-compose.yml = docker-compose.yml docker-compose.yml = docker-compose.yml
global.json = global.json global.json = global.json
Dockerfile = Dockerfile
EndProjectSection EndProjectSection
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8A323E64-E41E-4780-99FD-17BF58961FB5}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8A323E64-E41E-4780-99FD-17BF58961FB5}"

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
EXPOSE 443 EXPOSE 443
@ -6,7 +6,7 @@ EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src WORKDIR /src
COPY ["OliverBooth/OliverBooth.csproj", "OliverBooth/"] COPY ["OliverBooth/OliverBooth.csproj", "OliverBooth/"]
RUN dotnet restore "oliverbooth.dev/oliverbooth.dev.csproj" RUN dotnet restore "OliverBooth/OliverBooth.csproj"
COPY . . COPY . .
WORKDIR "/src/OliverBooth" WORKDIR "/src/OliverBooth"
RUN dotnet build "OliverBooth.csproj" -c Release -o /app/build RUN dotnet build "OliverBooth.csproj" -c Release -o /app/build

View File

@ -3,7 +3,9 @@ services:
oliverbooth: oliverbooth:
container_name: oliverbooth.dev container_name: oliverbooth.dev
pull_policy: build pull_policy: build
build: . build:
context: .
dockerfile: OliverBooth/Dockerfile
volumes: volumes:
- type: bind - type: bind
source: /var/log/oliverbooth/site source: /var/log/oliverbooth/site
@ -11,27 +13,23 @@ services:
- type: bind - type: bind
source: /etc/oliverbooth/site source: /etc/oliverbooth/site
target: /app/data target: /app/data
ports:
- "2845:2845"
restart: always restart: always
environment:
- MYSQL_HOST=${MYSQL_HOST}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
oliverbooth-blog: oliverbooth-blog:
container_name: blog.oliverbooth.dev container_name: blog.oliverbooth.dev
pull_policy: build pull_policy: build
build: . build:
context: .
dockerfile: OliverBooth/Dockerfile
volumes: volumes:
- type: bind - type: bind
source: /var/log/oliverbooth-blog/site source: /var/log/oliverbooth/blog
target: /app/logs target: /app/logs
- type: bind - type: bind
source: /etc/oliverbooth-blog/site source: /etc/oliverbooth/blog
target: /app/data target: /app/data
ports:
- "2846:2846"
restart: always restart: always
environment:
- MYSQL_HOST=${MYSQL_HOST}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}