on: workflow_call: inputs: checkout-code: required: false type: boolean default: false artifact-skip: required: false type: boolean default: false artifact-name: required: false type: string default: 'artifact' docker_context: required: false type: string default: '.' dockerfile_path: required: false type: string default: './Dockerfile' http_proxy: required: false type: string # default: 'http://192.168.0.20:7890' default: 'http://act_clash:7890' runs_on: required: false type: string default: 'ubuntu_act_on_20' platforms: required: false type: string default: 'linux/amd64' docker_image_name: required: false type: string default: ${{ github.repository }} base_image: required: false type: string default: 'scipy-notebook' base_image_version: required: false type: string default: 'lab-4.1.5' jobs: publish-docker-image: runs-on: ${{ inputs.runs_on }} # container: # image: catthehacker/ubuntu:act-latest env: RUNNER_TOOL_CACHE: /toolcache steps: - name: Check out code uses: actions/checkout@v3 if: ${{ inputs.checkout-code == true }} - uses: actions/download-artifact@v3 if: ${{ inputs.artifact-skip != true }} with: name: ${{ inputs.artifact-name }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker BuildX uses: docker/setup-buildx-action@v2 with: driver-opts: | network=act_runner_default env.http_proxy=http://act_clash:7890 env.https_proxy=http://act_clash:7890 - name: Login to Docker Registry uses: docker/login-action@v2 with: registry: ${{ secrets.REGISTRY_HOST }} username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - name: Docker meta id: meta uses: docker/metadata-action@v4 with: images: | # my-docker-hub-namespace/my-docker-hub-repository ${{ secrets.REGISTRY_HOST }}/${{ inputs.docker_image_name }} tags: | type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern=v{{major}} # - name: Cache docker buildx main # uses: actions/cache@v4 # with: # path: /tmp/.buildx-main-cache # key: ${{ runner.os }}-buildx-main-${{ github.sha }} # restore-keys: | # ${{ runner.os }}-buildx-main- - name: Build and push uses: docker/build-push-action@v4 with: network: host build-args: | http_proxy=${{ inputs.http_proxy }} https_proxy=${{ inputs.http_proxy }} version=${{ steps.meta.outputs.version }} registry=${{ secrets.REGISTRY_HOST }} BaseImage=${{ inputs.base_image }} BaseImageVersion=${{ inputs.base_image_version }} context: ${{ inputs.docker_context }} file: ${{ inputs.dockerfile_path }} platforms: ${{ inputs.platforms }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} # cache-from: type=local,src=/tmp/.buildx-main-cache # cache-to: type=local,mode=max,dest=/tmp/.buildx-main-cache-new # - # Temp fix # # https://github.com/docker/build-push-action/issues/252 # # https://github.com/moby/buildkit/issues/1896 # name: Move cache # run: | # rm -rf /tmp/.buildx-main-cache # mv /tmp/.buildx-main-cache-new /tmp/.buildx-main-cache