forked from Dotnet-Boxed/Templates
/
Dockerfile
58 lines (55 loc) · 2.73 KB
/
Dockerfile
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
47
48
49
50
51
52
53
54
55
56
57
58
# To build this Dockerfile, run the following command from the solution directory:
# docker build --file "Source\GraphQLTemplate\Dockerfile" --tag graph .
# Or you can use the experimental buildx command for a better experience:
# docker buildx build --progress plain --file "Source\GraphQLTemplate\Dockerfile" --tag graph .
# Base image used by Visual Studio at development time
# (See https://docs.microsoft.com/en-us/visualstudio/containers/container-msbuild-properties)
FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine AS base
# Open Container Initiative (OCI) labels (See https://github.com/opencontainers/image-spec/blob/master/annotations.md).
LABEL org.opencontainers.image.title="PROJECT-TITLE" \
org.opencontainers.image.description="PROJECT-DESCRIPTION" \
#if (GitHub)
org.opencontainers.image.documentation="https://github.com/GITHUB-USERNAME/GITHUB-PROJECT" \
org.opencontainers.image.source="https://github.com/GITHUB-USERNAME/GITHUB-PROJECT.git" \
org.opencontainers.image.url="https://github.com/GITHUB-USERNAME/GITHUB-PROJECT" \
#endif
org.opencontainers.image.vendor="PROJECT-AUTHOR"
# Disable the culture invariant mode which defaults to true in the base alpine image
# (See https://github.com/dotnet/corefx/blob/8245ee1e8f6063ccc7a3a60cafe821d29e85b02f/Documentation/architecture/globalization-invariant-mode.md)
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
RUN apk add --no-cache \
# Install cultures to enable use of System.CultureInfo
icu-libs \
# Install time zone database to enable use of System.TimeZoneInfo
tzdata
# Set the default locale and language.
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
WORKDIR /app
#if (HttpsEverywhere)
EXPOSE 80 443
##else
#EXPOSE 80
#endif
# SDK image used to build and publish the application
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS sdk
# To use the debug build configuration pass --build-arg Configuration=Debug
ARG Configuration=Release
ENV DOTNET_CLI_TELEMETRY_OPTOUT=true \
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
WORKDIR /src
COPY "GraphQLTemplate.sln" "."
COPY "Source/GraphQLTemplate/*.csproj" "Source/GraphQLTemplate/"
COPY "Tests/GraphQLTemplate.IntegrationTest/*.csproj" "Tests/GraphQLTemplate.IntegrationTest/"
RUN dotnet restore
COPY . .
# To view the files that have been copied into the container file system for debugging purposes uncomment this line
# RUN apk add --no-cache tree && tree
RUN dotnet build --configuration $Configuration --no-restore
RUN dotnet test --configuration $Configuration --no-build
RUN dotnet publish "Source/GraphQLTemplate/GraphQLTemplate.csproj" --configuration $Configuration --no-build --output /app
# Runtime image used to run the application
FROM base AS runtime
WORKDIR /app
COPY --from=sdk /app .
ENTRYPOINT ["dotnet", "GraphQLTemplate.dll"]