Skip to content

Commit

Permalink
CI用イメージビルド
Browse files Browse the repository at this point in the history
  • Loading branch information
na2na-p committed Nov 28, 2023
1 parent d55004a commit 6118e67
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/actions/prepare-docker-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Prepare Docker Image
description: Prepare Docker Image for CI
inputs:
docker_image_tag_ci:
description: Docker Image Tag for CI
required: true

runs:
using: composite
steps:
- uses: actions/checkout@v4
- name: Prepare for ci
shell: bash
id: prepare-for-ci
run: |
echo "WWWUSER=$(id -u)" >> $GITHUB_ENV
echo "WWWUSER=$(id -u)" >> $GITHUB_OUTPUT
echo "WWWGROUP=$(id -g)" >> $GITHUB_ENV
echo "WWWGROUP=$(id -g)" >> $GITHUB_OUTPUT
- name: Cache Docker Registry
uses: actions/cache@v3
with:
path: /tmp/docker-registry
key: docker-registry-${{ github.ref }}-${{ github.sha }}
restore-keys: |
docker-registry-${{ github.ref }}
docker-registry-
- name: Boot-up Local Docker Registry
shell: bash
run: docker run -d -p 5000:5000 --restart=always --name registry -v /tmp/docker-registry:/var/lib/registry registry:2
- name: Wait for Docker Registry
shell: bash
run: npx wait-on tcp:5000
- name: Get Docker Image Tag
shell: bash
env:
TAG: ${{ inputs.docker_image_tag_ci }}
run: |
echo "DOCKER_IMAGE_TAG_CI=$TAG" >> $GITHUB_ENV
echo TAG $TAG
- name: Docker Compose Pull
shell: bash
run: |
docker pull localhost:5000/jetdisc-ci:${{ inputs.docker_image_tag_ci }}
# - name: List docker images in registry
# shell: bash
# run: |
# curl -X GET http://localhost:5000/v2/_catalog
4 changes: 4 additions & 0 deletions .github/workflows/cd-for-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ jobs:
uses: ./.github/workflows/ci.yml
secrets: inherit
needs: prepare
image-build-for-ci:
uses: ./.github/workflows/image-build.yml
secrets: inherit
needs: prepare
59 changes: 59 additions & 0 deletions .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Image build
on:
workflow_call:
outputs:
docker_image_tag_ci:
description: Docker image tag for CI
value: ${{ jobs.image-build.outputs.docker_image_tag_ci }}
workflow_dispatch:

jobs:
image-build:
runs-on:
- ubuntu-latest
outputs:
docker_image_tag_ci: ${{ steps.generate_docker_image_tag.outputs.docker_image_tag_ci }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Docker Build Cache
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: docker-build-cache-${{ github.ref }}-${{ github.sha }}
restore-keys: |
docker-build-cache-${{ github.ref }}
docker-build-cache-
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Generate Docker Image Tag
id: generate_docker_image_tag
run: |
SHA=${{ github.sha }}
TAG=$(TZ=UTC-9 date '+%Y%m')-${SHA:0:7}
echo "DOCKER_IMAGE_TAG_CI=$TAG" >> $GITHUB_ENV
echo TAG $TAG
echo "docker_image_tag_ci=$TAG" >> $GITHUB_OUTPUT
- name: Cache Docker Registry
uses: actions/cache@v3
with:
path: /tmp/docker-registry
key: docker-registry-${{ github.ref }}-${{ github.sha }}
restore-keys: |
docker-registry-${{ github.ref }}
docker-registry-
- name: Boot-up Local Docker Registry
run: docker run -d -p 5000:5000 --restart=always --name registry -v /tmp/docker-registry:/var/lib/registry registry:2
- name: Wait for Docker Registry
run: npx wait-on tcp:5000
- name: Build Docker Image
run: |
docker buildx bake \
-f 'infra/docker/image-bake.hcl' \
--builder="${{ steps.buildx.outputs.name }}" \
--set='app.tags=localhost:5000/jetdisc-ci:${{ steps.generate_docker_image_tag.outputs.docker_image_tag_ci }}' \
--set='app.platforms=linux/amd64' \
--push

0 comments on commit 6118e67

Please sign in to comment.