Add Alpine deployment
This commit is contained in:
parent
83826cc930
commit
8523ddd60f
|
|
@ -0,0 +1,55 @@
|
|||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM alpine:latest AS base
|
||||
ENV \
|
||||
# UID of the non-root user 'app'
|
||||
APP_UID=1654 \
|
||||
# Configure web servers to bind to port 8080 when present
|
||||
ASPNETCORE_HTTP_PORTS=8080 \
|
||||
# Enable detection of running in a container
|
||||
DOTNET_RUNNING_IN_CONTAINER=true \
|
||||
# Set the invariant mode since ICU package isn't included (see https://github.com/dotnet/announcements/issues/20)
|
||||
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
|
||||
|
||||
RUN apk add --upgrade --no-cache \
|
||||
ca-certificates-bundle \
|
||||
\
|
||||
# .NET dependencies
|
||||
libgcc \
|
||||
libssl3 \
|
||||
libstdc++ \
|
||||
zlib
|
||||
|
||||
# Create a non-root user and group
|
||||
RUN addgroup \
|
||||
--gid=$APP_UID \
|
||||
app \
|
||||
&& adduser \
|
||||
--uid=$APP_UID \
|
||||
--ingroup=app \
|
||||
--disabled-password \
|
||||
app
|
||||
WORKDIR /app
|
||||
USER app
|
||||
EXPOSE 8080
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
|
||||
# Install clang/zlib1g-dev dependencies for publishing to native
|
||||
RUN apk add clang zlib-dev musl-dev libc6-compat
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["AS1024.GeoFeed.MinimalAPI/AS1024.GeoFeed.MinimalAPI.csproj", "AS1024.GeoFeed.MinimalAPI/"]
|
||||
RUN dotnet restore "./AS1024.GeoFeed.MinimalAPI/./AS1024.GeoFeed.MinimalAPI.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/AS1024.GeoFeed.MinimalAPI"
|
||||
RUN dotnet build "./AS1024.GeoFeed.MinimalAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./AS1024.GeoFeed.MinimalAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=true /p:DebugType=None /p:DebugSymbols=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["./AS1024.GeoFeed.MinimalAPI"]
|
||||
Loading…
Reference in New Issue