-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.api
46 lines (32 loc) · 1.62 KB
/
Dockerfile.api
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Stage 1
ARG ASPNET_IMAGE_TAG=8.0-bookworm-slim
ARG DOTNET_SDK_IMAGE_TAG=8.0
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_IMAGE_TAG} AS publish
WORKDIR /build
ENV DEBIAN_FRONTEND=noninteractive
COPY Dfe.ManageFreeSchoolProjects/. .
RUN dotnet restore Dfe.ManageFreeSchoolProjects.API
RUN dotnet build Dfe.ManageFreeSchoolProjects.API -c Release
RUN dotnet new tool-manifest
RUN dotnet tool install dotnet-ef --version 7.0.13
RUN mkdir -p /app/SQL
RUN dotnet ef migrations script --output /app/SQL/DbMigrationScript.sql --idempotent -p /build/Dfe.ManageFreeSchoolProjects.Data
RUN touch /app/SQL/DbMigrationScript.sql
RUN dotnet publish Dfe.ManageFreeSchoolProjects.API -c Release -o /app --no-build
COPY ./script/api-docker-entrypoint.sh /app/docker-entrypoint.sh
# Stage 3 - Final
FROM "mcr.microsoft.com/dotnet/aspnet:${ASPNET_IMAGE_TAG}" AS final
LABEL org.opencontainers.image.source=https://github.com/DFE-Digital/manage-free-school-projects
LABEL org.opencontainers.image.description="Manage Free School Projects - API"
ENV ASPNETCORE_HTTP_PORTS=80
RUN apt-get update
RUN apt-get install unixodbc curl gnupg jq -y
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
RUN curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc
RUN curl https://packages.microsoft.com/config/debian/12/prod.list | tee /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install msodbcsql18 mssql-tools18 -y
COPY --from=publish /app /app
WORKDIR /app
RUN chmod +x ./docker-entrypoint.sh
EXPOSE 80/tcp