diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 2ddceca..0000000 --- a/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:7.0-bullseye-slim AS build -WORKDIR /build - -ENV DEBIAN_FRONTEND=noninteractive - -COPY . . - -# Build project... - - -ARG ASPNET_IMAGE_TAG -FROM mcr.microsoft.com/dotnet/aspnet:7.0.17-bullseye-slim AS final - -COPY --from=build /app /app - -WORKDIR /app -COPY ./script/web-docker-entrypoint.sh ./docker-entrypoint.sh -RUN chmod +x ./docker-entrypoint.sh -EXPOSE 80/tcp diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..242c627 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,18 @@ +ARG ASPNET_IMAGE_TAG=7.0-bullseye-slim-amd64 +ARG DOTNET_SDK=7.0 + +# Stage 2 - Build and publish dotnet application +FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK} AS publish +COPY . . +RUN dotnet restore DfE.IdentifiersApi +RUN dotnet build DfE.IdentifiersApi -c Release +RUN dotnet publish DfE.IdentifiersApi -c Release -o /app --no-build + +COPY ./docker/docker-entrypoint.sh /app/docker-entrypoint.sh + +# Stage 3 - Put into Docker container that will actually be run +FROM mcr.microsoft.com/dotnet/aspnet:${ASPNET_IMAGE_TAG} AS final +COPY --from=publish /app /app +WORKDIR /app +RUN chmod +x ./docker-entrypoint.sh +EXPOSE 80/tcp diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..c6f71fd --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.8" +services: + webapp: + build: + context: .. + dockerfile: docker/Dockerfile + command: /bin/bash -c "./docker-entrypoint.sh dotnet DfE.IdentifiersApi.dll" + ports: + - 80:80/tcp + env_file: + - .env diff --git a/script/web-docker-entrypoint.sh b/docker/docker-entrypoint.sh similarity index 100% rename from script/web-docker-entrypoint.sh rename to docker/docker-entrypoint.sh