This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 368
/
Dockerfile
171 lines (138 loc) · 5.19 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
#Build main branch source apps
FROM microsoft/dotnet:2.1-sdk AS build-src
COPY ConferencePlanner.sln ./
COPY src src
RUN dotnet restore -nowarn:msb3202,nu1503 --packages /nuget
WORKDIR /src/BackEnd
RUN dotnet build -c Release -o /app/backend
WORKDIR /src/FrontEnd
RUN dotnet build -c Release -o app/frontend
#Build save-points
#1-Create-API-and-EF-Model
FROM microsoft/dotnet:2.1-sdk AS build-save-1
COPY --from=build-src /nuget /nuget
ARG DIR=save-points/1-Create-API-and-EF-Model/ConferencePlanner/
COPY $DIR/ConferencePlanner.sln ./
COPY $DIR/BackEnd/BackEnd.csproj BackEnd/
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
COPY ${DIR} ./
RUN dotnet build -c Release -o /app
#2a-Refactor-to-ConferenceDTO
FROM microsoft/dotnet:2.1-sdk AS build-save-2a
COPY --from=build-src /nuget /nuget
ARG DIR=save-points/2a-Refactor-to-ConferenceDTO/ConferencePlanner/
COPY $DIR/ConferencePlanner.sln ./
COPY $DIR/BackEnd/BackEnd.csproj BackEnd/
COPY $DIR/ConferenceDTO/ConferenceDTO.csproj ConferenceDTO/
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
COPY ${DIR} ./
RUN dotnet build -c Release -o /app
#2b-BackEnd-completed
FROM microsoft/dotnet:2.1-sdk AS build-save-2b
COPY --from=build-src /nuget /nuget
ARG DIR=save-points/2b-BackEnd-completed/ConferencePlanner/
COPY $DIR/ConferencePlanner.sln ./
COPY $DIR/BackEnd/BackEnd.csproj BackEnd/
COPY $DIR/ConferenceDTO/ConferenceDTO.csproj ConferenceDTO/
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
COPY ${DIR} ./
RUN dotnet build -c Release -o /app
#3-Front-End-started
FROM microsoft/dotnet:2.1-sdk AS build-save-3
COPY --from=build-src /nuget /nuget
ARG DIR=save-points/3-Front-End-started/ConferencePlanner/
COPY $DIR/ConferencePlanner.sln ./
COPY ${DIR} ./
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
WORKDIR /BackEnd
RUN dotnet build -c Release -o /app/backend
WORKDIR /FrontEnd
RUN dotnet build -c Release -o app/frontend
#4-Authentication-and-Tag-Helpers
FROM microsoft/dotnet:2.1-sdk AS build-save-4
COPY --from=build-src /nuget /nuget
ARG DIR=save-points/4-Authentication-and-Tag-Helpers/ConferencePlanner/
COPY $DIR/ConferencePlanner.sln ./
COPY ${DIR} ./
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
WORKDIR /BackEnd
RUN dotnet build -c Release -o /app/backend
WORKDIR /FrontEnd
RUN dotnet build -c Release -o app/frontend
#5-User-association-and-personal-agenda
FROM microsoft/dotnet:2.1-sdk AS build-save-5
COPY --from=build-src /nuget /nuget
ARG DIR=save-points/5-User-association-and-personal-agenda/ConferencePlanner/
COPY $DIR/ConferencePlanner.sln ./
COPY ${DIR} ./
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
WORKDIR /BackEnd
RUN dotnet build -c Release -o /app/backend
WORKDIR /FrontEnd
RUN dotnet build -c Release -o app/frontend
#6-Deployment-docker
FROM microsoft/dotnet:2.1-sdk AS build-save-6
COPY --from=build-src /nuget /nuget
ARG DIR=save-points/6-Deployment-docker/ConferencePlanner/
COPY $DIR/ConferencePlanner.sln ./
COPY ${DIR} ./
WORKDIR /BackEnd
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
RUN dotnet build -c Release -o /app/backend
WORKDIR /FrontEnd
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
RUN dotnet build -c Release -o app/frontend
#8a-Adding-FrontEnd-Spa-final
FROM microsoft/dotnet:2.1-sdk AS build-save-8a-final
ENV NODE_VERSION 8.11.2
ENV NODE_DOWNLOAD_URL https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz
ENV NODE_DOWNLOAD_SHA 67dc4c06a58d4b23c5378325ad7e0a2ec482b48cea802252b99ebe8538a3ab79
RUN curl -SL "$NODE_DOWNLOAD_URL" --output nodejs.tar.gz \
&& echo "$NODE_DOWNLOAD_SHA nodejs.tar.gz" | sha256sum -c - \
&& tar -xzf "nodejs.tar.gz" -C /usr/local --strip-components=1 \
&& rm nodejs.tar.gz \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
COPY --from=build-src /nuget /nuget
ARG DIR=save-points/8a-Adding-FrontEnd-Spa-final/ConferencePlanner
COPY $DIR/ConferencePlanner.sln ./
COPY ${DIR}/src ./src
WORKDIR /src/BackEnd
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
RUN dotnet build -c Release -o /app/backend
WORKDIR /src/FrontEndSpa
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
WORKDIR /src/FrontEndSpa/ClientApp
RUN npm install
RUN npm run build
WORKDIR /src/FrontEndSpa
RUN dotnet build -c Release -o app/frontend
#8a-Adding-FrontEnd-Spa-started
FROM microsoft/dotnet:2.1-sdk AS build-save-8a-start
COPY --from=build-src /nuget /nuget
ARG DIR=save-points/8a-Adding-FrontEnd-Spa-started/ConferencePlanner
COPY $DIR/ConferencePlanner.sln ./
COPY ${DIR}/src ./src
WORKDIR /src/BackEnd
RUN dotnet restore -nowarn:msb3202,nu1503 -s /nuget
RUN dotnet build -c Release -o /app/backend
#produce final images
FROM build-src AS publish-backend
RUN dotnet publish -c Release -o /app
FROM build-src AS publish-frontend
RUN dotnet publish -c Release -o /app
# Produce this image using
# docker build --target final-backend -t aspnet-app-workshop-backend:latest .
FROM base AS final-backend
WORKDIR /app
COPY --from=publish-backend /app .
ENTRYPOINT ["dotnet", "BackEnd.dll"]
# Produce this image using
# docker build --target final-backend -t aspnet-app-workshop-frontend:latest .
FROM base AS final-frontend
WORKDIR /app
COPY --from=publish-frontend /app .
ENTRYPOINT ["dotnet", "FrontEnd.dll"]