|
| 1 | +# Ensures that the local development dockerfile builds properly. |
| 2 | +# |
| 3 | +# The resulting Docker image is discarded. |
1 | 4 | name: Docker |
2 | 5 |
|
3 | 6 | on: |
|
12 | 15 | - 'Cargo.lock' |
13 | 16 | - 'Dockerfile' |
14 | 17 |
|
| 18 | +env: |
| 19 | + DOCKER_UNOPTIMIZED: "1" |
| 20 | + |
15 | 21 | jobs: |
16 | 22 | docker: |
17 | 23 | runs-on: ubuntu-latest |
18 | 24 | steps: |
19 | 25 | - uses: actions/checkout@v1 |
20 | | - - run: make docker |
| 26 | + |
| 27 | + # Create a build image on a Linkerd build host. |
| 28 | + - name: Setup (Origin) |
| 29 | + if: '!github.event.pull_request.head.repo.fork' |
| 30 | + run: | |
| 31 | + mkdir -p ~/.ssh |
| 32 | + # Create an identity file and protect before writing contents to it. |
| 33 | + touch ~/.ssh/id && chmod 600 ~/.ssh/id |
| 34 | + echo "${{ secrets.DOCKER_PRIVATE_KEY }}" >~/.ssh/id |
| 35 | + # Use well-known public keys for the host to prevent middlemen. |
| 36 | + echo "${{ secrets.DOCKER_KNOWN_HOSTS }}" >~/.ssh/known_hosts |
| 37 | + # Configure host with ServerAliveInterval to ensure that the client |
| 38 | + # stays alive even when the server is busy emitting nothing. |
| 39 | + # ServerAliveCountMax ensures that server responds to these pings |
| 40 | + # within ~5 minutes. |
| 41 | + ( |
| 42 | + echo "Host linkerd-docker" |
| 43 | + echo " User github" |
| 44 | + echo " Hostname ${{ secrets.DOCKER_ADDRESS }}" |
| 45 | + echo " IdentityFile ~/.ssh/id" |
| 46 | + echo " BatchMode yes" |
| 47 | + echo " ServerAliveInterval 60" |
| 48 | + echo " ServerAliveCountMax 5" |
| 49 | + ) >~/.ssh/config |
| 50 | + # Confirm that the SSH configuration works. |
| 51 | + ssh linkerd-docker docker version |
| 52 | +
|
| 53 | + - name: Docker (Origin) |
| 54 | + if: '!github.event.pull_request.head.repo.fork' |
| 55 | + env: |
| 56 | + DOCKER_HOST: "ssh://linkerd-docker" |
| 57 | + run: | |
| 58 | + export DOCKER_TAG="proxy-ci:$(dd bs=64 count=1 if=/dev/urandom status=none | tr -dc 'a-zA-Z0-9')" |
| 59 | + make docker |
| 60 | + docker image rm -f "$DOCKER_TAG" |
| 61 | +
|
| 62 | + - name: Docker (Fork) |
| 63 | + if: github.event.pull_request.head.repo.fork |
| 64 | + run: make docker |
0 commit comments