Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ fi \
FROM gcr.io/distroless/cc AS final
COPY --from=build /app/target/final/release/multi-arch-container-rust .

ARG GIT_REPO
ENV APP_GIT_REPO=$GIT_REPO
ARG GIT_TAG
ENV APP_GIT_TAG=$GIT_TAG
ARG GIT_REPOSITORY
ENV APP_GIT_REPOSITORY=$GIT_REPOSITORY
ARG GIT_BRANCH
ENV APP_GIT_BRANCH=$GIT_BRANCH
ARG GIT_COMMIT
ENV APP_GIT_COMMIT=$GIT_COMMIT
ARG GIT_TAG
ENV APP_GIT_TAG=$GIT_TAG

ARG GITHUB_WORKFLOW
ENV APP_GITHUB_WORKFLOW=$GITHUB_WORKFLOW
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ First clone the repository (ideally by opening it as [vscode devcontainer](https
#!/bin/sh

#set variables to emulate running in the workflow/pipeline
GIT_REPO=$(basename `git rev-parse --show-toplevel`)
GIT_REPOSITORY=$(basename `git rev-parse --show-toplevel`)
GIT_BRANCH=$(git branch --show-current)
GIT_COMMIT=$(git rev-parse HEAD)
GIT_TAG="latest-dev"
GITHUB_WORKFLOW="n/a"
GITHUB_RUN_ID=0
GITHUB_RUN_NUMBER=0
IMAGE_NAME="$GIT_REPO:$GIT_TAG"
IMAGE_NAME="$GIT_REPOSITORY:$GIT_TAG"
#Note: you cannot export a buildx container image into a local docker instance with multiple architecture manifests so for local testing you have to select just a single architecture.
#$PLATFORM="linux/amd64,linux/arm64,linux/arm/v7"
PLATFORM="linux/amd64"
Expand All @@ -83,13 +83,12 @@ docker buildx create --name multiarchcontainerrust --use
#https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md
docker buildx build \
-t $IMAGE_NAME \
-t "$GIT_REPO:latest" \
--label "GITHUB_RUN_ID=$GITHUB_RUN_ID" \
--label "IMAGE_NAME=$IMAGE_NAME" \
--build-arg GIT_REPO=$GIT_REPO \
--build-arg GIT_TAG=$GIT_TAG \
--build-arg GIT_REPOSITORY=$GIT_REPOSITORY \
--build-arg GIT_BRANCH=$GIT_BRANCH \
--build-arg GIT_COMMIT=$GIT_COMMIT \
--build-arg GIT_TAG=$GIT_TAG \
--build-arg GITHUB_WORKFLOW=$GITHUB_WORKFLOW \
--build-arg GITHUB_RUN_ID=$GITHUB_RUN_ID \
--build-arg GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER \
Expand All @@ -100,13 +99,13 @@ docker buildx build \

#Preview matching images
#https://docs.docker.com/engine/reference/commandline/images/
docker images $GIT_REPO
docker images $GIT_REPOSITORY

read -p "Hit ENTER to run the '$IMAGE_NAME' image..."

#Run the multi-architecture container image
#https://docs.docker.com/engine/reference/commandline/run/
docker run --rm -it --name $GIT_REPO $IMAGE_NAME
docker run --rm -it --name $GIT_REPOSITORY $IMAGE_NAME

#userprofile=$(wslpath "$(wslvar USERPROFILE)")
#export KUBECONFIG=$userprofile/.kube/config
Expand Down
15 changes: 7 additions & 8 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ $ErrorActionPreference = "Stop"

#set variables to emulate running in the workflow/pipeline
$REPO_ROOT = git rev-parse --show-toplevel
$GIT_REPO = $REPO_ROOT | Split-Path -Leaf
$GIT_TAG = "latest-dev"
$GIT_REPOSITORY = $REPO_ROOT | Split-Path -Leaf
$GIT_BRANCH = $(git branch --show-current)
$GIT_COMMIT = $(git rev-parse HEAD)
$GIT_TAG = "latest-dev"
$GITHUB_WORKFLOW = "n/a"
$GITHUB_RUN_ID = 0
$GITHUB_RUN_NUMBER = 0
$IMAGE_NAME = "$($GIT_REPO):$($GIT_TAG)"
$IMAGE_NAME = "$($GIT_REPOSITORY):$($GIT_TAG)"
#Note: you cannot export a buildx container image into a local docker instance with multiple architecture manifests so for local testing you have to select just a single architecture.
#$PLATFORM = "linux/amd64,linux/arm64,linux/arm/v7"
$PLATFORM = "linux/amd64"
Expand All @@ -23,11 +23,10 @@ docker buildx create --name multiarchcontainerrust --use
#https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md
docker buildx build `
-t $IMAGE_NAME `
-t "$($GIT_REPO):latest" `
--build-arg GIT_REPO=$GIT_REPO `
--build-arg GIT_TAG=$GIT_TAG `
--build-arg GIT_REPOSITORY=$GIT_REPOSITORY `
--build-arg GIT_BRANCH=$GIT_BRANCH `
--build-arg GIT_COMMIT=$GIT_COMMIT `
--build-arg GIT_TAG=$GIT_TAG `
--build-arg GITHUB_WORKFLOW=$GITHUB_WORKFLOW `
--build-arg GITHUB_RUN_ID=$GITHUB_RUN_ID `
--build-arg GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER `
Expand All @@ -38,13 +37,13 @@ docker buildx build `

#Preview matching images
#https://docs.docker.com/engine/reference/commandline/images/
docker images $GIT_REPO
docker images $GIT_REPOSITORY

Write-Host "Hit ENTER to run the '$IMAGE_NAME' image..."
pause

#Run the multi-architecture container image
#https://docs.docker.com/engine/reference/commandline/run/
docker run --rm -it --name $GIT_REPO $IMAGE_NAME
docker run --rm -it --name $GIT_REPOSITORY $IMAGE_NAME

#kubectl run -i --tty --attach multi-arch-container-rust --image=ghcr.io/f2calv/multi-arch-container-rust --image-pull-policy='Always'
13 changes: 6 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/sh

#set variables to emulate running in the workflow/pipeline
GIT_REPO=$(basename `git rev-parse --show-toplevel`)
GIT_REPOSITORY=$(basename `git rev-parse --show-toplevel`)
GIT_BRANCH=$(git branch --show-current)
GIT_COMMIT=$(git rev-parse HEAD)
GIT_TAG="latest-dev"
GITHUB_WORKFLOW="n/a"
GITHUB_RUN_ID=0
GITHUB_RUN_NUMBER=0
IMAGE_NAME="$GIT_REPO:$GIT_TAG"
IMAGE_NAME="$GIT_REPOSITORY:$GIT_TAG"
#Note: you cannot export a buildx container image into a local docker instance with multiple architecture manifests so for local testing you have to select just a single architecture.
#$PLATFORM="linux/amd64,linux/arm64,linux/arm/v7"
PLATFORM="linux/amd64"
Expand All @@ -21,13 +21,12 @@ docker buildx create --name multiarchcontainerrust --use
#https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md
docker buildx build \
-t $IMAGE_NAME \
-t "$GIT_REPO:latest" \
--label "GITHUB_RUN_ID=$GITHUB_RUN_ID" \
--label "IMAGE_NAME=$IMAGE_NAME" \
--build-arg GIT_REPO=$GIT_REPO \
--build-arg GIT_TAG=$GIT_TAG \
--build-arg GIT_REPOSITORY=$GIT_REPOSITORY \
--build-arg GIT_BRANCH=$GIT_BRANCH \
--build-arg GIT_COMMIT=$GIT_COMMIT \
--build-arg GIT_TAG=$GIT_TAG \
--build-arg GITHUB_WORKFLOW=$GITHUB_WORKFLOW \
--build-arg GITHUB_RUN_ID=$GITHUB_RUN_ID \
--build-arg GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER \
Expand All @@ -38,13 +37,13 @@ docker buildx build \

#Preview matching images
#https://docs.docker.com/engine/reference/commandline/images/
docker images $GIT_REPO
docker images $GIT_REPOSITORY

read -p "Hit ENTER to run the '$IMAGE_NAME' image..."

#Run the multi-architecture container image
#https://docs.docker.com/engine/reference/commandline/run/
docker run --rm -it --name $GIT_REPO $IMAGE_NAME
docker run --rm -it --name $GIT_REPOSITORY $IMAGE_NAME

#userprofile=$(wslpath "$(wslvar USERPROFILE)")
#export KUBECONFIG=$userprofile/.kube/config
Expand Down
15 changes: 15 additions & 0 deletions charts/multi-arch-container-rust/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ spec:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
env:
- name: "GIT_REPOSITORY"
value: {{ .Values.git.repository | default "" | quote }}
- name: "GIT_BRANCH"
value: {{ .Values.git.branch | default "" | quote }}
- name: "GIT_COMMIT"
value: {{ .Values.git.commit | default "" | quote }}
- name: "GIT_TAG"
value: {{ .Values.image.tag | default .Chart.AppVersion }}
- name: "GITHUB_WORKFLOW"
value: {{ .Values.github.workflow | default "" | quote }}
- name: "GITHUB_RUN_ID"
value: {{ .Values.github.run_id | int64 | default 0 | quote }}
- name: "GITHUB_RUN_NUMBER"
value: {{ .Values.github.run_number | int64 | default 0 | quote }}
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ async fn main() -> std::io::Result<()> {
);

log::info!(
"Git information; name '{:?}', branch '{:?}', commit '{:?}', tag '{:?}'",
app_settings.git_repo,
"Git information; repository '{:?}', branch '{:?}', commit '{:?}', tag '{:?}'",
app_settings.git_repository,
app_settings.git_branch,
app_settings.git_commit,
app_settings.git_tag,
Expand Down Expand Up @@ -66,7 +66,7 @@ fn get_configuration() -> Result<AppSettings, ConfigError> {

#[derive(Debug, serde::Deserialize)]
struct AppSettings {
git_repo: Option<String>,
git_repository: Option<String>,
git_branch: Option<String>,
git_commit: Option<String>,
git_tag: Option<String>,
Expand All @@ -79,8 +79,8 @@ impl std::fmt::Display for AppSettings {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"git_repo='{:?}', git_branch='{:?}'",
self.git_repo, self.git_branch
"git_repository='{:?}', git_branch='{:?}'",
self.git_repository, self.git_branch
)
}
}
Expand Down