37 lines
1.1 KiB
Docker
37 lines
1.1 KiB
Docker
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
|
|
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
|
WORKDIR /app
|
|
EXPOSE 80
|
|
EXPOSE 443
|
|
|
|
#设置时间为中国上海
|
|
ENV TZ=Asia/Shanghai
|
|
ENV DEBIAN_FRONTEND noninteractive
|
|
|
|
# 设置包源为阿里
|
|
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list \
|
|
&& apt-get clean
|
|
|
|
# 安装 tzdata 软件包
|
|
RUN apt-get update \
|
|
&& apt-get install -y tzdata \
|
|
&& ln -fs /usr/share/zoneinfo/$TZ /etc/localtime \
|
|
&& rm -rf /var/lib/apt/lists/ \
|
|
&& dpkg-reconfigure -f noninteractive tzdata
|
|
|
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
|
WORKDIR /src
|
|
COPY ["Hg.Internal.WebApi/Hg.Internal.WebApi.csproj", "Hg.Internal.WebApi/"]
|
|
RUN dotnet restore "Hg.Internal.WebApi/Hg.Internal.WebApi.csproj"
|
|
COPY . .
|
|
WORKDIR "/src/Hg.Internal.WebApi"
|
|
RUN dotnet build "Hg.Internal.WebApi.csproj" -c Release -o /app/build
|
|
|
|
FROM build AS publish
|
|
RUN dotnet publish "Hg.Internal.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
|
|
FROM base AS final
|
|
WORKDIR /app
|
|
COPY --from=publish /app/publish .
|
|
ENTRYPOINT ["dotnet", "Hg.Internal.WebApi.dll"] |