-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
54 lines (42 loc) · 1.44 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
# Docker multi-stage build
FROM mcr.microsoft.com/dotnet/sdk:6.0.410-focal-amd64 AS builder
WORKDIR /app
# Copy csproj and restore (fetch dependencies) as distinct layers.
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build.
COPY . ./
RUN dotnet publish -c Release -o build
# Build runtime image. Using 6.0.16-focal-amd64
FROM mcr.microsoft.com/dotnet/aspnet:6.0.18-focal-amd64
ENV ASPNETCORE_URLS=http://+:5000
ENV COMBINE_IS_IN_CONTAINER=1
ENV ASPNETCORE_ENVIRONMENT=Production
ENV DOTNET_PRINT_TELEMETRY_MESSAGE=false
# Set the home directory to the app user's home.
ENV HOME=/home/app
ENV APP_HOME=${HOME}/backend
ENV APP_FILES=${HOME}/.CombineFiles
# Install system dependencies.
RUN apt-get update \
&& apt-get install -y \
# icu.net dependency: libdl.so
libc6-dev ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Create the home directory for the new app user.
RUN mkdir -p $HOME
# Create an app user so the program doesn't run as root.
RUN groupadd -r app && \
useradd -r -g app -d $HOME -s /sbin/nologin -c "Docker image user" app
## Set up application install directory.
RUN mkdir $APP_HOME && \
mkdir $APP_FILES && \
# Give access to the entire home folder so the backend can create files and folders there.
chown -R app:app $HOME
WORKDIR $APP_HOME
# Copy in the build application.
COPY --chown=app:app launch.sh ./
COPY --chown=app:app --from=builder /app/build ./
# Change to the app user.
USER app
ENTRYPOINT ["./launch.sh"]