Add docker images (#5)
This commit is contained in:
parent
1a477790c4
commit
aa3435ee7b
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@ -0,0 +1 @@
|
||||
target
|
44
.github/workflows/container-stable.yaml
vendored
44
.github/workflows/container-stable.yaml
vendored
@ -5,8 +5,6 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "src/**"
|
||||
|
||||
jobs:
|
||||
containerization:
|
||||
@ -26,15 +24,13 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@master
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.CR_PAT }}
|
||||
|
||||
- name: Build
|
||||
- name: Build base
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
@ -43,8 +39,42 @@ jobs:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/allanger/${{ env.GITHUB_REPOSITORY }}:stable
|
||||
ghcr.io/allanger/${{ env.GITHUB_REPOSITORY }}:latest
|
||||
ghcr.io/${{ github.repository }}-base:latest
|
||||
labels: |
|
||||
action_id=${{ github.action }}
|
||||
action_link=${{ env.LINK }}
|
||||
actor=${{ github.actor }}
|
||||
sha=${{ github.sha }}
|
||||
ref=${{ github.ref }}
|
||||
- name: Build helmfile
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: ./dockerfiles
|
||||
file: ./dockerfiles/Dockerfile-helmfile
|
||||
platforms: linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository }}-helmfile:latest
|
||||
ghcr.io/${{ github.repository }}-helmfile:stable
|
||||
labels: |
|
||||
action_id=${{ github.action }}
|
||||
action_link=${{ env.LINK }}
|
||||
actor=${{ github.actor }}
|
||||
sha=${{ github.sha }}
|
||||
ref=${{ github.ref }}
|
||||
|
||||
- name: Build argo
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: ./dockerfiles
|
||||
file: ./dockerfiles/Dockerfile-argo
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository }}-argo:latest
|
||||
ghcr.io/${{ github.repository }}-argo:stable
|
||||
labels: |
|
||||
action_id=${{ github.action }}
|
||||
action_link=${{ env.LINK }}
|
||||
|
41
.github/workflows/container-version.yaml
vendored
41
.github/workflows/container-version.yaml
vendored
@ -1,5 +1,5 @@
|
||||
---
|
||||
name: "Version container"
|
||||
name: "Versioned container"
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -27,15 +27,13 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@master
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.CR_PAT }}
|
||||
|
||||
- name: Build
|
||||
- name: Build base
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
@ -44,7 +42,40 @@ jobs:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/allanger/${{ env.GITHUB_REPOSITORY }}:${{ env.TAG }}
|
||||
ghcr.io/${{ github.repository }}-base:${{ env.TAG }}
|
||||
labels: |
|
||||
action_id=${{ github.action }}
|
||||
action_link=${{ env.LINK }}
|
||||
actor=${{ github.actor }}
|
||||
sha=${{ github.sha }}
|
||||
ref=${{ github.ref }}
|
||||
- name: Build helmfile
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: ./dockerfiles
|
||||
file: ./dockerfiles/Dockerfile-helmfile
|
||||
platforms: linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository }}-helmfile:${{ env.TAG }}
|
||||
labels: |
|
||||
action_id=${{ github.action }}
|
||||
action_link=${{ env.LINK }}
|
||||
actor=${{ github.actor }}
|
||||
sha=${{ github.sha }}
|
||||
ref=${{ github.ref }}
|
||||
|
||||
- name: Build argo
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: ./dockerfiles
|
||||
file: ./dockerfiles/Dockerfile-argo
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository }}-argo:${{ env.TAG }}
|
||||
labels: |
|
||||
action_id=${{ github.action }}
|
||||
action_link=${{ env.LINK }}
|
||||
|
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM rust:1.66.1-alpine3.17 as builder
|
||||
WORKDIR /src
|
||||
RUN apk update && apk add --no-cache gcc musl-dev
|
||||
COPY ./ .
|
||||
RUN cargo build --release
|
||||
|
||||
FROM alpine:3.17.1
|
||||
COPY --from=builder /src/target/release/cdh /bin/cdh
|
||||
WORKDIR /workdir
|
||||
ENTRYPOINT ["/bin/cdh"]
|
11
dockerfiles/Dockerfile-argo
Normal file
11
dockerfiles/Dockerfile-argo
Normal file
@ -0,0 +1,11 @@
|
||||
FROM ghcr.io/allanger/dumb-downloader as builder
|
||||
ARG ARGOCD_VERSION=v2.5.10
|
||||
ENV RUST_LOG=info
|
||||
RUN mkdir /out
|
||||
RUN dudo -l "https://github.com/argoproj/argo-cd/releases/download/{{ version }}/argocd-{{ os }}-{{ arch }}" -i /tmp/argocd -p $ARGOCD_VERSION
|
||||
RUN mv /tmp/argocd /out/argocd && chmod +x /out/argocd
|
||||
|
||||
FROM ghcr.io/allanger/check-da-helm-base
|
||||
COPY --from=builder /out/ /usr/bin
|
||||
RUN apk update --no-cache && apk add --no-cache jq bash
|
||||
ENTRYPOINT ["cdh"]
|
16
dockerfiles/Dockerfile-helmfile
Normal file
16
dockerfiles/Dockerfile-helmfile
Normal file
@ -0,0 +1,16 @@
|
||||
FROM ghcr.io/allanger/dumb-downloader as builder
|
||||
RUN apt-get update -y && apt-get install tar -y
|
||||
ARG HELM_VERSION=v3.10.3
|
||||
ARG HELMFILE_VERSION=0.150.0
|
||||
ENV RUST_LOG=info
|
||||
RUN dudo -l "https://github.com/helmfile/helmfile/releases/download/v{{ version }}/helmfile_{{ version }}_{{ os }}_{{ arch }}.tar.gz" -i /tmp/helmfile -p $HELMFILE_VERSION
|
||||
RUN dudo -l "https://get.helm.sh/helm-{{ version }}-{{ os }}-{{ arch }}.tar.gz" -i /tmp/helm.tar.gz -p $HELM_VERSION
|
||||
RUN tar -xf /tmp/helm.tar.gz -C /tmp && rm -f /tmp/helm.tar.gz
|
||||
RUN mkdir /out && for bin in `find /tmp | grep helm`; do cp $bin /out/; done
|
||||
RUN chmod +x /out/helm
|
||||
RUN chmod +x /out/helmfile
|
||||
|
||||
FROM ghcr.io/allanger/check-da-helm-base
|
||||
COPY --from=builder /out/ /usr/bin
|
||||
RUN apk update --no-cache && apk add --no-cache jq bash
|
||||
ENTRYPOINT ["cdh"]
|
15
scripts/download_for_arch.sh
Executable file
15
scripts/download_for_arch.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
case $(uname -m) in
|
||||
"arm64"|"aarch64")
|
||||
PLATFORM="arm64"
|
||||
;;
|
||||
"x86_64")
|
||||
PLATFORM="amd64"
|
||||
;;
|
||||
*)
|
||||
echo "Unsuported target"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
echo "Downloading $2 from $1"
|
||||
curl -LJO $1 $2
|
@ -8,13 +8,15 @@ use std::{borrow::Borrow, io::Result, process::Command};
|
||||
|
||||
pub(crate) struct Helmfile {
|
||||
path: String,
|
||||
env: String,
|
||||
}
|
||||
|
||||
impl Connector for Helmfile {
|
||||
fn get_app(&self) -> Result<Vec<types::HelmChart>> {
|
||||
let cmd: String = format!(
|
||||
"helmfile -f {} list --output json | jq '[.[] | {{chart: .name, version: .version}}]'",
|
||||
self.path
|
||||
"helmfile -f {} -e {} list --output json | jq '[.[] | {{chart: .name, version: .version}}]'",
|
||||
self.path,
|
||||
self.env
|
||||
)
|
||||
.to_string();
|
||||
|
||||
@ -35,7 +37,7 @@ impl Connector for Helmfile {
|
||||
}
|
||||
}
|
||||
fn sync_repos(&self) -> Result<()> {
|
||||
let cmd: String = format!("helmfile -f {} sync", self.path);
|
||||
let cmd: String = format!("helmfile -f {} -e {} sync", self.path, self.env);
|
||||
Command::new("bash")
|
||||
.arg("-c")
|
||||
.arg(cmd)
|
||||
@ -47,7 +49,7 @@ impl Connector for Helmfile {
|
||||
type ConnectorType = Helmfile;
|
||||
}
|
||||
impl Helmfile {
|
||||
pub(crate) fn init(path: String) -> Self {
|
||||
Self { path: path }
|
||||
pub(crate) fn init(path: String, env: String) -> Self {
|
||||
Self {path, env}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,9 @@ struct Args {
|
||||
/// Path to the helmfile
|
||||
#[clap(short, long, value_parser, default_value = "./")]
|
||||
path: String,
|
||||
/// Pass an environment to the helmfile
|
||||
#[arg(long, required = false, default_value = "default")]
|
||||
helmfile_environment: String,
|
||||
/// Should execution be failed if you have outdated charts
|
||||
#[clap(short, long, action, default_value_t = false, env = "OUTDATED_FAIL")]
|
||||
outdated_fail: bool,
|
||||
@ -88,7 +91,7 @@ fn main() {
|
||||
let charts = match args.kind {
|
||||
Kinds::Argo => Argo::init().get_app(),
|
||||
Kinds::Helm => Helm::init().get_app(),
|
||||
Kinds::Helmfile => Helmfile::init(args.path.clone()).get_app(),
|
||||
Kinds::Helmfile => Helmfile::init(args.path.clone(), args.helmfile_environment.clone()).get_app(),
|
||||
}
|
||||
.unwrap();
|
||||
|
||||
@ -97,7 +100,7 @@ fn main() {
|
||||
let res = match args.kind {
|
||||
Kinds::Argo => Argo::init().sync_repos(),
|
||||
Kinds::Helm => Helm::init().sync_repos(),
|
||||
Kinds::Helmfile => Helmfile::init(args.path).sync_repos(),
|
||||
Kinds::Helmfile => Helmfile::init(args.path, args.helmfile_environment).sync_repos(),
|
||||
};
|
||||
match res {
|
||||
Ok(_) => info!("helm repos are synced"),
|
||||
|
Reference in New Issue
Block a user