-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
76 lines (49 loc) · 1.8 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
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS dotnet-base
ENV DOCKERIZE_VERSION="v0.6.1" \
# Tini for Docker
TINI_VERSION="v0.19.0"
# === Builder image ===
FROM dotnet-base AS builder
#System dependencies
RUN apt update && apt upgrade -y && apt install --no-install-recommends -y \
curl \
wget \
ffmpeg
# Dockerize
RUN wget "https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz" \
&& tar -C /usr/local/bin -xzf "dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz" \
&& rm "dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz" \
&& dockerize --version
# Tini
RUN wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" \
&& chmod +x /usr/local/bin/tini \
&& tini --version
# === Base image ===
FROM dotnet-base AS base
COPY --from=builder /usr/local/bin/dockerize /usr/local/bin/dockerize
COPY --from=builder /usr/local/bin/tini /usr/local/bin/tini
COPY --from=builder /usr/bin/ffmpeg /usr/bin/ffmpeg
COPY --from=builder /usr/lib/*-linux-gnu/* /usr/lib/
COPY --from=builder /lib/*-linux-gnu/* /lib/
COPY ./scripts/entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
WORKDIR /SkyTube
# === Development image ===
FROM base AS dev
COPY ./SkyTube.csproj .
RUN dotnet restore
ENTRYPOINT [ "tini", "--", "/docker-entrypoint.sh" ]
CMD [ "dotnet", "watch", "run" ]
# === Build production image ===
FROM dev AS build
COPY . ./
RUN dotnet publish -c Release -o /SkyTube/out
# === Production image ===
FROM base AS prod
# Setup Permissions
RUN groupadd -r dotnet && useradd -m -d /dotnet -r -g dotnet dotnet \
&& chown dotnet:dotnet -R /SkyTube
COPY --from=build /SkyTube/out /SkyTube
USER dotnet
ENTRYPOINT [ "tini", "--", "/docker-entrypoint.sh" ]
CMD [ "dotnet", "SkyTube.dll" ]