Skip to content

Commit

Permalink
完善文档并增加actions以及docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
hslr-s committed May 15, 2024
1 parent 10419f9 commit 2b46386
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 11 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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 }}
27 changes: 21 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -9,30 +13,41 @@ RUN npm install \



FROM golang:1.19 as server_image
FROM golang:1.21-alpine3.18 as server_image

WORKDIR /build

COPY . .

COPY --from=web_image /build/dist /build/assets/frontend

# 执行指令 关闭链接确认
# 中国国内源
# RUN sed -i "[email protected]@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 "[email protected]@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
2 changes: 1 addition & 1 deletion assets/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1|0.1.2(beta)
1|0.1.2-beta
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 20 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ Li Calendar - 锂日历记事本
./li-calendar
```
#### 访问:
浏览器打开:http://[你的域名或ip]:9090
## 💎 Docker 运行
Expand All @@ -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
```

Expand All @@ -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)
Expand Down

0 comments on commit 2b46386

Please sign in to comment.