Skip to content

Commit

Permalink
chore: build error,website 构建锁定版本
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed Apr 17, 2023
1 parent 86d3f35 commit 32818c3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 26 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/test-arm.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
40 changes: 16 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]
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}
Expand All @@ -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


#运行容器
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/provider/website/website.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit 32818c3

Please sign in to comment.