From 1604500f2a66985c4e82a909dd7154243d2f915e Mon Sep 17 00:00:00 2001 From: Ske Date: Mon, 12 Aug 2019 06:49:18 +0200 Subject: [PATCH] Optimize Docker build files --- .dockerignore | 15 +++++++++++++++ Dockerfile | 18 +++++++++++------- docker-compose.yml | 13 +++++++------ 3 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..85524c7a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +/.git/ +/.github/ +/.idea/ +/docs/ +/logs/ +/scripts/ + +bin/ +obj/ + +*.conf +*.md + +Dockerfile +docker-compose.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 18653e98..0f6b47cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 -COPY PluralKit.API /app/PluralKit.API -COPY PluralKit.Bot /app/PluralKit.Bot -COPY PluralKit.Core /app/PluralKit.Core -COPY PluralKit.Web /app/PluralKit.Web -COPY PluralKit.sln /app -RUN dotnet build +COPY . /app +RUN dotnet publish -c Release -o out + +FROM mcr.microsoft.com/dotnet/core/runtime:2.2-alpine +WORKDIR /app +COPY --from=build /app/PluralKit.*/out ./ + +ENTRYPOINT ["dotnet"] +CMD ["PluralKit.Bot.dll"] + diff --git a/docker-compose.yml b/docker-compose.yml index 6a5f313e..251b3fba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,9 @@ version: "3" services: bot: - build: . - entrypoint: ["dotnet", "run", "--project", "PluralKit.Bot"] + image: pluralkit # This image is reused in the other containers due to the + build: . # build instruction right here + command: ["PluralKit.Bot.dll"] environment: - "PluralKit:Database=Host=db;Username=postgres;Password=postgres;Database=postgres;Maximum Pool Size=1000" - "PluralKit:InfluxUrl=http://influx:8086" @@ -16,8 +17,8 @@ services: - influx restart: always web: - build: . - entrypoint: ["dotnet", "run", "--project", "PluralKit.Web"] + image: pluralkit + command: ["PluralKit.Web.dll"] environment: - "PluralKit:Database=Host=db;Username=postgres;Password=postgres;Database=postgres;Maximum Pool Size=1000" links: @@ -26,8 +27,8 @@ services: - 2837:5000 restart: always api: - build: . - entrypoint: ["dotnet", "run", "--project", "PluralKit.API"] + image: pluralkit + command: ["PluralKit.API.dll"] environment: - "PluralKit:Database=Host=db;Username=postgres;Password=postgres;Database=postgres;Maximum Pool Size=1000" links: