Docker setup optimizations/tweaks
This commit is contained in:
		| @@ -1,18 +1,11 @@ | |||||||
| /.git/ | # Start by excluding everything | ||||||
| /.github/ | * | ||||||
| /.idea/ |  | ||||||
| /docs/ |  | ||||||
| /logs/ |  | ||||||
| /scripts/ |  | ||||||
|  |  | ||||||
| bin/ | # Include project code and build files | ||||||
| obj/ | !PluralKit.*/ | ||||||
|  | !PluralKit.sln | ||||||
|  | !nuget.config | ||||||
|  |  | ||||||
| *.conf | # Re-exclude host build artifact directories | ||||||
| *.md | **/bin | ||||||
| *.sql | **/obj | ||||||
| *.gz |  | ||||||
| *.tar |  | ||||||
|  |  | ||||||
| Dockerfile |  | ||||||
| docker-compose.yml |  | ||||||
							
								
								
									
										25
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								Dockerfile
									
									
									
									
									
								
							| @@ -1,14 +1,19 @@ | |||||||
| FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build |  | ||||||
|  |  | ||||||
| WORKDIR /app |  | ||||||
| COPY . /app |  | ||||||
| RUN dotnet publish -c Release -o out -f netcoreapp3.1 |  | ||||||
|  |  | ||||||
| FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine | FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine | ||||||
| WORKDIR /app | WORKDIR /app | ||||||
| RUN dotnet tool install --global dotnet-trace && dotnet tool install --global dotnet-dump && dotnet tool install --global dotnet-counters |  | ||||||
| COPY --from=build /app/PluralKit.*/bin/Release/netcoreapp3.1 ./ |  | ||||||
|  |  | ||||||
|  | # Restore/fetch dependencies excluding app code to make use of caching | ||||||
|  | COPY PluralKit.sln nuget.config /app/ | ||||||
|  | COPY PluralKit.API/PluralKit.API.csproj /app/PluralKit.API/ | ||||||
|  | COPY PluralKit.Bot/PluralKit.Bot.csproj /app/PluralKit.Bot/ | ||||||
|  | COPY PluralKit.Core/PluralKit.Core.csproj /app/PluralKit.Core/ | ||||||
|  | COPY PluralKit.Tests/PluralKit.Tests.csproj /app/PluralKit.Tests/ | ||||||
|  | RUN dotnet restore PluralKit.sln | ||||||
|  |  | ||||||
|  | # Copy the rest of the code and build | ||||||
|  | COPY . /app | ||||||
|  | RUN dotnet build -c Release -o bin | ||||||
|  |  | ||||||
|  | # Run :) | ||||||
|  | # Allow overriding CMD from eg. docker-compose to run API layer too | ||||||
| ENTRYPOINT ["dotnet"] | ENTRYPOINT ["dotnet"] | ||||||
| CMD ["PluralKit.Bot.dll"] | CMD ["bin/PluralKit.Bot.dll"] | ||||||
|  |  | ||||||
| @@ -1,9 +1,13 @@ | |||||||
|  | # API port: 2838, InfluxDB port: 2839, both listen on localhost only | ||||||
|  | # Reads `pluralkit.conf` from current directory, and logs to `/var/log/pluralkit`. | ||||||
|  |  | ||||||
| version: "3" | version: "3" | ||||||
|  |  | ||||||
| services: | services: | ||||||
|   bot: |   bot: | ||||||
|     image: pluralkit # This image is reused in the other containers due to the |     image: pluralkit # This image is reused in the other containers due to the | ||||||
|     build: .         # build instruction right here |     build: .         # build instruction right here | ||||||
|     command: ["PluralKit.Bot.dll"] |     command: ["bin/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" | ||||||
| @@ -12,35 +16,39 @@ services: | |||||||
|     volumes: |     volumes: | ||||||
|       - "./pluralkit.conf:/app/pluralkit.conf:ro" |       - "./pluralkit.conf:/app/pluralkit.conf:ro" | ||||||
|       - "/var/log/pluralkit:/var/log/pluralkit" |       - "/var/log/pluralkit:/var/log/pluralkit" | ||||||
|     links: |     restart: unless-stopped | ||||||
|       - db |  | ||||||
|       - influx |  | ||||||
|     restart: always |  | ||||||
|   api: |   api: | ||||||
|     image: pluralkit |     image: pluralkit | ||||||
|     command: ["PluralKit.API.dll"] |     command: ["bin/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: |  | ||||||
|       - db |  | ||||||
|     ports: |     ports: | ||||||
|       - "127.0.0.1:2838:5000" |       - "127.0.0.1:2838:5000" | ||||||
|     restart: always |     restart: unless-stopped | ||||||
|  |  | ||||||
|   db: |   db: | ||||||
|     image: postgres:11-alpine |     image: postgres:12-alpine | ||||||
|     volumes: |     volumes: | ||||||
|       - "db_data:/var/lib/postgresql/data" |       - "db_data:/var/lib/postgresql/data" | ||||||
|     restart: always |       - "/var/run/postgresql:/var/run/postgresql" | ||||||
|     command: ["postgres", "-c", "max-connections=1000"] |     command: ["postgres", | ||||||
|  |               "-c", "max-connections=1000", | ||||||
|  |               "-c", "timezone='Etc/UTC'", | ||||||
|  |               "-c", "max_wal_size=1GB", | ||||||
|  |               "-c", "min_wal_size=80MB", | ||||||
|  |               "-c", "shared_buffers=128MB"] | ||||||
|     environment: |     environment: | ||||||
|       - "POSTGRES_PASSWORD=postgres" |       - "POSTGRES_PASSWORD=postgres" | ||||||
|  |     restart: unless-stopped | ||||||
|  |  | ||||||
|   influx: |   influx: | ||||||
|     image: influxdb:alpine |     image: influxdb:alpine | ||||||
|     volumes: |     volumes: | ||||||
|       - "influx_data:/var/lib/influxdb" |       - "influx_data:/var/lib/influxdb" | ||||||
|     ports: |     ports: | ||||||
|       - 2839:8086 |       - 127.0.0.1:2839:8086 | ||||||
|     restart: always |     restart: unless-stopped | ||||||
|  |  | ||||||
| volumes: | volumes: | ||||||
|   db_data: |   db_data: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user