forked from amoerie/teamcity-theatre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
89 lines (59 loc) · 2.45 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
80
81
82
83
84
85
86
87
88
89
#####################
# #
# MULTI STAGE BUILD #
# #
#####################
#########################
#######################
# STAGE : NPM INSTALL #
#######################
FROM node:10.14 AS npminstall
WORKDIR /TeamCityTheatre
# copy bare minimum files needed to restore NPM packages
COPY ./src/TeamCityTheatre.Web/package.json ./TeamCityTheatre.Web/
COPY ./src/TeamCityTheatre.Web/package-lock.json ./TeamCityTheatre.Web/
WORKDIR /TeamCityTheatre/TeamCityTheatre.Web
# install node packages
RUN npm ci
#######################
# STAGE : NPM BUILD #
#######################
FROM npminstall as npmbuild
WORKDIR /TeamCityTheatre/TeamCityTheatre.Web
# and everything else needed to build the frontend
COPY ./src/TeamCityTheatre.Web/tsconfig.json ./
COPY ./src/TeamCityTheatre.Web/webpack.config.js ./
COPY ./src/TeamCityTheatre.Web/Views/ ./Views/
# .. and build the frontend
RUN npm run build:release
############################
# STAGE : DOT NET RESTORE #
############################
FROM microsoft/dotnet:2.2-sdk AS dotnetrestore
WORKDIR /TeamCityTheatre
# copy bare minimum files needed to restore dot net packages
COPY src/TeamCityTheatre.sln ./
COPY src/TeamCityTheatre.Web/TeamCityTheatre.Web.csproj ./TeamCityTheatre.Web/
COPY src/TeamCityTheatre.Core/TeamCityTheatre.Core.csproj ./TeamCityTheatre.Core/
RUN dotnet restore
############################
# STAGE : DOT NET PUBLISH #
############################
FROM dotnetrestore AS dotnetpublish
WORKDIR /TeamCityTheatre
# copy prebuilt frontend files
COPY --from=npmbuild ./TeamCityTheatre/TeamCityTheatre.Web/wwwroot/ ./TeamCityTheatre.Web/wwwroot/
# copy necessary project files to build .NET
COPY src/TeamCityTheatre.Core/. ./TeamCityTheatre.Core/
COPY src/TeamCityTheatre.Web/. ./TeamCityTheatre.Web/
# publish
RUN dotnet publish "./TeamCityTheatre.Web/TeamCityTheatre.Web.csproj" --verbosity normal --configuration Release --output "/Output"
############################
# STAGE : RUN APPLICATION #
############################
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS runtime
WORKDIR /TeamCityTheatre
RUN mkdir Data
RUN mkdir Logs
COPY --from=dotnetpublish /Output ./
ENTRYPOINT ["dotnet", "TeamCityTheatre.Web.dll"]