-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathdockerfile
51 lines (37 loc) · 1.35 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
# ChatGPT made the first version of this, hopefully it works!
# Start with the official .NET Core 9.0 SDK image
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
# Install Node.js (replace with the latest LTS version)
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs
# Set the working directory to the app's source code directory
WORKDIR /app
# We need python for some reason
RUN apt-get update && apt-get install -y python3
RUN apt-get install libatomic1
# Copy the app's source code to the container image
COPY . .
# Restore workloads
RUN dotnet workload restore
# Restore the app's dependencies
RUN dotnet restore
# Remove .js files that have corresponding .ts files
RUN find . -name "*.ts" | while read tsfile; do \
jsfile="${tsfile%.ts}.js"; \
if [ -f "$jsfile" ]; then \
echo "Deleting $jsfile because $tsfile exists"; \
rm "$jsfile"; \
fi; \
done
# Build the app
RUN dotnet publish -c Release -o out
# Start with a smaller runtime image for the final image
FROM mcr.microsoft.com/dotnet/aspnet:9.0
# Set the working directory to the app's output directory
WORKDIR /app
# Copy the app's output files from the build-env image
COPY --from=build-env /app/out .
# Expose the app's port (if needed)
EXPOSE 80
# Start the app
ENTRYPOINT ["dotnet", "Valour.Server.dll"]