Optimize Docker build files

This commit is contained in:
Ske 2019-08-12 06:49:18 +02:00
parent 5728f94e00
commit 1604500f2a
3 changed files with 33 additions and 13 deletions

15
.dockerignore Normal file
View File

@ -0,0 +1,15 @@
/.git/
/.github/
/.idea/
/docs/
/logs/
/scripts/
bin/
obj/
*.conf
*.md
Dockerfile
docker-compose.yml

View File

@ -1,9 +1,13 @@
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine AS build
WORKDIR /app WORKDIR /app
COPY PluralKit.API /app/PluralKit.API COPY . /app
COPY PluralKit.Bot /app/PluralKit.Bot RUN dotnet publish -c Release -o out
COPY PluralKit.Core /app/PluralKit.Core
COPY PluralKit.Web /app/PluralKit.Web FROM mcr.microsoft.com/dotnet/core/runtime:2.2-alpine
COPY PluralKit.sln /app WORKDIR /app
RUN dotnet build COPY --from=build /app/PluralKit.*/out ./
ENTRYPOINT ["dotnet"]
CMD ["PluralKit.Bot.dll"]

View File

@ -1,8 +1,9 @@
version: "3" version: "3"
services: services:
bot: bot:
build: . image: pluralkit # This image is reused in the other containers due to the
entrypoint: ["dotnet", "run", "--project", "PluralKit.Bot"] build: . # build instruction right here
command: ["PluralKit.Bot.dll"]
environment: environment:
- "PluralKit:Database=Host=db;Username=postgres;Password=postgres;Database=postgres;Maximum Pool Size=1000" - "PluralKit:Database=Host=db;Username=postgres;Password=postgres;Database=postgres;Maximum Pool Size=1000"
- "PluralKit:InfluxUrl=http://influx:8086" - "PluralKit:InfluxUrl=http://influx:8086"
@ -16,8 +17,8 @@ services:
- influx - influx
restart: always restart: always
web: web:
build: . image: pluralkit
entrypoint: ["dotnet", "run", "--project", "PluralKit.Web"] command: ["PluralKit.Web.dll"]
environment: environment:
- "PluralKit:Database=Host=db;Username=postgres;Password=postgres;Database=postgres;Maximum Pool Size=1000" - "PluralKit:Database=Host=db;Username=postgres;Password=postgres;Database=postgres;Maximum Pool Size=1000"
links: links:
@ -26,8 +27,8 @@ services:
- 2837:5000 - 2837:5000
restart: always restart: always
api: api:
build: . image: pluralkit
entrypoint: ["dotnet", "run", "--project", "PluralKit.API"] command: ["PluralKit.API.dll"]
environment: environment:
- "PluralKit:Database=Host=db;Username=postgres;Password=postgres;Database=postgres;Maximum Pool Size=1000" - "PluralKit:Database=Host=db;Username=postgres;Password=postgres;Database=postgres;Maximum Pool Size=1000"
links: links: