-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathDockerfile
79 lines (60 loc) · 2.56 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
# Copy source
COPY . ./
# Bring in metadata via --build-arg for build
ARG IMAGE_VERSION=unknown
# Restore packages
RUN dotnet restore
# Add SQLite migration
RUN export PATH="$PATH:/root/.dotnet/tools" && \
dotnet tool install --version 8.0.11 --global dotnet-ef && \
dotnet ef migrations add ${IMAGE_VERSION} --project src/GRA.Data.SQLite/GRA.Data.SQLite.csproj
# Build project and run tests
RUN dotnet test -v m /property:WarningLevel=0
# Publish release project
WORKDIR /app/src/GRA.Web
RUN dotnet publish -v m /property:WarningLevel=0 -c Release --property:PublishDir=/app/publish/
# Copy release-publish.bash script
RUN cp /app/release-publish.bash "/app/publish/"
# Get runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish
WORKDIR /app
# Install curl for health monitoring
RUN apt-get update \
&& apt-get install --no-install-recommends -y curl=7.88.1-10+deb12u8 \
&& rm -rf /var/lib/apt/lists/*
# Bring in metadata via --build-arg to publish
ARG BRANCH=unknown
ARG IMAGE_CREATED=unknown
ARG IMAGE_REVISION=unknown
ARG IMAGE_VERSION=unknown
# Configure image labels
LABEL branch=$branch \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="The Great Reading Adventure open-source tool for managing dynamic library reading programs" \
org.opencontainers.image.documentation="http://manual.greatreadingadventure.com/" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/greatreadingadventure" \
org.opencontainers.image.title="Great Reading Adventure" \
org.opencontainers.image.url="http://greatreadingadventure.com/" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION
# Default image environment variable settings
ENV org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION
# Copy source
COPY --from=build "/app/publish/" .
# Persist shared directory
VOLUME ["/app/shared"]
# Port 80 for http
EXPOSE 80
# Configure health check
HEALTHCHECK CMD curl --fail http://localhost:8080/healthcheck || exit
# Set entrypoint
ENTRYPOINT ["dotnet", "GRA.Web.dll"]