-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
94 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'package.json' | ||
- 'package-lock.json' | ||
- 'Dockerfile-base' | ||
pull_request: | ||
paths: | ||
- 'package.json' | ||
- 'package-lock.json' | ||
- 'Dockerfile-base' | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Extract commit ID | ||
id: vars | ||
run: echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Create builder | ||
run: | | ||
docker buildx create --use --name mybuilder | ||
docker buildx inspect --bootstrap | ||
- name: Build and push multi-arch image | ||
run: | | ||
docker buildx build \ | ||
--platform linux/amd64,linux/arm64 \ | ||
-f Dockerfile-base \ | ||
-t jumpserver/lina-base:${{ env.COMMIT_ID }} \ | ||
-t jumpserver/lina-base:latest \ | ||
--push . | ||
- name: Update Dockerfile | ||
run: | | ||
sed -i 's|-base:.* AS stage-build|-base:${{ env.COMMIT_ID }} AS stage-build|' Dockerfile | ||
- name: Commit changes | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add Dockerfile | ||
git commit -m "perf: Update Dockerfile with new base image tag" | ||
git push | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM node:16.20-bullseye-slim AS stage-build | ||
ARG TARGETARCH | ||
|
||
ARG DEPENDENCIES=" \ | ||
g++ \ | ||
make \ | ||
python3" | ||
|
||
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 \ | ||
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 \ | ||
&& sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \ | ||
&& apt-get update \ | ||
&& apt-get -y install --no-install-recommends ${DEPENDENCIES} \ | ||
&& echo "no" | dpkg-reconfigure dash | ||
|
||
ARG NPM_REGISTRY="https://registry.npmmirror.com" | ||
|
||
RUN set -ex \ | ||
&& npm config set registry ${NPM_REGISTRY} \ | ||
&& yarn config set registry ${NPM_REGISTRY} | ||
|
||
WORKDIR /data | ||
|
||
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked \ | ||
--mount=type=bind,source=package.json,target=package.json \ | ||
--mount=type=bind,source=yarn.lock,target=yarn.lock \ | ||
yarn install |