2025-03-26 08:00:00
这两天因为一些第三方项目需求,要在一台阿里云的国内ECS服务器上安装Dokploy并且部署NextJS应用,在安装Dokploy的过程中遇到很多坑,并且没有找到什么很好的教程能有效解决我的问题,折腾了好久终于装好,遂把我遇到的坑以及完整的安装过程记录下来,以供有需要的朋友参考。 > 我的配置环境:阿里云ECS服务器,配置:2C2G,区域:华东1(杭州),系统:Ubuntu24.04 # 目录 - Dokploy简介 - 什么是Dokploy? - 安装Dokploy - 正常安装 - 国内服务器安装 - 修改安装脚本 - 配置Docker镜像源 - 运行安装脚本 - 配置防火墙 - 访问后台 - 安装常见问题 - 配置后台 - 绑定域名 - 配置应用 - 配置GitHub - 新建应用 - 直接Deploy - 利用GitHub Action来Deploy - 新建GitHub Token - 配置Registry - 配置Provider - 配置项目Workflow - 配置环境变量 - 配置应用域名 - 常见问题 - 参考代码 ---- # 什么是Dokploy? [Dokploy](https://dokploy.com) 是一个开源的应用部署解决方案,提供一站式项目、数据的管理以及系统监控。  简单来说就是可以像Vercel一样地在自己的服务器上部署网站,并且还能部署数据库、Docker Compose等开源服务,例如Supabase,并且可以很方便地监控系统及应用日志  # 安装Dokploy ## 正常安装 如果你的服务器能直接访问到Dockerhub,直接拉Docker镜像,比如服务器是阿里云/腾讯云等国内云服务器厂商的境外区域服务器,或者是国外的云服务器厂商,比如Hostinger,那你就可以直接使用官方的安装脚本 ``` curl -sSL https://dokploy.com/install.sh | sh ``` > 如果你还没买服务器,或者对服务器区域没有要求,那么我更建议你直接购买国外的云服务器,安装过程、后续维护都更方便,免去很多潜在的问题。 > > 我自己就买了一台[Hostinger](https://www.hostinger.com/cart?product=vps%3Avps_kvm_2&period=12&referral_type=cart_link&REFERRALCODE=SMCIAMCORWTX&referral_id=0195d1ac-4d34-709b-a1cf-da5744f200e0)的VPS服务器,2C8G配置,100GB的存储空间,8T的带宽,日常卖6.99刀一个月,经常会有搞活动两年只需800多rmb,对比之下还是很实惠的。这个配置也足够个人项目使用了,部署多个应用也不是问题。 ## 国内服务器安装 如果你因为个人需求,必须使用国内的服务器部署,那么就可能会经历跟我一样的问题,你可以按以下步骤来。 1. 先把官方install脚本下载下来 ``` wget https://dokploy.com/install.sh ``` 然后修改以下部分 ``` docker pull postgres:16 docker pull redis:7 docker pull traefik:v3.1.2 docker pull dokploy/dokploy:latest # Installation docker service create \ --name dokploy \ --replicas 1 \ --network dokploy-network \ --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \ --mount type=bind,source=/etc/dokploy,target=/etc/dokploy \ --mount type=volume,source=dokploy-docker-config,target=/root/.docker \ --publish published=3000,target=3000,mode=host \ --update-parallelism 1 \ --update-order stop-first \ --constraint 'node.role == manager' \ -e ADVERTISE_ADDR=$advertise_addr \ dokploy/dokploy:latest ``` 修改为 ``` docker pull postgres:16 docker pull redis:7 docker pull traefik:v3.1.2 # 修改以下部分 docker pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/dokploy/dokploy:latest docker tag swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/dokploy/dokploy:latest docker.io/dokploy/dokploy:latest # Installation docker service create \ --name dokploy \ --replicas 1 \ --network dokploy-network \ --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \ --mount type=bind,source=/etc/dokploy,target=/etc/dokploy \ --mount type=volume,source=dokploy-docker-config,target=/root/.docker \ --publish published=3000,target=3000,mode=host \ --update-parallelism 1 \ --update-order stop-first \ --constraint 'node.role == manager' \ -e ADVERTISE_ADDR=$advertise_addr \ # 修改以下部分 swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/dokploy/dokploy ``` 2. 修改docker镜像源为阿里云国内源 运行以下命令 ``` # 1. 创建空的daemon.json echo >/etc/docker/daemon.json # 2. 写入docker镜像源 cat>/etc/docker/daemon.json Secrets and variables -> Actions 点击 "New repository secret" 添加以下信息: Name: `{环境变量名}` Value: `{环境变量值}` 这样设置后,GitHub Actions 在构建 Docker 镜像时就会使用这个环境变量了。 ## 配置应用域名 在Domains页配置想要的域名,然后映射到应用对应的端口,(例如通常NextJS应用是`3000`, Astro应用是`4321`),注意把HTTPS打开,也可以点击右边的骰子按钮来生成一个`xxx.traefik.me`域名,但注意`traefik.me`域名只能用HTTP访问,不要把HTTPS打开。  然后即可使用域名访问。 # 常见问题 1. 用`ip:端口`访问应用/dokploy后台是正常,但用域名访问失败,页面返回`502 currently unable to handle this request.`,请检查你的域名DNS解析是否正常,服务器防火墙是否打开80/443端口,Linux服务器内是否开启了防火墙 # 参考代码 `workflow.yml`参考 ``` # https://docs.github.com/zh/actions/use-cases-and-examples/publishing-packages/publishing-docker-images name: Create and publish a Docker image # Configures this workflow to run every time a change is pushed to the branch called `release`. on: push: branches: ['main'] # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} # There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. jobs: build-and-push-image: runs-on: ubuntu-latest # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. permissions: contents: read packages: write attestations: write id-token: write # steps: - name: Checkout repository uses: actions/checkout@v4 # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. - name: Log in to the Container registry uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. - name: Build and push Docker image id: push uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} # environment variables build-args: | NEXT_PUBLIC_ARG1=${{ secrets.NEXT_PUBLIC_ARG1 }} SEC_ARG2=${{ secrets.SEC_ARG2 }} # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)." # - name: Generate artifact attestation # uses: actions/attest-build-provenance@v1 # with: # subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} # subject-digest: ${{ steps.push.outputs.digest }} # push-to-registry: true # Trigger redeploy on dokploy => project webhooks settings - name: Trigger dokploy redeploy run: | curl -X GET {dokploy_webhook} ``` `Dockerfile`参考 ``` # https://github.com/nextauthjs/next-auth-example/blob/main/Dockerfile # syntax=docker/dockerfile:1 FROM node:20-alpine AS base # Install dependencies only when needed FROM base AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat WORKDIR /app # Install dependencies COPY package.json pnpm-lock.yaml* ./ RUN npm install -g pnpm && pnpm i --frozen-lockfile # Rebuild the source code only when needed FROM base AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . # 声明构建参数 ARG ARG1 # 设置环境变量 ENV ARG1=$ARG1 # Next.js collects completely anonymous telemetry data about general usage. # Learn more here: https://nextjs.org/telemetry # Uncomment the following line in case you want to disable telemetry during the build. # ENV NEXT_TELEMETRY_DISABLED 1 RUN npm install -g pnpm \ && mv next.config.docker.mjs next.config.mjs \ && pnpm build # Production image, copy all the files and run next FROM base AS runner WORKDIR /app ENV NODE_ENV production # Uncomment the following line in case you want to disable telemetry during runtime. # ENV NEXT_TELEMETRY_DISABLED 1 RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs COPY --from=builder /app/public ./public # Set the correct permission for prerender cache RUN mkdir .next RUN chown nextjs:nodejs .next # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static USER nextjs EXPOSE 3000 ENV PORT 3000 ENV HOSTNAME "0.0.0.0" # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output CMD ["node", "server.js"] ```
2025-02-19 08:00:00
最后更新日期:2025年2月19日 ## 简介 欢迎使用「轻息」应用。我们高度重视您的隐私保护。本隐私政策旨在说明我们如何处理您的信息。 ## 信息收集 「轻息」是一款纯本地的呼吸训练应用,我们: - 不收集任何个人信息 - 不需要网络连接 - 不收集使用数据 - 不使用任何分析工具 - 不存储任何用户数据 ## 数据存储 所有呼吸训练设置都只保存在您的设备本地,我们不会将任何数据上传到云端或服务器。 ## 第三方服务 我们的应用不使用任何第三方服务,也不与第三方共享任何信息。 ## 儿童隐私 我们的应用适合所有年龄段的用户使用,不会收集任何未成年人的信息。 ## 隐私政策更新 如果我们对隐私政策作出更改,我们会在本页面更新内容,并在应用中通知您重要的更改。 ## 联系我们 如果您对本隐私政策有任何疑问,请通过以下方式联系我们: [[email protected]]
2025-02-19 08:00:00
Last Updated: February 19, 2025 ## Introduction Welcome to Auram. We highly value your privacy. This privacy policy explains how we handle your information. ## Information Collection Auram is a purely local breathing training application. We: - Do not collect any personal information - Do not require internet connection - Do not collect usage data - Do not use any analytics tools - Do not store any user data ## Data Storage All breathing training settings are saved locally on your device only. We do not upload any data to the cloud or servers. ## Third-Party Services Our application does not use any third-party services and does not share any information with third parties. ## Children's Privacy Our application is suitable for users of all ages and does not collect any information from minors. ## Privacy Policy Updates If we make changes to our privacy policy, we will update the content on this page and notify you of important changes in the app. ## Contact Us If you have any questions about this privacy policy, please contact us at: [[email protected]]
2025-02-11 08:00:00
🔥 **网站收录终极指南!除了谷歌,把这些搜索引擎都提交上,实现流量起飞!** 🚀 想让你的网站获得更多流量,被更多人发现?谷歌只是众多搜索引擎之一,全球还有那么多的搜索引擎,一个也不能放过 ### 🌍 **国外搜索引擎** 🔍 **Google**(全球最大搜索引擎) 👉 使用Google Search Console → 添加你的网站 🔗 https://search.google.com/search-console 🔍 **Bing**(微软旗下,欧美常用) 👉 进入Bing Webmaster → 提交网站 🔗 https://www.bing.com/webmasters 🔍 **Yandex**(俄罗斯流量王) 👉 Yandex Webmaster → 添加你的网站 🔗 https://webmaster.yandex.com/ 🔍 **Naver**(韩国主流搜索引擎) 👉 Naver站长工具 → 提交网站 🔗 https://searchadvisor.naver.com 🔍 **DuckDuckGo**(隐私友好型搜索引擎) 👉 虽然DuckDuckGo没有站长工具,但它的结果来自Bing和Yandex,提交到Bing和Yandex即可覆盖! 🔍 **Seznam**(捷克主流搜索引擎) 👉 Seznam站长工具 → 添加网站 🔗 https://napoveda.seznam.cz --- ### 🇨🇳 **国内搜索引擎** 🔍 **百度**(中国最大搜索引擎) 👉 百度搜索平台 → 提交链接 🔗 快速提交:https://ziyuan.baidu.com/linksubmit/url ✨ 高阶玩法:用百度站长工具深度优化! 🔗 进阶入口:https://ziyuan.baidu.com 🔍 **360搜索**(中国常用搜索引擎) 👉 360站长平台 → 提交链接 🔗 https://zhanzhang.so.com 🔍 **Sogou**(搜狗搜索) 👉 搜狗站长平台 → 提交网站 🔗 https://zhanzhang.sogou.com --- 📈 提交后别忘了定期检查收录状态哦!
2025-01-26 08:00:00
我们在新上线一个网站时,特别是出海的网站,一般都需要集成Google登录,因为Google账户在国外的普及率相当高。 并且Google登录配置简单,我认为Google登录的优先级在所有的登录方式中甚至可以排到第一位。在网站上线初期,花三分钟先配置一个Google登录尽快上线,是性价比最高的。 虽然但是,整个流程需要配置的步骤还是不少,并且有一些很重要的细节,会影响效率从而影响到上站的速度,因此我今天借一个新站接入Google登录的机会,把全流程详细地记录下来分享给大家。 只要跟着做,小白也能在三分钟内配置好~ ## 第一步:创建Google Cloud项目 1. 访问 [Google Cloud Console](https://console.cloud.google.com/apis/dashboard) 2. 点击右上角的"创建项目"按钮 3. 输入你的项目名称(比如"我的网站") 4. 点击"创建"完成项目创建 5. 切换到新创建的项目  ## 第二步:配置OAuth权限请求页面 1. 在左侧菜单中找到"API和服务" → "OAuth权限请求页面" 2. 用户类型(User Type)选择"外部" 3. 填写应用名称、支持邮箱等基本信息 注意⚠️:这里不要上传应用徽标,否则会有一个验证的时间 4. 添加你的应用域名,privacy policy和terms of service的页面地址(需要提前在网站做好相关内容页) 5. 已获授权的网域 - 网站域名(不用写localhost) 5. 选择需要的权限范围 - 一般是用户的基本信息,比如`userinfo.email`, `userinfo.profile`,不知道选啥的话一般这俩就够了,按需自选 6. 测试用户把自己添加上 7. 测试完成后点击"发布应用",然后就可以让任意用户使用了,也就是正式上线  ## 第三步:配置OAuth凭据 1. 在左侧菜单中找到"API和服务" → "凭据" 2. 点击"创建凭据" → 选择"OAuth客户端ID" 1. 选择应用类型(Web应用) 2. 设置应用名称 3. 设置已获授权的 JavaScript 来源 - 开发环境: (样例)`http://localhost:3000/` - 生产环境: (样例)`https://你的域名/` 3. 添加授权的重定向URI: - 开发环境: (样例)`http://localhost:3000/api/auth/callback/google` - 生产环境: (样例)`https://你的域名/api/auth/callback/google` 4. 点击"创建",你将获得: - 客户端ID(Client ID) - 客户端密钥(Client Secret) 5. 填入环境变量中 ⚠️ 重要提示:请安全保存这些凭据,特别是客户端密钥,千万不要泄露或直接写在代码中! ## 常见问题解答 ### 1. 为什么我的登录按钮点击没反应? - 检查环境变量是否正确配置 - 确认重定向URI是否正确设置 - 查看浏览器控制台是否有错误信息 ### 2. 登录后页面一直加载怎么办? - 检查NEXTAUTH_URL是否与你的实际网站URL匹配 - 确认数据库连接是否正常(如果使用了数据库) ### 3. 生产环境部署注意事项 - 更新环境变量为生产环境的值 - 在Google Cloud Console中添加生产环境的重定向URI - 确保域名已经配置SSL证书(https) ## 安全提示 1. 永远不要在代码中硬编码客户端密钥 2. 使用环境变量存储敏感信息 3. 定期更新依赖包以修复安全漏洞 4. 在生产环境中使用HTTPS 5. 定期检查OAuth同意屏幕的设置
2025-01-26 08:00:00
我们在上线面向开发者的网站,一般都需要集成GitHub登录,因为GitHub账户在开发者群体中的普及率相当高。 GitHub登录的配置相对简单直接,当做的是面向开发者群体的网站时,我的建议是接入Google以及GitHub登录。 虽然整个流程相对简单,但有一些细节需要注意,因此我今天借一个新站接入GitHub登录的机会,把全流程详细地记录下来分享给大家。 只要跟着做,小白也能在三分钟内配置好~  ## 第一步:注册GitHub OAuth应用 1. 访问 [GitHub Developer Settings](https://github.com/settings/developers) 2. 点击"OAuth Apps"标签 3. 点击"New OAuth App"按钮 4. 填写应用信息: - Application name:你的应用名称 - Homepage URL:你的网站首页地址 - Application description:应用描述,会展示在授权界面 - Authorization callback URL:授权回调地址(样例) - 开发环境:`http://localhost:3000/api/auth/callback/github` - 生产环境:`https://你的域名/api/auth/callback/github` - Enable Device Flow : 不用管 ⚠️ 注意:URL只能填写一个,所以开发环境和生产环境需要申请两个不同的Application.  ## 第二步:获取OAuth凭据 1. 创建应用后,你会看到应用详情页面 2. 记录下 Client ID(客户端ID) 3. 点击"Generate a new client secret"生成新的客户端密钥 4. 立即保存生成的Client Secret(客户端密钥),因为它只会显示一次。 5. 将Client ID和Client Secret填写到环境变量 6. 上传网站logo,点击"Update Application" ⚠️ 注意:如果你不小心丢失了Client Secret,只能重新生成一个新的。 ## 常见问题解答 ### 1. 为什么我的登录按钮点击没反应? - 检查环境变量是否正确配置 - 确认回调URL是否与GitHub OAuth应用中设置的完全一致 - 查看浏览器控制台是否有错误信息 ### 2. 登录后页面一直加载怎么办? - 检查NEXTAUTH_URL是否与你的实际网站URL匹配 - 确认数据库连接是否正常(如果使用了数据库) - 验证GitHub OAuth应用的回调URL是否正确配置 ### 3. 生产环境部署注意事项 - 更新环境变量为生产环境的值 - 在GitHub OAuth应用设置中添加生产环境的回调URL - 确保域名已经配置SSL证书(https) ## 安全提示 1. 永远不要在代码中硬编码客户端密钥 2. 使用环境变量存储敏感信息 3. 定期更新依赖包以修复安全漏洞 4. 在生产环境中使用HTTPS 5. 定期检查GitHub OAuth应用的权限设置 6. 如果怀疑凭据泄露,立即重新生成Client Secret