Skip to content

添加打包为 Docker 镜像并使用的方法;添加 CORS 控制 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DingJunyao
Copy link

@DingJunyao DingJunyao commented Oct 17, 2023

为方便用户使用,添加 Dockerfile 用于打包镜像;

另外:

  • config.js 内各参数的获取方式改为从环境变量获取,便于 Docker 部署与安全部署;并在 git 内加入该文件;原先的运行方式仍然可用
  • 在实际使用中发现,涉及跨域问题,故添加 CORS 控制。

打包:

docker build -t wx_jsapi_sign:latest .

以 docker 命令行方式运行(示例):

docker run \
    -d \
    --name wx_jsapi_sign \
    --port PORT:3000 \
    -e COMPANY_NAME="Beijing Dream Castle Culture Co., Ltd" \
    -e PROJECT_NAME=梦之城微信控制中心 \
    -e [email protected] \
    -e CRYPTO_KEY=k4yb0ardc4x \
    -e LOCAL_SOURCE=dreamcastle \
    -e APP_ID=wx9999999999 \
    -e APP_SECRET=ad73709c6e0815c999999999999 \
    -e WHITELIST=https://4ading.com,http://localhost:4000 \
    --restart unless-stopped \
    wx_jsapi_sign:latest

以 Docker Compose 配置文件运行(示例):

version: "3.9"
services:
  wx_jsapi_sign:
    container_name: wx_jsapi_sign
    image: wx_jsapi_sign:latest
    ports:
      - PORT:3000
    environment:
      - COMPANY_NAME="Beijing Dream Castle Culture Co., Ltd"
      - PROJECT_NAME=梦之城微信控制中心
      - [email protected]
      - CRYPTO_KEY=k4yb0ardc4x
      - LOCAL_SOURCE=dreamcastle
      - APP_ID=wx9999999999
      - APP_SECRET=ad73709c6e0815c999999999999
      - WHITELIST=https://4ading.com,http://localhost:4000  # CORS, 留空允许全部
    restart: unless-stopped

我这边已打包至 Docker Hub (dingjunyao/wx_jsapi_sign)GitHub Packages(ghcr.io/dingjunyao/wx_jsapi_sign)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant