Skip to content

Commit 35f756a

Browse files
author
Leonid Podolinskiy
authored
add arm init containers (#18)
* add arm init containers * update permissions in init container * add buildix and qemu steps to pipeline for multiplatform support
1 parent 2313e7b commit 35f756a

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

.github/workflows/init_container.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ jobs:
2222
strategy:
2323
matrix:
2424
agents: [
25-
{file: "agent.zip", platform: "linux"},
26-
{file: "agent-alpine.zip", platform: "alpine"}
25+
{name: "linux", file: "agent.zip", platform: "linux/amd64"},
26+
{name: "alpine", file: "agent-alpine.zip", platform: "linux/amd64"},
27+
{name: "linux-arm64", file: "agent-arm64.zip", platform: "linux/arm64"},
28+
{name: "alpine-arm64", file: "agent-alpine-arm64.zip", platform: "linux/arm64"}
2729
]
2830
runs-on: ubuntu-latest
2931
name: Build and push Docker image
@@ -45,6 +47,10 @@ jobs:
4547

4648
- uses: actions/checkout@v3
4749

50+
- name: Set up QEMU
51+
uses: docker/setup-qemu-action@v3
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v3
4854

4955
- name: Login to DockerHub
5056
if: ${{ success() }}
@@ -66,7 +72,7 @@ jobs:
6672
run: |
6773
python3 -m pip install semver
6874
existing_tags=()
69-
dockerhub_tags=$(curl -s "https://hub.docker.com/v2/namespaces/lightruncom/repositories/k8s-operator-init-java-agent-${{ matrix.agents.platform }}/tags?page_size=50" | jq -r ".results[].name")
75+
dockerhub_tags=$(curl -s "https://hub.docker.com/v2/namespaces/lightruncom/repositories/k8s-operator-init-java-agent-${{ matrix.agents.name }}/tags?page_size=50" | jq -r ".results[].name")
7076
if [[ $? -ne 0 ]] ; then
7177
echo "Failed to fetch existing tags"
7278
exit 1
@@ -82,24 +88,25 @@ jobs:
8288
echo "Comparing existing tag: $tag with new: ${{steps.set_tag.outputs.TAG_NAME}}"
8389
if [[ $(pysemver compare $tag ${{steps.set_tag.outputs.TAG_NAME}}) -ge 0 ]] ; then
8490
echo "Existing tag: $tag is greater or equal than new: ${{ inputs.release_tag }}. Skip adding latest tag"
85-
echo "DOCKER_TAGS=lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.platform }}:${{steps.set_tag.outputs.TAG_NAME}}" >> "$GITHUB_OUTPUT"
91+
echo "DOCKER_TAGS=lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.name }}:${{steps.set_tag.outputs.TAG_NAME}}" >> "$GITHUB_OUTPUT"
8692
exit 0
8793
fi
8894
done
8995
echo "Adding latest tag to ${{steps.set_tag.outputs.TAG_NAME}}"
90-
echo "DOCKER_TAGS=lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.platform }}:${{steps.set_tag.outputs.TAG_NAME}},lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.platform }}:latest" >> "$GITHUB_OUTPUT"
96+
echo "DOCKER_TAGS=lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.name }}:${{steps.set_tag.outputs.TAG_NAME}},lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.name }}:latest" >> "$GITHUB_OUTPUT"
9197
9298
- name: Download agent artifacts
9399
run: |
94100
aws s3 cp s3://${{ secrets.RELEASE_ARTIFACTS_BUCKET }}/artifacts/${{ inputs.release_tag }}/${{ matrix.agents.file }} ./lightrun-init-agent/
95101
96102
97-
- name: Build and push ${{ matrix.agents.platform }} container
103+
- name: Build and push ${{ matrix.agents.name }} container
98104
uses: docker/build-push-action@v4
99105
with:
100106
context: .
101107
file: ./lightrun-init-agent/Dockerfile
102108
push: true
109+
platforms: ${{ matrix.agents.platform }}
103110
tags: ${{steps.set_docker_tags.outputs.DOCKER_TAGS}}
104111
build-args: |
105112
FILE=${{ matrix.agents.file }}
@@ -111,6 +118,6 @@ jobs:
111118
env:
112119
SLACK_CHANNEL: devops-alerts
113120
SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff'
114-
SLACK_MESSAGE: "Tag ${{ inputs.release_tag }} | Platform ${{ matrix.agents.platform }}"
121+
SLACK_MESSAGE: "Tag ${{ inputs.release_tag }} | Platform ${{ matrix.agents.name }}"
115122
SLACK_TITLE: Init contianer build status - ${{ job.status }}
116123
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

examples/app/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=linux/amd64 openjdk:11
1+
FROM openjdk:11
22
WORKDIR /app
33
COPY PrimeMain.java /app
44
RUN javac -g PrimeMain.java

lightrun-init-agent/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=linux/amd64 alpine:latest
1+
FROM alpine:latest
22

33
ARG FILE
44

@@ -9,8 +9,9 @@ RUN unzip -o /tmp/$FILE -d /agent ;\
99
# Erase default values
1010
sed -i.bak "s|com.lightrun.secret=.*|com.lightrun.secret=|" /agent/agent.config && rm /agent/agent.config.bak && \
1111
sed -i.bak "s|pinned_certs=.*|pinned_certs=|" /agent/agent.config && rm /agent/agent.config.bak && \
12-
# In openshift UID will be dynamic per project, hence chmod and not chown
13-
chmod -R 777 /agent
12+
# In openshift UID will be dynamic per project, hence procide permissions to root group (defualt in k8s)
13+
chgrp -R 0 /agent && \
14+
chmod -R g=u /agent
1415

1516
USER 1000
1617
COPY lightrun-init-agent/update_config.sh /update_config.sh

0 commit comments

Comments
 (0)