Skip to content

Commit

Permalink
feat(release): distribute werf images for linux/arm64 plarform
Browse files Browse the repository at this point in the history
Signed-off-by: Fral738 <frolov1998kc@mail.ru>

feat(build): add werf version check, rename args

Signed-off-by: Fral738 <frolov1998kc@mail.ru>

chore(werf-in-image): use actual trdl_channels.yaml

Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
  • Loading branch information
Fral738 authored and alexey-igrychev committed Oct 25, 2024
1 parent d3c67b8 commit f653db8
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 46 deletions.
9 changes: 9 additions & 0 deletions scripts/werf-in-image/artifact.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG distro_image
ARG source_image

FROM ${source_image} as source_image

FROM ${distro_image}
ARG source
ARG destination
COPY --from=source_image ${source} ${destination}
33 changes: 33 additions & 0 deletions scripts/werf-in-image/trdl.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM alpine
ARG groups
ARG channels
ARG trdl_channels_yaml

RUN apk add curl gnupg

RUN curl -sSLO "https://tuf.trdl.dev/targets/releases/0.7.0/linux-amd64/bin/trdl" -O "https://tuf.trdl.dev/targets/signatures/0.7.0/linux-amd64/bin/trdl.sig" && \
curl -sSL https://trdl.dev/trdl.asc | gpg --import && \
gpg --verify trdl.sig trdl && \
rm trdl.sig && \
chmod +x ./trdl && \
mv trdl /usr/local/bin/trdl && \
trdl add werf https://tuf.werf.io 1 b7ff6bcbe598e072a86d595a3621924c8612c7e6dc6a82e919abe89707d7e3f468e616b5635630680dd1e98fc362ae5051728406700e6274c5ed1ad92bea52a2 && \
wget https://github.com/mikefarah/yq/releases/download/v4.24.2/yq_linux_amd64 -O /usr/local/bin/yq && \
chmod +x /usr/local/bin/yq

RUN for group in ${groups}; do \
for channel in ${channels}; do \
while true ; do \
echo "Perform trdl update for werf $group $channel ..." &&\
trdl update werf $group $channel &&\
. $(trdl use werf $group $channel) &&\
REQUIRED_VERSION=$(cat ${trdl_channels_yaml} | yq -e ".groups[] | select(.name == \"$group\") | .channels[] | select(.name == \"$channel\") | .version" -) &&\
DOWNLOADED_VERSION=$(werf version | sed -e 's|^v||') &&\
echo "werf $group $channel: required version $REQUIRED_VERSION, downloaded version $DOWNLOADED_VERSION" &&\
[[ "$REQUIRED_VERSION" != "$DOWNLOADED_VERSION" ]] || break &&\
echo "Version mismatch! Will retry update" &&\
sleep 1; \
done; \
cp $(trdl bin-path werf $group $channel)/werf /usr/local/bin/werf-$group-$channel; \
done \
done
77 changes: 31 additions & 46 deletions scripts/werf-in-image/werf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,20 @@ project: werf-in-image
configVersion: 1
{{- $_ := set $ "Groups" (list "1.2" "2") }}
{{- $_ := set $ "Channels" (list "alpha" "beta" "ea" "stable" "rock-solid") }}
build:
platform:
- linux/amd64
- linux/arm64

---
image: trdl
from: alpine
shell:
beforeInstall:
- apk add curl gnupg
- curl -sSLO "https://tuf.trdl.dev/targets/releases/0.7.0/linux-amd64/bin/trdl" -O "https://tuf.trdl.dev/targets/signatures/0.7.0/linux-amd64/bin/trdl.sig"
- curl -sSL https://trdl.dev/trdl.asc | gpg --import
- gpg --verify trdl.sig trdl
- rm trdl.sig
- chmod +x ./trdl
- mv trdl /usr/local/bin/trdl
- trdl add werf https://tuf.werf.io 1 b7ff6bcbe598e072a86d595a3621924c8612c7e6dc6a82e919abe89707d7e3f468e616b5635630680dd1e98fc362ae5051728406700e6274c5ed1ad92bea52a2
- wget https://github.com/mikefarah/yq/releases/download/v4.16.1/yq_linux_amd64 -O /usr/local/bin/yq
- chmod +x /usr/local/bin/yq
install:
{{- range $_, $group := $.Groups -}}
{{- range $_, $channel := $.Channels }}
- |
while true ; do
echo "Perform trdl update for werf {{ $group }} {{ $channel }} ..."
trdl update werf {{ $group }} {{ $channel }}
. $(trdl use werf {{ $group }} {{ $channel }})
REQUIRED_VERSION=$(cat /trdl_channels.yaml | yq e '.groups[] | select(.name == "{{ $group }}") | .channels[] | select(.name == "{{ $channel }}") | .version' -)
DOWNLOADED_VERSION=$(werf version | sed -e 's|^v||')
echo "werf {{ $group }} {{ $channel }}: required version $REQUIRED_VERSION, downloaded version $DOWNLOADED_VERSION"
[[ "$REQUIRED_VERSION" != "$DOWNLOADED_VERSION" ]] || break
echo "Version mismatch! Will retry update"
sleep 1
done
- cp $(trdl bin-path werf {{ $group }} {{ $channel }})/werf /usr/local/bin/werf-{{ $group }}-{{ $channel }}
{{- end -}}
{{- end }}
git:
- add: /trdl_channels.yaml
to: /trdl_channels.yaml
stageDependencies:
install: [""]
dockerfile: ./trdl.Dockerfile
final: false
args:
groups: 1.2 2
channels: alpha beta ea stable rock-solid
trdl_channels_yaml: |
{{ .Files.Get "../../trdl_channels.yaml" | nindent 4 }}

{{- range $_, $distro := list "alpine" "ubuntu" "centos" "fedora" }}
---
Expand All @@ -51,12 +26,17 @@ dockerfile: "./{{ $distro }}.Dockerfile"
{{- range $_, $channel := $.Channels }}
---
image: "{{ $group }}-{{ $channel }}-{{ $distro }}"
fromImage: "{{ $distro }}"
import:
dockerfile: ./artifact.Dockerfile
dependencies:
- image: trdl
after: install
add: "/usr/local/bin/werf-{{ $group }}-{{ $channel }}"
to: /usr/local/bin/werf
imports:
- type: ImageName
targetBuildArg: source_image

args:
distro_image: "{{ $distro }}"
source: "/usr/local/bin/werf-{{ $group }}-{{ $channel }}"
destination: "/usr/local/bin/werf"
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -71,12 +51,17 @@ dockerfile: "./argocd-cmp-sidecar-{{ $distro }}.Dockerfile"
{{- range $_, $channel := $.Channels }}
---
image: "argocd-cmp-sidecar-{{ $group }}-{{ $channel }}-{{ $distro }}"
fromImage: "argocd-cmp-sidecar-{{ $distro }}"
import:
dockerfile: ./artifact.Dockerfile
dependencies:
- image: trdl
after: install
add: "/usr/local/bin/werf-{{ $group }}-{{ $channel }}"
to: /usr/local/bin/werf
imports:
- type: ImageName
targetBuildArg: source_image

args:
distro_image: "{{ $distro }}"
source: "/usr/local/bin/werf-{{ $group }}-{{ $channel }}"
destination: "/usr/local/bin/werf"
{{- end }}
{{- end }}
{{- end }}

0 comments on commit f653db8

Please sign in to comment.