FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
WORKDIR /app
ENV TZ=Europe/Moscow
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
EXPOSE 81
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY Campus.ProductCache.sln src/
COPY . .
RUN dotnet publish Campus.ProductCache.sln -o /app
FROM build AS test
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "test", "--logger:trx"]
FROM base AS final
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "Campus.ProductCache.WebApi.dll"]
FROM build AS test
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "test", "--logger:trx"]
version: "3.4"
services:
api:
environment:
- NPGSQL_CONNECTION_STRING=Server = postgres; Port = 5432; Database = test; Persist Security Info = True; Pooling = true; MaxPoolSize = 1000; User Id = postgres; Password = postgres;
- NAME=Campus.ProductCache.WebApi
build:
context: .
dockerfile: Dockerfile
target: test
depends_on:
- postgres
postgres:
image: postgres
restart: always
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=test
volumes:
- ./DbScripts/001_init.sql:/docker-entrypoint-initdb.d/init-1.sql
- ./DbScripts/002_fill_to_test.sql:/docker-entrypoint-initdb.d/init-2.sql
- ./DbScripts/003_fillbase.sql:/docker-entrypoint-initdb.d/init-3.sql
docker-compose run --rm api