From e79570a54d2e6366e860fea76b96ef1ae7417577 Mon Sep 17 00:00:00 2001 From: lzwang Date: Fri, 28 Oct 2022 23:59:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(WebServer):=20=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E5=9F=BA=E4=BA=8E=20Caddy=20=E7=9A=84=20web=20=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 13 +++++++++++-- web-server/Caddyfile | 18 ++++++++++++++++++ web-server/Dockerfile | 22 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 web-server/Caddyfile create mode 100644 web-server/Dockerfile diff --git a/.drone.yml b/.drone.yml index 5113337..d72339d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -29,6 +29,17 @@ steps: - docker ps - docker images + - name: Build Web Server + environment: + USERNAME: + from_secret: docker_hub_username + TOKEN: + from_secret: docker_hub_token + commands: + - docker build . -t $USERNAME/web-server:latest -f ./web-server/Dockerfile --no-cache + - docker login -u $USERNAME -p $TOKEN + - docker push $USERNAME/web-server:latest + - name: Build Python 3.10 environment: USERNAME: @@ -36,7 +47,6 @@ steps: TOKEN: from_secret: docker_hub_token commands: - - echo $USERNAME - docker build . -t $USERNAME/python3.10:nightly -f ./python3.10/Dockerfile --no-cache - docker login -u $USERNAME -p $TOKEN - docker push $USERNAME/python3.10:nightly @@ -48,7 +58,6 @@ steps: TOKEN: from_secret: docker_hub_token commands: - - echo $USERNAME - docker build . -t $USERNAME/cloud-center:linux-nightly -f ./cloud-center/Dockerfile --no-cache - docker login -u $USERNAME -p $TOKEN - docker push $USERNAME/cloud-center:linux-nightly diff --git a/web-server/Caddyfile b/web-server/Caddyfile new file mode 100644 index 0000000..726cc3d --- /dev/null +++ b/web-server/Caddyfile @@ -0,0 +1,18 @@ +# References: +# https://caddyserver.com/docs/caddyfile-tutorial +# https://caddyserver.com/docs/caddyfile + +:8000 { + root * /web/data # 网站根目录 + file_server browse # 加上 browse 参数后就可以在没有index.html文件时,当作文件管理器 +} + +:8001 { + root * /web/mkdocs # 网站根目录 + file_server # 加上 browse 参数后就可以在没有index.html文件时,当作文件管理器 +} + +:8002 { + root * /web/hexo # 网站根目录 + file_server # 加上 browse 参数后就可以在没有index.html文件时,当作文件管理器 +} diff --git a/web-server/Dockerfile b/web-server/Dockerfile new file mode 100644 index 0000000..d06ab6c --- /dev/null +++ b/web-server/Dockerfile @@ -0,0 +1,22 @@ +FROM caddy:latest + +# image info +LABEL Project="CloudCenterWebServer" +LABEL Author="lzwang" +LABEL Email="zhuangwang82@gmail.com" +LABEL Version=1.0 + +COPY Caddyfile /etc/caddy/Caddyfile + +RUN mkdir "/web" + +VOLUME /web + +# mkdocs site +EXPOSE 8001 + +# hexo site +EXPOSE 8002 + +# file server +EXPOSE 8003