Skip to content

Commit

Permalink
perf: docker push
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuler committed Jul 22, 2024
1 parent a770a0a commit 028441e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build and Push Base Image

on:
push:
paths:
- 'requirements.txt'
- '*.yml'

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
tags: jumpserver/${{ env.REPO }}:${{ env.IMAGE_TAG }}
file: Dockerfile

- name: Login to GitHub container registry
uses: docker/login-action@v3
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
#
- name: Get current branch name
id: get_branch
run: echo "current_branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV

- name: Update docker-web dependencies applets
run: |
git clone https://github.com/jumpserver/docker-web.git
cd docker-web
git checkout -b ${{ env.current_branch }}
sed -i 's|jumpserver/applets:.* |jumpserver/applets:${{ env.IMAGE_TAG }} |' Dockerfile
git add Dockerfile
git commit -m "perf: Update Dockerfile applets version"
git push origin ${{ env.current_branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG DEPENDENCIES=" \
wget \
zip"

ARG APT_MIRROR=http://mirrors.ustc.edu.cn
ARG APT_MIRROR=http://deb.debian.org
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
set -ex \
Expand All @@ -16,11 +16,12 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
&& sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
&& apt-get update \
&& apt-get -y install --no-install-recommends ${DEPENDENCIES} \
&& apt-get clean all \
&& echo "no" | dpkg-reconfigure dash

WORKDIR /opt/applets

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=applets \
--mount=type=bind,source=requirements.txt,target=requirements.txt \
set -ex \
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pywinauto==0.6.6
selenium==4.4.0
pywin32==304
PyYAML==6.0
cffi==1.16.0
cffi==1.16.0

0 comments on commit 028441e

Please sign in to comment.