Skip to content

Commit

Permalink
perf: 按要求移除重复构建代码
Browse files Browse the repository at this point in the history
  • Loading branch information
wojiushixiaobai committed May 30, 2024
1 parent aa37ab2 commit 3bdfd01
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/jms-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
component: [lion]
version: [v4]
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v3

- name: Prepare Mirror
- name: Prepare Build
run: |
sed -i 's@registry.npmmirror.com@registry.yarnpkg.com@g' ui/yarn.lock
sed -i 's@registry.fit2cloud.com/@@g' Dockerfile
sed -i 's@^FROM registry.fit2cloud.com/jumpserver@FROM ghcr.io/jumpserver@g' Dockerfile
sed -i 's@^FROM registry.fit2cloud.com/jumpserver@FROM ghcr.io/jumpserver@g' Dockerfile-ee
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -33,34 +38,28 @@ jobs:
context: .
push: true
file: Dockerfile
tags: ghcr.io/jumpserver/lion:v4-lite
tags: ghcr.io/jumpserver/${{ matrix.component }}:${{ matrix.version }}-ce
platforms: linux/amd64
build-args: |
VERSION=v4
VERSION=${{ matrix.version }}
GOPROXY=direct
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

- name: Prepare EE Image
run: |
sed -i 's@^FROM registry.fit2cloud.com/jumpserver@FROM ghcr.io/jumpserver@g' Dockerfile-ee

- name: Build EE Image
uses: docker/build-push-action@v5
with:
context: .
push: false
file: Dockerfile-ee
tags: jumpserver/lion:v4
tags: ghcr.io/jumpserver/${{ matrix.component }}:${{ matrix.version }}
platforms: linux/amd64
build-args: |
VERSION=v4
GOPROXY=direct
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
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ RUN set -ex \

WORKDIR /opt/lion/ui
ADD ui/package.json ui/yarn.lock .
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked \
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=lion \
yarn install

ADD ui .
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked \
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=lion \
yarn build

FROM golang:1.22-bullseye as stage-build
Expand Down Expand Up @@ -42,7 +42,7 @@ ENV GOOS=linux

RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/go/pkg/mod \
go mod download -x
go mod download

COPY . .
ARG VERSION
Expand All @@ -58,7 +58,7 @@ RUN --mount=type=cache,target=/root/.cache \

RUN chmod +x entrypoint.sh

FROM registry.fit2cloud.com/jumpserver/guacd:1.5.5-bullseye
FROM jumpserver/guacd:1.5.5-bullseye
ARG TARGETARCH
ENV LANG=en_US.UTF-8

Expand All @@ -69,8 +69,8 @@ ARG DEPENDENCIES=" \
supervisor"

ARG APT_MIRROR=http://mirrors.ustc.edu.cn
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=lion \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=lion \
set -ex \
&& rm -f /etc/apt/apt.conf.d/docker-clean \
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache \
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile-ee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG VERSION

FROM registry.fit2cloud.com/jumpserver/lion:${VERSION}-lite
FROM registry.fit2cloud.com/jumpserver/lion:${VERSION}-ce
ARG TARGETARCH

ARG DEPENDENCIES=" \
Expand All @@ -10,8 +10,8 @@ ARG DEPENDENCIES=" \
vim \
wget"

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=lion \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=lion \
set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends ${DEPENDENCIES}

0 comments on commit 3bdfd01

Please sign in to comment.