diff --git a/.github/workflows/test-arm.yml b/.github/workflows/test-arm.yml new file mode 100644 index 000000000..ae940b86e --- /dev/null +++ b/.github/workflows/test-arm.yml @@ -0,0 +1,46 @@ +name: arm + +on: + push: + tags: + - "arm*" +permissions: + contents: write + +jobs: + arm: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Get version + id: get_version + run: | + TIMEVERSION=$(date "+%Y%m%d-%H%M%S") + echo ::set-output name=VERSION::${TIMEVERSION} + - name: 展示版本 + run: echo ${{ steps.get_version.outputs.VERSION }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: 打包镜像并推送 + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + build-args: | + VAN_BLOG_BUILD_SERVER=https://blog-demo.mereith.com/ + VAN_BLOG_VERSIONS=test-${{ steps.get_version.outputs.VERSION }} + platforms: linux/arm64 + push: true + tags: | + "docker.io/mereith/van-blog:test-${{ steps.get_version.outputs.VERSION }}" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e9aa086c4..6f336adbf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,24 +28,15 @@ RUN pnpm config set fetch-timeout 600000 -g RUN pnpm i RUN pnpm build -FROM node:16-alpine AS WEBSITE_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 +FROM node:18-alpine AS WEBSITE_BUILDER WORKDIR /app -COPY ./packages/website/package.json ./packages/website/pnpm-lock.yaml* ./ -RUN npm install --global pnpm@7.27.1 -RUN pnpm config set network-timeout 600000 -g -RUN pnpm config set registry https://registry.npmmirror.com -g -RUN pnpm config set fetch-retries 20 -g -RUN pnpm config set fetch-timeout 600000 -g -# RUN yarn config set registry https://registry.npmmirror.com -g -RUN pnpm i - -FROM node:16-alpine AS WEBSITE_BUILDER -WORKDIR /app -COPY --from=WEBSITE_DEPS /app/node_modules ./node_modules -COPY ./packages/website/ . -ENV isBuild=t +COPY ./package.json ./ +COPY ./pnpm-lock.yaml ./ +COPY ./pnpm-workspace.yaml ./ +COPY ./tsconfig.base.json ./ +COPY ./lerna.json ./ +COPY ./packages/website ./packages/website +ENV isBuild t ENV VAN_BLOG_ALLOW_DOMAINS "pic.mereith.com" ARG VAN_BLOG_BUILD_SERVER ENV VAN_BLOG_SERVER_URL ${VAN_BLOG_BUILD_SERVER} @@ -56,7 +47,8 @@ RUN pnpm config set network-timeout 600000 -g RUN pnpm config set registry https://registry.npmmirror.com -g RUN pnpm config set fetch-retries 20 -g RUN pnpm config set fetch-timeout 600000 -g -RUN pnpm build +RUN pnpm install --frozen-lockfile +RUN pnpm build:website #运行容器 @@ -81,12 +73,12 @@ COPY --from=SERVER_BUILDER /app/node_modules ./node_modules COPY --from=SERVER_BUILDER /app/dist/src/ ./ # 复制 website WORKDIR /app/website -COPY --from=WEBSITE_BUILDER /app/next.config.js ./ -COPY --from=WEBSITE_BUILDER /app/public ./public -COPY --from=WEBSITE_BUILDER /app/package.json ./package.json -COPY --from=WEBSITE_BUILDER /app/.next/standalone ./ -COPY --from=WEBSITE_BUILDER /app/.next/static ./.next/static -RUN cd /app/website && cd .. +COPY --from=WEBSITE_BUILDER /app/packages/website/.next/standalone/ ./ +COPY --from=WEBSITE_BUILDER /app/packages/website/next.config.js ./packages/website/next.config.js +COPY --from=WEBSITE_BUILDER /app/packages/website/public ./packages/website/public +COPY --from=WEBSITE_BUILDER /app/packages/website/package.json ./packages/website/package.json +COPY --from=WEBSITE_BUILDER /app/packages/website/.next/static ./packages/website/.next/static +RUN cd /app/website && cd .. ENV NODE_ENV production ENV VAN_BLOG_SERVER_URL "http://127.0.0.1:3000" ENV VAN_BLOG_ALLOW_DOMAINS "pic.mereith.com" diff --git a/packages/server/src/provider/website/website.provider.ts b/packages/server/src/provider/website/website.provider.ts index 93686914c..fc729050a 100644 --- a/packages/server/src/provider/website/website.provider.ts +++ b/packages/server/src/provider/website/website.provider.ts @@ -101,13 +101,13 @@ export class WebsiteProvider { let args = ['dev']; if (process.env.NODE_ENV == 'production') { cmd = 'node'; - args = ["server.js"]; + args = ["./packages/website/server.js"]; } const loadEnvs = await this.loadEnv(); this.logger.log(JSON.stringify(loadEnvs, null, 2)); if (this.ctx == null) { this.ctx = spawn(cmd, args, { - env: { + env: { ...process.env, ...loadEnvs, },