-
Notifications
You must be signed in to change notification settings - Fork 174
/
Copy pathDockerfile
75 lines (62 loc) · 2.69 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# JR Cms .NET ! Open source .net cross platform cms.
# Version : 4.8.0
# Author : jarrysix([email protected])
# Date : 2023-05-16 08:02
# How to docked a dotnet app:
# https://docs.docker.com/engine/examples/dotnetcore/
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build-env
ENV RELEASE_DIR=/app/out/release
# 在Linux上启动GDI+
#ENV DOTNET_System_Drawing_EnableUnixSupport=true
WORKDIR /app
COPY ./src ./src
COPY ./README.md ./LICENSE ./
WORKDIR src/JR.Cms.App
RUN dotnet restore && dotnet publish -c Release -o ${RELEASE_DIR}
RUN mkdir -p ${RELEASE_DIR}/root && cp -r root/*.md ${RELEASE_DIR}/root && \
mkdir -p ${RELEASE_DIR}/templates && cp -r templates/default ${RELEASE_DIR}/templates && \
cp -r public oem install plugins ${RELEASE_DIR} && \
cd ${RELEASE_DIR} && \
rm -rf *.pdb *.xml appsettings.json appsettings.Development.json && \
rm -rf runtimes/win* runtimes/osx* runtimes/*arm* runtimes/*x86 linux-s390x linux-s390x linux-musl-x64 && \
cp ../../LICENSE ../../README.md . && ls -al
# 设置开发者
LABEL MAINTAINER=jarrysix
# 设置标签
LABEL Vendor="jarrysix"
LABEL License="GPLv2"
LABEL Version=4.0
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
ENV CMS_RUN_ON_DOCKER=yes
WORKDIR /cms
COPY --from=build-env /app/out/release ./
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.sustech.edu.cn/g' /etc/apk/repositories && \
apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "create data init folder.." && \
mkdir -p ${CMS_INIT_DIR:=/var/cms} && mv -f templates plugins oem root ${CMS_INIT_DIR} && \
echo "if [ \`ls /cms/templates | wc -w\` -eq 0 ];then cp -r ${CMS_INIT_DIR}/templates/* /cms/templates;fi;" \
"if [ \`ls /cms/plugins | wc -w\` -eq 0 ];then cp -r ${CMS_INIT_DIR}/plugins/* /cms/plugins;fi;"\
"if [ \`ls /cms/oem | wc -w\` -eq 0 ];then cp -r ${CMS_INIT_DIR}/oem/* /cms/oem;fi;"\
"dotnet JR.Cms.App.dll --urls http://+:80" > ../entrypoint.sh && chmod u+x ../entrypoint.sh
VOLUME ["/cms/config","/cms/templates","/cms/plugins",\
"/cms/uploads","/cms/data","/cms/root","/cms/oem"]
EXPOSE 80
ENTRYPOINT ["sh","../entrypoint.sh"]
# # Quick Start
# # ```
# # docker run --rm -it -p 8080:80 jarry6/cms
# # ```
# # open http://localhost:8080 in your brower.
# # Advance
# ```
# docker run --rm -p 8080:8080 \
# --volume=$(pwd)/config:/cms/config \
# --volume=$(pwd)/oem:/cms/oem \
# --volume=$(pwd)/templates:/cms/templates \
# --volume=$(pwd)/plugins:/cms/plugins \
# --volume=$(pwd)/uploads:/cms/uploads \
# --volume=$(pwd)/data:/cms/data \
# --volume=$(pwd)/root:/cms/root \
# jarry6/cms
# ```