|
| 1 | +name: build-and-publish-image-ssh |
| 2 | + |
| 3 | +description: "Build and publish a Docker image with SSH forwarding" |
| 4 | + |
| 5 | +inputs: |
| 6 | + file: |
| 7 | + required: true |
| 8 | + description: "Dockerfile to build" |
| 9 | + tags: |
| 10 | + required: true |
| 11 | + description: "Image tags to publish" |
| 12 | + pull: |
| 13 | + default: false |
| 14 | + required: false |
| 15 | + description: "Attempt to pull a newer version of the image (default false)" |
| 16 | + push: |
| 17 | + default: false |
| 18 | + required: false |
| 19 | + description: "Push the image to the container registry (default false)" |
| 20 | + temp: |
| 21 | + default: /tmp |
| 22 | + required: true |
| 23 | + description: "Path to temp dir" |
| 24 | + context: |
| 25 | + default: "." |
| 26 | + required: true |
| 27 | + description: "Path to image build context" |
| 28 | + platforms: |
| 29 | + default: "linux/amd64" |
| 30 | + required: false |
| 31 | + description: "Platforms to build" |
| 32 | + buildx-driver-opts: |
| 33 | + default: "" |
| 34 | + required: false |
| 35 | + description: "List of additional driver-specific options" |
| 36 | + build-args: |
| 37 | + default: "" |
| 38 | + required: false |
| 39 | + description: "Build arguments to use" |
| 40 | + registry-url: |
| 41 | + default: "" |
| 42 | + required: false |
| 43 | + description: "Address of container registry" |
| 44 | + registry-username: |
| 45 | + default: "" |
| 46 | + required: false |
| 47 | + description: "Username used to log in to the container registry" |
| 48 | + registry-password: |
| 49 | + default: "" |
| 50 | + required: false |
| 51 | + description: "Password used to log in to the container registry" |
| 52 | + AWS_ACCESS_KEY_ID: |
| 53 | + default: "" |
| 54 | + required: false |
| 55 | + description: "AWS access id for writing to the shared sccache S3 bucket" |
| 56 | + AWS_SECRET_ACCESS_KEY: |
| 57 | + default: "" |
| 58 | + required: false |
| 59 | + description: "AWS secret key for writing to the shared sccache S3 bucket" |
| 60 | + SSH_PRIVATE_KEY: |
| 61 | + default: "" |
| 62 | + required: true |
| 63 | + description: "Private SSH key for cloning private RAPIDS repositories" |
| 64 | + |
| 65 | +outputs: |
| 66 | + digest: |
| 67 | + description: "Image content-addressable identifier" |
| 68 | + value: ${{ steps.docker-build.outputs.digest }} |
| 69 | + metadata: |
| 70 | + description: "Build result metadata" |
| 71 | + value: ${{ steps.docker-build.outputs.metadata }} |
| 72 | + |
| 73 | +runs: |
| 74 | + using: composite |
| 75 | + steps: |
| 76 | + - name: Set up QEMU |
| 77 | + uses: docker/setup-qemu-action@v1 |
| 78 | + - name: Set up Docker Buildx context |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + docker context create builders |
| 82 | + - name: Set up Docker Buildx |
| 83 | + uses: docker/setup-buildx-action@v2 |
| 84 | + with: |
| 85 | + endpoint: builders |
| 86 | + buildkitd-flags: --debug |
| 87 | + driver-opts: ${{ inputs.buildx-driver-opts }} |
| 88 | + - name: Login to container registry |
| 89 | + if: inputs.push == 'true' |
| 90 | + uses: docker/login-action@v1 |
| 91 | + with: |
| 92 | + registry: ${{ inputs.registry-url }} |
| 93 | + username: ${{ inputs.registry-username }} |
| 94 | + password: ${{ inputs.registry-password }} |
| 95 | + - name: Initialize sccache_credentials |
| 96 | + shell: bash |
| 97 | + run: | |
| 98 | + echo "AWS_ACCESS_KEY_ID=${{ inputs.AWS_ACCESS_KEY_ID }}" >> ${{ inputs.temp }}/sccache_credentials |
| 99 | + echo "AWS_SECRET_ACCESS_KEY=${{ inputs.AWS_SECRET_ACCESS_KEY }}" >> ${{ inputs.temp }}/sccache_credentials |
| 100 | + - name: Set up ssh-agent |
| 101 | + uses: webfactory/ssh-agent@v0.5.4 |
| 102 | + with: |
| 103 | + ssh-private-key: ${{ inputs.SSH_PRIVATE_KEY }} |
| 104 | + - name: Build image |
| 105 | + id: docker-build |
| 106 | + uses: docker/build-push-action@v2 |
| 107 | + with: |
| 108 | + pull: ${{ inputs.pull }} |
| 109 | + push: ${{ inputs.push }} |
| 110 | + file: ${{ inputs.file }} |
| 111 | + tags: ${{ inputs.tags }} |
| 112 | + context: ${{ inputs.context }} |
| 113 | + load: ${{ inputs.push == false }} |
| 114 | + platforms: ${{ inputs.platforms }} |
| 115 | + build-args: ${{ inputs.build-args }} |
| 116 | + ssh: | |
| 117 | + default=${{ env.SSH_AUTH_SOCK }} |
| 118 | + labels: | |
| 119 | + org.opencontainers.image.vendor=NVIDIA |
| 120 | + org.opencontainers.image.source=https://github.com/rapidsai/node |
| 121 | + secret-files: | |
| 122 | + "sccache_credentials=${{ inputs.temp }}/sccache_credentials" |
| 123 | + - name: Clean up |
| 124 | + if: always() |
| 125 | + shell: bash |
| 126 | + run: | |
| 127 | + rm ${{ inputs.temp }}/sccache_credentials |
0 commit comments