|
1 | 1 | name: Build Docker Image
|
2 |
| -description: Build a local Docker image using buildkit |
| 2 | +description: Builds a Docker image (with BuildKit enabled). |
3 | 3 |
|
4 | 4 | inputs:
|
5 | 5 | path:
|
6 |
| - description: Path to Docker build context |
| 6 | + description: Docker build context path (e.g., "."). |
7 | 7 | required: true
|
8 | 8 | target:
|
9 |
| - description: Docker build target |
| 9 | + description: Docker build target (e.g., "server"). |
10 | 10 | required: true
|
11 | 11 | tag:
|
12 |
| - description: Local tag for Docker image |
13 |
| - required: false |
14 |
| - docker-args: |
15 |
| - description: Extra arguments to docker build |
| 12 | + description: Docker build image tag (e.g., "server-production"). |
| 13 | + required: true |
| 14 | + docker-build-extra-args: |
| 15 | + description: Docker build extra arguments (e.g., "--build-arg DEBUG=false"). |
16 | 16 | required: false
|
17 | 17 |
|
18 |
| -outputs: |
19 |
| - image-id: |
20 |
| - description: Docker image ID |
21 |
| - value: ${{ steps.get-image-id.outputs.id }} |
22 |
| - |
23 | 18 | runs:
|
24 | 19 | using: composite
|
25 | 20 | steps:
|
26 |
| - - name: Generate ID file path |
27 |
| - id: id-file |
28 |
| - shell: bash |
29 |
| - run: printf "::set-output name=path::%s/iidfile_%s_$RANDOM" ${{ runner.temp }} $(date +%s) |
30 |
| - |
31 |
| - - name: Build image |
32 |
| - shell: bash |
| 21 | + - shell: bash |
33 | 22 | env:
|
34 | 23 | DOCKER_BUILDKIT: 1
|
35 |
| - run: | |
36 |
| - docker build \ |
37 |
| - --iidfile=${{ steps.id-file.outputs.path }} \ |
38 |
| - --target=${{ inputs.target }} \ |
39 |
| - --build-arg COMMIT_SHA=$(git rev-parse --short HEAD) \ |
40 |
| - ${{ inputs.docker-args }} ${{ inputs.path }} |
41 |
| -
|
42 |
| - - name: Get image ID |
43 |
| - id: get-image-id |
44 |
| - shell: bash |
45 |
| - run: | |
46 |
| - printf "::set-output name=id::%s" $(cat ${{ steps.id-file.outputs.path }}) |
47 |
| - rm -f ${{ steps.id-file.outputs.path }} |
48 |
| -
|
49 |
| - - name: Tag image |
50 |
| - shell: bash |
51 |
| - run: | |
52 |
| - if [ -n "${{ inputs.tag }}" ] |
53 |
| - then |
54 |
| - docker tag ${{ steps.get-image-id.outputs.id }} ${{ inputs.tag }} |
55 |
| - fi |
| 24 | + run: > |
| 25 | + docker build |
| 26 | + --ssh default |
| 27 | + --tag ${{ inputs.tag }} |
| 28 | + --target ${{ inputs.target }} |
| 29 | + --build-arg COMMIT_SHA=${{ github.sha }} |
| 30 | + ${{ inputs.docker-build-extra-args }} ${{ inputs.path }} |
0 commit comments