-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (59 loc) · 2.14 KB
/
Copy pathDockerfile
File metadata and controls
75 lines (59 loc) · 2.14 KB
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
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS server-build
WORKDIR /Server
# Install dependencies
COPY *.sln .
COPY paket.dependencies .
COPY paket.lock .
COPY .config/ .
COPY .paket/ .
COPY src/Client/*.fsproj src/Client/paket.references ./src/Client/
COPY src/Server/*.fsproj src/Server/paket.references ./src/Server/
COPY src/Shared/*.fsproj src/Shared/paket.references ./src/Shared/
COPY src/Server.Test/*.fsproj src/Server.Test/paket.references ./src/Server.Test/
RUN dotnet tool restore
RUN dotnet restore
RUN dotnet paket restore
# Copy everything
COPY . .
# Build and publish a release
RUN dotnet fable --cwd src/Client -o output
RUN dotnet publish src/Server -c Release -o publish
## Client Build Area
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 AS client-base
RUN apt update && apt install -y make
WORKDIR /Client
# install dependencies into temp directory
# this will cache them and speed up future builds
FROM client-base AS client-install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile
# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production
# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM client-base AS client-build
COPY --from=client-install /temp/dev/node_modules node_modules
COPY . .
COPY --from=server-build /Server/src/Client/output ./src/Client/output
ENV NODE_ENV=production
RUN make build_client_style
RUN make build_client
## App Area
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:9.0
WORKDIR /App
RUN apt update && apt install -y curl
COPY --from=server-build /Server/publish .
COPY --from=server-build /Server/src/Server/Templates Templates
COPY --from=client-build /Client/src/Client/dist wwwroot
ARG PORT=3000
EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${PORT} || exit 1
ENTRYPOINT ["dotnet", "Server.dll"]