mirror of https://github.com/jumpserver/jumpserver
perf: change docker file build (#13761)
* perf: change docker file build * perf: Update Dockerfile with new base image tag --------- Co-authored-by: ibuler <ibuler@qq.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>pull/13763/head
parent
5e45129e32
commit
ef656a8dfd
@ -0,0 +1,60 @@
|
|||||||
|
name: Build and Push Base Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'pr*'
|
||||||
|
paths:
|
||||||
|
- 'poetry.lock'
|
||||||
|
- 'pyproject.toml'
|
||||||
|
- 'Dockerfile-base'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract date
|
||||||
|
id: vars
|
||||||
|
run: echo "IMAGE_TAG=$(date +'%Y%m%d_%H%M%S')" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Extract repository name
|
||||||
|
id: repo
|
||||||
|
run: echo "REPO=$(basename ${{ github.repository }})" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build and push multi-arch image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
file: Dockerfile-base
|
||||||
|
tags: jumpserver/core-base:${{ env.IMAGE_TAG }}
|
||||||
|
|
||||||
|
- name: Update Dockerfile
|
||||||
|
run: |
|
||||||
|
sed -i 's|-base:.* AS stage-build|-base:${{ env.IMAGE_TAG }} 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 }}
|
@ -0,0 +1,54 @@
|
|||||||
|
FROM python:3.11-slim-bullseye
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
# Install APT dependencies
|
||||||
|
ARG DEPENDENCIES=" \
|
||||||
|
ca-certificates \
|
||||||
|
wget \
|
||||||
|
g++ \
|
||||||
|
make \
|
||||||
|
pkg-config \
|
||||||
|
default-libmysqlclient-dev \
|
||||||
|
freetds-dev \
|
||||||
|
gettext \
|
||||||
|
libkrb5-dev \
|
||||||
|
libldap2-dev \
|
||||||
|
libsasl2-dev"
|
||||||
|
|
||||||
|
|
||||||
|
ARG APT_MIRROR=http://deb.debian.org
|
||||||
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core \
|
||||||
|
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=core \
|
||||||
|
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 > /dev/null \
|
||||||
|
&& apt-get -y install --no-install-recommends ${DEPENDENCIES} \
|
||||||
|
&& echo "no" | dpkg-reconfigure dash
|
||||||
|
|
||||||
|
|
||||||
|
# Install bin tools
|
||||||
|
ARG CHECK_VERSION=v1.0.2
|
||||||
|
RUN set -ex \
|
||||||
|
&& wget https://github.com/jumpserver-dev/healthcheck/releases/download/${CHECK_VERSION}/check-${CHECK_VERSION}-linux-${TARGETARCH}.tar.gz \
|
||||||
|
&& tar -xf check-${CHECK_VERSION}-linux-${TARGETARCH}.tar.gz \
|
||||||
|
&& mv check /usr/local/bin/ \
|
||||||
|
&& chown root:root /usr/local/bin/check \
|
||||||
|
&& chmod 755 /usr/local/bin/check \
|
||||||
|
&& rm -f check-${CHECK_VERSION}-linux-${TARGETARCH}.tar.gz
|
||||||
|
|
||||||
|
|
||||||
|
# Install Python dependencies
|
||||||
|
WORKDIR /opt/jumpserver
|
||||||
|
|
||||||
|
ARG PIP_MIRROR=https://pypi.org/simple
|
||||||
|
RUN --mount=type=cache,target=/root/.cache,sharing=locked,id=core \
|
||||||
|
--mount=type=bind,source=poetry.lock,target=poetry.lock \
|
||||||
|
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
||||||
|
set -ex \
|
||||||
|
&& python3 -m venv /opt/py3 \
|
||||||
|
&& pip install poetry -i ${PIP_MIRROR} \
|
||||||
|
&& poetry config virtualenvs.create false \
|
||||||
|
&& . /opt/py3/bin/activate \
|
||||||
|
&& poetry install --only main
|
@ -1,52 +1,38 @@
|
|||||||
ARG VERSION
|
ARG VERSION
|
||||||
|
|
||||||
FROM registry.fit2cloud.com/jumpserver/xpack:${VERSION} AS build-xpack
|
FROM registry.fit2cloud.com/jumpserver/xpack:${VERSION} AS build-xpack
|
||||||
FROM python:3.11-slim-bullseye AS build-core
|
FROM jumpserver/core:${VERSION}-ce
|
||||||
ARG BUILD_DEPENDENCIES=" \
|
|
||||||
g++"
|
|
||||||
|
|
||||||
ARG APT_MIRROR=http://mirrors.ustc.edu.cn
|
COPY --from=build-xpack /opt/xpack /opt/jumpserver/apps/xpack
|
||||||
|
|
||||||
|
ARG TOOLS=" \
|
||||||
|
g++ \
|
||||||
|
curl \
|
||||||
|
iputils-ping \
|
||||||
|
netcat-openbsd \
|
||||||
|
nmap \
|
||||||
|
telnet \
|
||||||
|
vim \
|
||||||
|
wget"
|
||||||
|
|
||||||
|
ARG APT_MIRROR=http://deb.debian.org
|
||||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core \
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core \
|
||||||
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=core \
|
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=core \
|
||||||
set -ex \
|
set -ex \
|
||||||
&& rm -f /etc/apt/apt.conf.d/docker-clean \
|
&& rm -f /etc/apt/apt.conf.d/docker-clean \
|
||||||
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache \
|
&& 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 \
|
&& sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get -y install --no-install-recommends ${BUILD_DEPENDENCIES} \
|
&& apt-get -y install --no-install-recommends ${TOOLS} \
|
||||||
&& echo "no" | dpkg-reconfigure dash
|
&& echo "no" | dpkg-reconfigure dash
|
||||||
|
|
||||||
WORKDIR /opt/jumpserver
|
|
||||||
|
|
||||||
ARG PIP_MIRROR=https://pypi.tuna.tsinghua.edu.cn/simple
|
ARG PIP_MIRROR=https://pypi.org/simple
|
||||||
RUN --mount=type=cache,target=/root/.cache,sharing=locked,id=core \
|
RUN --mount=type=cache,target=/root/.cache,sharing=locked,id=core \
|
||||||
--mount=type=bind,source=poetry.lock,target=/opt/jumpserver/poetry.lock \
|
--mount=type=bind,source=poetry.lock,target=/opt/jumpserver/poetry.lock \
|
||||||
--mount=type=bind,source=pyproject.toml,target=/opt/jumpserver/pyproject.toml \
|
--mount=type=bind,source=pyproject.toml,target=/opt/jumpserver/pyproject.toml \
|
||||||
set -ex \
|
set -ex \
|
||||||
&& python3 -m venv /opt/py3 \
|
. /opt/py3/bin/activate \
|
||||||
&& pip install poetry -i ${PIP_MIRROR} \
|
&& pip install poetry -i ${PIP_MIRROR} \
|
||||||
&& poetry config virtualenvs.create false \
|
|
||||||
&& . /opt/py3/bin/activate \
|
|
||||||
&& poetry install --only xpack
|
&& poetry install --only xpack
|
||||||
|
|
||||||
FROM registry.fit2cloud.com/jumpserver/core:${VERSION}-ce
|
|
||||||
ARG TARGETARCH
|
|
||||||
|
|
||||||
ARG TOOLS=" \
|
|
||||||
curl \
|
|
||||||
iputils-ping \
|
|
||||||
netcat-openbsd \
|
|
||||||
nmap \
|
|
||||||
telnet \
|
|
||||||
vim \
|
|
||||||
wget"
|
|
||||||
|
|
||||||
ARG APT_MIRROR=http://mirrors.ustc.edu.cn
|
|
||||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core \
|
|
||||||
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=core \
|
|
||||||
set -ex \
|
|
||||||
&& apt-get update \
|
|
||||||
&& apt-get -y install --no-install-recommends ${TOOLS}
|
|
||||||
|
|
||||||
COPY --from=build-core /opt/py3 /opt/py3
|
|
||||||
COPY --from=build-xpack /opt/xpack /opt/jumpserver/apps/xpack
|
|
Loading…
Reference in new issue