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
ARG UBUNTU_VERSION=18.04
FROM ubuntu:${UBUNTU_VERSION}
ARG DOTNET_VERSION=5.0

RUN cd /tmp \
# 镜像源
&& sed -i 's@/deb.debian.org/@/mirrors.aliyun.com/@g' /etc/apt/sources.list \
&& apt-get update \
&& apt-get install apt-utils libgdiplus libc6-dev -y \
&& apt install -y wget \
# 下载安装AspnetCore运行时
&& wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb \
&& apt-get update \
&& apt-get install -y apt-transport-https \
&& apt-get update \
&& apt-get install -y aspnetcore-runtime-${DOTNET_VERSION} \
# 设置时区
&& set -x \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y tzdata \
&& ln -sf /usr/share/zoneinfo/Asia/ShangHai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
# 设置字体
&& wget -O /usr/share/fonts/mryh.ttf http://dev.dianmi-north.cn:32110/fonts/微软雅黑.ttf \
&& apt-get install fontconfig -y \
&& fc-cache -vf \
&& fc-list \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
# openssl
&& sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/' /etc/ssl/openssl.cnf \
&& sed -i 's/CipherString = DEFAULT@SECLEVEL=2/CipherString = DEFAULT@SECLEVEL=1/' /etc/ssl/openssl.cnf

ENV \
# Configure web servers to bind to port 80 when present
ASPNETCORE_URLS=http://+:80 \
# Enable detection of running in a container
DOTNET_RUNNING_IN_CONTAINER=true

运行

1
docker buildx build --platform=linux/amd64 . -t dm-aspnet-runtime:5.0 --network=host