Skip to content

Commit 2b3eb28

Browse files
committed
perf: change build
perf: using cache perf: using pnpm
1 parent 453c4b1 commit 2b3eb28

File tree

4 files changed

+84
-35
lines changed

4 files changed

+84
-35
lines changed
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and Push Base Image
2+
3+
on:
4+
push:
5+
paths:
6+
- 'package.json'
7+
- 'package-lock.json'
8+
- 'yarn.lock'
9+
- 'Dockerfile-base'
10+
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Login to DockerHub
26+
uses: docker/login-action@v2
27+
with:
28+
username: ${{ secrets.DOCKERHUB_USERNAME }}
29+
password: ${{ secrets.DOCKERHUB_TOKEN }}
30+
31+
- name: Extract date
32+
id: vars
33+
run: echo "IMAGE_TAG=$(date +'%Y%m%d_%H%M%S')" >> $GITHUB_ENV
34+
35+
- name: Extract repository name
36+
id: repo
37+
run: echo "REPO=$(basename ${{ github.repository }})" >> $GITHUB_ENV
38+
39+
- name: Build and push multi-arch image
40+
uses: docker/build-push-action@v6
41+
with:
42+
platforms: linux/amd64,linux/arm64
43+
push: true
44+
file: Dockerfile-base
45+
tags: jumpserver/${{ env.REPO }}-base:${{ env.IMAGE_TAG }}
46+
47+
- name: Update Dockerfile
48+
run: |
49+
sed -i 's|-base:.* AS stage-build|-base:${{ env.IMAGE_TAG }} AS stage-build|' Dockerfile
50+
51+
- name: Commit changes
52+
run: |
53+
git config --global user.name 'github-actions[bot]'
54+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
55+
git add Dockerfile
56+
git commit -m "perf: Update Dockerfile with new base image tag"
57+
git push
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

+1-31
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
1-
FROM node:16.20-bullseye-slim AS stage-build
2-
ARG TARGETARCH
3-
4-
ARG DEPENDENCIES=" \
5-
g++ \
6-
make \
7-
python3"
8-
9-
ARG APT_MIRROR=http://mirrors.ustc.edu.cn
10-
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
11-
--mount=type=cache,target=/var/lib/apt,sharing=locked \
12-
set -ex \
13-
&& rm -f /etc/apt/apt.conf.d/docker-clean \
14-
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache \
15-
&& sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
16-
&& apt-get update \
17-
&& apt-get -y install --no-install-recommends ${DEPENDENCIES} \
18-
&& echo "no" | dpkg-reconfigure dash
19-
20-
ARG NPM_REGISTRY="https://registry.npmmirror.com"
21-
22-
RUN set -ex \
23-
&& npm config set registry ${NPM_REGISTRY} \
24-
&& yarn config set registry ${NPM_REGISTRY}
25-
26-
WORKDIR /data
27-
28-
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked \
29-
--mount=type=bind,source=package.json,target=package.json \
30-
--mount=type=bind,source=yarn.lock,target=yarn.lock \
31-
yarn install
1+
FROM jumpserver/lina-base:latest AS stage-build
322

333
ARG VERSION
344
ENV VERSION=$VERSION

Dockerfile-base

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM node:20.15-bullseye-slim
2+
3+
ARG DEPENDENCIES=" \
4+
g++ \
5+
make \
6+
python3"
7+
8+
RUN set -ex \
9+
&& rm -f /etc/apt/apt.conf.d/docker-clean \
10+
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
11+
&& apt-get update \
12+
&& apt-get -y install --no-install-recommends ${DEPENDENCIES} \
13+
&& echo "no" | dpkg-reconfigure dash
14+
15+
WORKDIR /data
16+
17+
COPY package.json yarn.lock ./
18+
19+
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=yarn-cache \
20+
yarn install

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "Lina",
2+
"name": "lina",
33
"version": "v4.0.0",
44
"description": "JumpServer Web UI",
55
"author": "JumpServer Team <[email protected]>",
66
"license": "GPL-3.0-or-later",
77
"scripts": {
8-
"dev": "vue-cli-service serve",
9-
"serve": "vue-cli-service serve",
10-
"build": "vue-cli-service build",
8+
"dev": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
9+
"serve": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
10+
"build": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service build",
1111
"build:prod": "vue-cli-service build",
1212
"build:stage": "vue-cli-service build --mode staging",
1313
"preview": "node build/index.js --preview",

0 commit comments

Comments
 (0)