-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.api
38 lines (34 loc) · 1.79 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
# Set the major version of dotnet
ARG DOTNET_VERSION=8.0
# Build the app using the dotnet SDK
FROM "mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-azurelinux3.0" AS build
WORKDIR /build
COPY ./Dfe.ManageFreeSchoolProjects/ /build
RUN ["dotnet", "restore", "Dfe.ManageFreeSchoolProjects.API"]
RUN ["dotnet", "build", "Dfe.ManageFreeSchoolProjects.API", "--no-restore", "-c", "Release"]
RUN ["dotnet", "publish", "Dfe.ManageFreeSchoolProjects.API", "--no-build", "-o", "/app"]
RUN ["dotnet", "new", "tool-manifest"]
RUN ["dotnet", "tool", "install", "dotnet-ef", "--version", "8.0.11"]
RUN ["mkdir", "-p", "/app/SQL"]
RUN ["dotnet", "restore", "Dfe.ManageFreeSchoolProjects.Data"]
RUN ["dotnet", "build", "Dfe.ManageFreeSchoolProjects.Data", "--no-restore"]
RUN ["dotnet", "ef", "migrations", "script", "--output", "/app/SQL/DbMigrationScript.sql", "--idempotent", "-p", "/build/Dfe.ManageFreeSchoolProjects.Data", "--no-build"]
RUN ["touch", "/app/SQL/DbMigrationScriptOutput.txt"]
# Install SQL tools to allow migrations to be run
FROM "mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}-azurelinux3.0" AS base
RUN curl "https://packages.microsoft.com/config/rhel/9/prod.repo" | tee /etc/yum.repos.d/mssql-release.repo
ENV ACCEPT_EULA=Y
RUN ["tdnf", "update"]
RUN ["tdnf", "install", "-y", "mssql-tools18"]
RUN ["tdnf", "clean", "all"]
# Build a runtime environment
FROM base AS runtime
WORKDIR /app
LABEL org.opencontainers.image.source="https://github.com/DFE-Digital/manage-free-school-projects"
LABEL org.opencontainers.image.description="Manage Free School Projects - API"
COPY --from=build /app /app
COPY ./script/api-docker-entrypoint.sh /app/docker-entrypoint.sh
RUN ["chmod", "+x", "/app/docker-entrypoint.sh"]
RUN ["touch", "/app/SQL/DbMigrationScriptOutput.txt"]
RUN chown "$APP_UID" "/app/SQL" -R
USER $APP_UID