Skip to content

Commit

Permalink
Merge pull request #1099 from jumpserver/pr@v4@perf_docker_build
Browse files Browse the repository at this point in the history
perf: 优化构建
  • Loading branch information
wojiushixiaobai authored May 30, 2024
2 parents 43eee38 + 62f266c commit 51b307e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14,984 deletions.
46 changes: 30 additions & 16 deletions .github/workflows/jms-build-test.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
name: "Run Build Test"
on:
push:
branches:
- pr@*
- repr@*
paths:
- 'Dockerfile'
- 'Dockerfile*'
- 'package.json'
- 'yarn.lock'

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
component: [luna]
version: [v4]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3

- uses: docker/setup-qemu-action@v2
- name: Prepare Build
run: |
sed -i '[email protected]@registry.yarnpkg.com@g' yarn.lock
- uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/build-push-action@v3
- name: Build Image
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: jumpserver/luna:test
push: true
file: Dockerfile
tags: ghcr.io/jumpserver/${{ matrix.component }}:${{ matrix.version }}
platforms: linux/amd64
build-args: |
VERSION=${{ matrix.version }}
APT_MIRROR=http://deb.debian.org
NPM_REGISTRY=https://registry.yarnpkg.com
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
cache-from: type=gha
cache-to: type=gha,mode=max

- uses: LouisBrunner/[email protected]
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Check Build
conclusion: ${{ job.status }}
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ FROM node:16.20-bullseye-slim as stage-build
ARG TARGETARCH
ARG NPM_REGISTRY="https://registry.npmmirror.com"

WORKDIR /data

RUN set -ex \
&& npm config set registry ${NPM_REGISTRY} \
&& yarn config set registry ${NPM_REGISTRY}

ADD package.json yarn.lock /data/
WORKDIR /data

RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=luna \
--mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=yarn.lock,target=yarn.lock \
yarn install

ARG VERSION
ENV VERSION=$VERSION

ADD . /data

RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=luna \
sed -i "s@version =.*;@version = '${VERSION}';@g" src/environments/environment.prod.ts \
&& yarn build \
Expand Down
Loading

0 comments on commit 51b307e

Please sign in to comment.