From 2b46386fd76108e5a07ed0243d81b1cd586c5545 Mon Sep 17 00:00:00 2001 From: Sun <95302870@qq.com> Date: Wed, 15 May 2024 16:48:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=96=87=E6=A1=A3=E5=B9=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0actions=E4=BB=A5=E5=8F=8Adocker-compose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 44 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 27 +++++++++++++++++------ assets/version | 2 +- docker-compose.yml | 14 ++++++++++++ readme.md | 24 +++++++++++++++++---- 5 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 docker-compose.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9be042e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,44 @@ +name: docker-push + +on: + workflow_dispatch: + # 暂时取消自动编译,优化后重新开启 + # push: + # tags: + # - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Clone Frontend Project + run: git clone https://github.com/li-calendar-notepad/li-calendar-vue.git web + + - name: Read version from file + id: read_version + # run: echo "APP_VERSION=$(cut -d '|' -f 2 ./assets/version)" >> $GITHUB_ENV // 暂时不支持括号 + run: echo "APP_VERSION=latest" >> $GITHUB_ENV + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . # 这里在项目根目录找Dockerfile构建 + # platforms: linux/amd64 + platforms: linux/amd64,linux/arm,linux/arm64 + push: true + tags: ${{ vars.DOCKER_IMAGE_NAME }}:${{ env.APP_VERSION }},${{ vars.DOCKER_IMAGE_NAME }} diff --git a/Dockerfile b/Dockerfile index 16cf783..56cbee4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,8 @@ -FROM node:16.17.1-alpine3.15 as web_image +FROM node AS web_image + +# 华为源 +# RUN npm config set registry https://repo.huaweicloud.com/repository/npm/ + WORKDIR /build @@ -9,7 +13,7 @@ RUN npm install \ -FROM golang:1.19 as server_image +FROM golang:1.21-alpine3.18 as server_image WORKDIR /build @@ -17,22 +21,33 @@ COPY . . COPY --from=web_image /build/dist /build/assets/frontend -# 执行指令 关闭链接确认 +# 中国国内源 +# RUN sed -i "s@dl-cdn.alpinelinux.org@mirrors.aliyun.com@g" /etc/apk/repositories \ +# && go env -w GOPROXY=https://goproxy.cn,direct + +RUN apk add --no-cache bash curl gcc git musl-dev + RUN go env -w GO111MODULE=on \ - && go env -w GOPROXY=https://goproxy.cn,direct \ && export PATH=$PATH:/go/bin \ && go install -a -v github.com/go-bindata/go-bindata/...@latest \ && go install -a -v github.com/elazarl/go-bindata-assetfs/...@latest \ && go-bindata-assetfs -o=assets/bindata.go -pkg=assets assets/... \ + && go mod tidy \ && go build -o li-calendar --ldflags="-X main.RunMode=release -X main.IsDocker=docker" main.go -FROM ubuntu +FROM alpine + +# 中国国内源 +# RUN sed -i "s@dl-cdn.alpinelinux.org@mirrors.aliyun.com@g" /etc/apk/repositories WORKDIR /app COPY --from=server_image /build/li-calendar /app/li-calendar -RUN apt-get update && apt-get install -y ca-certificates &&./li-calendar config +EXPOSE 9090 + +RUN apk add --no-cache bash ca-certificates su-exec tzdata \ + && chmod +x ./li-calendar CMD ./li-calendar \ No newline at end of file diff --git a/assets/version b/assets/version index 29b80c4..0193a25 100644 --- a/assets/version +++ b/assets/version @@ -1 +1 @@ -1|0.1.2(beta) \ No newline at end of file +1|0.1.2-beta \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e1d9071 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3.2" + +services: + sun-panel: + image: 'licalendar:latest' + container_name: licalendar + volumes: + - ./conf:/app/conf + - ./uploads:/app/uploads + - ./database:/app/database + # - ./runtime:/app/runtime + ports: + - 9090:9090 + restart: always \ No newline at end of file diff --git a/readme.md b/readme.md index 767613d..dd4cbac 100644 --- a/readme.md +++ b/readme.md @@ -117,8 +117,7 @@ Li Calendar - 锂日历记事本 ./li-calendar ``` -#### 访问: -浏览器打开:http://[你的域名或ip]:9090 + ## 💎 Docker 运行 @@ -133,8 +132,7 @@ docker build -t licalendar:latest . docker run --name li-calendar -p 9090:9090 \ -v ~/licalendar/conf:/app/conf \ -v ~/licalendar/uploads:/app/uploads \ --v ~/licalendar/runtime:/app/runtime \ --v ~/licalendar/lang:/app/lang \ +-v ~/licalendar/database:/app/database \ licalendar:latest ``` @@ -147,6 +145,24 @@ licalendar:latest -v ~/licalendar/database:/app/database # sqlite数据库目录 ``` + + +## 🧂 访问、默认账号密码: + +### 浏览器打开 + +``` +http://[你的域名或ip]:9090 +``` + +### 默认账号密码 + +``` +账号:admin2024 // 年份是根据当时部署的年份创建的 +密码:123456 +``` + + ## ⛺ (假日、风格)导入文件 特殊日期和风格文件下载(特殊日期包含中国法定节假日2020-2023年文件,欢迎提供其他地区或者国家假期数据) [去查看和下载,持续更新](https://cloud.enianteam.com/#/share/ugwzotae)