diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..8bb788d --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +VUE_APP_PUBLIC_PATH = '/' \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..b9b2de5 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +VUE_APP_PUBLIC_PATH = './' \ No newline at end of file diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..cf19b01 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,28 @@ +name: Build Docker Image + +on: + push: + branches: + - main # 当推送到 main 分支时触发 + pull_request: + branches: + - main # 当有 pull request 到 main 分支时触发 + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: ../../docker/Dockerfile + push: false # 不推送镜像 + tags: weektodo-product:latest \ No newline at end of file diff --git a/.gitignore b/.gitignore index ca95d59..d13a1c1 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,6 @@ pnpm-debug.log* #Electron-builder output /dist_electron -.env \ No newline at end of file +# docker +compose.yml +Dockerfile \ No newline at end of file diff --git a/README.md b/README.md index eed4535..2cb820c 100644 --- a/README.md +++ b/README.md @@ -106,9 +106,16 @@ yarn run electron:serve // to run native version ``` ### Docker - - To run the development web version use `docker-compose up` - +get into the `docker` folder, if you want run the development web version copy the file with prefix "devlop." and delete the prefix then run the command: `docker-compose up`, production version also. +use command `docker build -t weektodo:latest -f docker/Dockerfile .` to build the image. +### Reverse Proxy +use Caddy to reverse proxy the app, you can use edit Caddyfile. for example: +``` +:80/weektodo/* { + uri strip_prefix /weektodo + reverse_proxy http://weektodo:80 +} +``` ## Contributing You can support this project in several ways: diff --git a/Dockerfile b/docker/develop.Dockerfile similarity index 100% rename from Dockerfile rename to docker/develop.Dockerfile diff --git a/docker-compose.yml b/docker/develop.compose.yml similarity index 100% rename from docker-compose.yml rename to docker/develop.compose.yml diff --git a/docker/product.Dockerfile b/docker/product.Dockerfile new file mode 100644 index 0000000..4ade7e9 --- /dev/null +++ b/docker/product.Dockerfile @@ -0,0 +1,13 @@ +# frist prase +FROM node:16-alpine AS builder +WORKDIR /app +COPY package.json yarn.lock /app/ +RUN yarn install --frozen-lockfile && yarn cache clean +# because dcoker is layer build and every layer docker when builded will has cache,so we can use cache to speed up the build +COPY . /app +RUN ["yarn", "run", "build"] +# second prase +FROM caddy:latest +WORKDIR /app +COPY --from=builder /app/dist /usr/share/caddy/ +EXPOSE 80 diff --git a/docker/product.compose.yml b/docker/product.compose.yml new file mode 100644 index 0000000..0306793 --- /dev/null +++ b/docker/product.compose.yml @@ -0,0 +1,15 @@ +services: + weektodo: + build: + context: .. + dockerfile: docker/Dockerfile + container_name: weektodo + restart: unless-stopped + ports: + - "8080:80" + healthcheck: + test: ["CMD", "wget", "--spider", "http://127.0.0.1:80"] + interval: 1m30s + timeout: 10s + retries: 3 + start_period: 40s \ No newline at end of file diff --git a/src/components/layout/sideBar.vue b/src/components/layout/sideBar.vue index 089f860..bf8e902 100644 --- a/src/components/layout/sideBar.vue +++ b/src/components/layout/sideBar.vue @@ -2,7 +2,7 @@