Skip to content

Commit 5307bc3

Browse files
authored
Add GCP flavor of the Docker image (#11)
--------- Signed-off-by: peterdeme <snypox@gmail.com>
1 parent 1dc68c8 commit 5307bc3

File tree

4 files changed

+73
-17
lines changed

4 files changed

+73
-17
lines changed

.github/workflows/build.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
fail-fast: false
1717
max-parallel: 2 # ECR has pretty aggressive rate limiting 😪
1818
matrix:
19-
folder: [base, aws]
19+
folder: [base, aws, gcp]
2020
arch: [amd64, arm64]
2121
env:
2222
IMAGE_NAME: ansible-test-${{ matrix.folder }}-${{ matrix.arch }}:${{ github.sha }}
@@ -25,16 +25,16 @@ jobs:
2525
uses: actions/checkout@main
2626

2727
- name: Set up QEMU
28-
uses: docker/setup-qemu-action@v2
28+
uses: docker/setup-qemu-action@v3
2929
if: matrix.arch == 'arm64'
3030
with:
3131
platforms: linux/arm64
3232

3333
- name: Set up Docker Buildx
34-
uses: docker/setup-buildx-action@v2
34+
uses: docker/setup-buildx-action@v3
3535

3636
- name: Build the ${{ matrix.folder }} image
37-
uses: docker/build-push-action@v3
37+
uses: docker/build-push-action@v5
3838
with:
3939
context: ${{ matrix.folder }}
4040
build-args: |
@@ -54,3 +54,7 @@ jobs:
5454
if [ "${{ matrix.folder }}" == "aws" ]; then
5555
docker run --rm ${{ env.IMAGE_NAME }} sh -c "python3 -c \"import boto3; print(boto3.__version__)\""
5656
fi
57+
58+
if [ "${{ matrix.folder }}" == "gcp" ]; then
59+
docker run --rm ${{ env.IMAGE_NAME }} sh -c "python3 -c \"import google.auth; print(google.auth.__version__)\""
60+
fi

.github/workflows/deploy.yml

+53-12
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ jobs:
2525
uses: actions/checkout@main
2626

2727
- name: Set up QEMU
28-
uses: docker/setup-qemu-action@v2
28+
uses: docker/setup-qemu-action@v3
2929
with:
3030
platforms: linux/arm64
3131

3232
- name: Configure AWS credentials
33-
uses: aws-actions/configure-aws-credentials@v2
33+
uses: aws-actions/configure-aws-credentials@v4
3434
with:
3535
aws-region: ${{ env.AWS_REGION }}
3636
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
@@ -46,17 +46,17 @@ jobs:
4646
REPOSITORY_PATH: ${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}
4747

4848
- name: Log in to GitHub registry
49-
uses: docker/login-action@v1
49+
uses: docker/login-action@v3
5050
with:
5151
registry: ghcr.io
5252
username: ${{ github.actor }}
5353
password: ${{ secrets.GITHUB_TOKEN }}
5454

5555
- name: Set up Docker Buildx
56-
uses: docker/setup-buildx-action@v2
56+
uses: docker/setup-buildx-action@v3
5757

5858
- name: Build and push the image
59-
uses: docker/build-push-action@v3
59+
uses: docker/build-push-action@v5
6060
with:
6161
context: base
6262
platforms: linux/amd64,linux/arm64
@@ -74,15 +74,12 @@ jobs:
7474
uses: actions/checkout@main
7575

7676
- name: Set up QEMU
77-
uses: docker/setup-qemu-action@v2
77+
uses: docker/setup-qemu-action@v3
7878
with:
7979
platforms: linux/arm64
8080

81-
- name: Set env
82-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
83-
8481
- name: Configure AWS credentials
85-
uses: aws-actions/configure-aws-credentials@v2
82+
uses: aws-actions/configure-aws-credentials@v4
8683
with:
8784
aws-region: ${{ env.AWS_REGION }}
8885
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
@@ -98,10 +95,10 @@ jobs:
9895
REPOSITORY_PATH: ${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_AWS }}
9996

10097
- name: Set up Docker Buildx
101-
uses: docker/setup-buildx-action@v2
98+
uses: docker/setup-buildx-action@v3
10299

103100
- name: Build and push the image
104-
uses: docker/build-push-action@v3
101+
uses: docker/build-push-action@v5
105102
with:
106103
build-args: |
107104
REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}
@@ -110,3 +107,47 @@ jobs:
110107
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }}
111108
tags: |
112109
${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_AWS }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
110+
111+
gcp:
112+
needs: base
113+
name: Build and deploy the alpine base GCP image
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Check out repository code
117+
uses: actions/checkout@main
118+
119+
- name: Set up QEMU
120+
uses: docker/setup-qemu-action@v3
121+
with:
122+
platforms: linux/arm64
123+
124+
- name: Configure AWS credentials
125+
uses: aws-actions/configure-aws-credentials@v4
126+
with:
127+
aws-region: ${{ env.AWS_REGION }}
128+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
129+
role-duration-seconds: 900
130+
131+
- name: Install latest AWS CLI
132+
id: install-aws-cli
133+
uses: unfor19/install-aws-cli-action@v1
134+
135+
- name: Login to Amazon ECR
136+
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${REPOSITORY_PATH}
137+
env:
138+
REPOSITORY_PATH: ${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_GCP }}
139+
140+
- name: Set up Docker Buildx
141+
uses: docker/setup-buildx-action@v3
142+
143+
- name: Build and push the image
144+
uses: docker/build-push-action@v5
145+
with:
146+
build-args: |
147+
REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}
148+
context: aws
149+
platforms: linux/amd64,linux/arm64
150+
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }}
151+
tags: |
152+
${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_GCP }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
153+

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ to use `public.ecr.aws/spacelift/runner-ansible` as the runner image for the sta
1212
The image is pushed to the `public.ecr.aws/spacelift/runner-ansible` public repository. It is also pushed to the
1313
`ghcr.io/spacelift-io/runner-ansible` repository as a backup in case of issues with ECR.
1414

15+
Altogether we have 3 flavors of the image:
16+
17+
- `public.ecr.aws/spacelift/runner-ansible` - built on top of the [Spacelift Terraform runner image](https://github.com/spacelift-io/runner-terraform), with Ansible installed.
18+
- `public.ecr.aws/spacelift/runner-ansible-aws` - built on top of `runner-ansible`, with `boto3` installed.
19+
- `public.ecr.aws/spacelift/runner-ansible-gcp` - built on top of `runner-ansible`, with `google-auth` installed.
20+
1521
## Branch Model
1622

1723
This repository uses two main branches:
1824

1925
- `main` - contains the production version of the runner image.
2026
- `future` - used to test development changes.
2127

22-
Pushes to main deploy to the latest tag, whereas pushes to future deploy to the future tag. This
28+
Pushes to main deploy to the `latest` tag, whereas pushes to future deploy to the `future` tag. This
2329
means that to use the development version you can use the `public.ecr.aws/spacelift/runner-ansible:future` image.
2430

2531
## Development

gcp/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ARG REPOSITORY_BASE_PATH
2+
3+
FROM ${REPOSITORY_BASE_PATH}:latest
4+
5+
RUN pip install requests google-auth

0 commit comments

Comments
 (0)