-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (50 loc) · 1.88 KB
/
Dockerfile
File metadata and controls
67 lines (50 loc) · 1.88 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
# syntax=docker/dockerfile:1
ARG DOTNETVERSION=8.0
ARG BASEIMAGE=alpine
# Use --platform=$BUILDPLATFORM in order to correctly pull the base image for the build platform.
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:$DOTNETVERSION-$BASEIMAGE AS build
COPY . /source
WORKDIR /source
ARG TARGETARCH
ARG BUILDPLATFORM
ARG TARGETPLATFORM
# Build the application.
RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM ($TARGETARCH)"
RUN dotnet restore -a $TARGETARCH
RUN dotnet publish -a $TARGETARCH --no-restore --property:PublishDir=/app
################################################################################
# If you need to enable globalization and time zones:
# https://github.com/dotnet/dotnet-docker/blob/main/samples/enable-globalization.md
FROM mcr.microsoft.com/dotnet/aspnet:$DOTNETVERSION-$BASEIMAGE AS final
WORKDIR /app
# ATTENTION: Change this to match the name of your application.
ARG BASENAME="AzPC"
COPY --from=build /app ./
COPY ${BASENAME}.Blazor/${BASENAME}.Blazor/config ./config
COPY ${BASENAME}.Blazor/${BASENAME}.Blazor/data ./data
# Create a non-privileged user that the app will run under.
# See https://docs.docker.com/go/dockerfile-user-best-practices/
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
# --home "/nonexistent" \
--shell "/sbin/nologin" \
# --no-create-home \
--uid "$UID" \
appuser
RUN chown -R appuser:appuser /app
USER appuser
# Enable Swagger UI
ENV ENABLE_SWAGGER_UI=true
# Initialize the database
ENV INIT_DB=true
# API base URL setting for Blazor Server mode
ENV API__BaseUrl=http://localhost:8080
# Set database type to InMemory for demo purposes
ENV Databases__Application__Type=InMemory
ENV Databases__Identity__Type=InMemory
# Default port for dotnet application
EXPOSE 8080
# ATTENTION: Change this to match the name of your application.
ENTRYPOINT ["dotnet", "AzPC.Blazor.dll"]