diff --git a/.drone.yml b/.drone.yml index 5b98818..db45783 100644 --- a/.drone.yml +++ b/.drone.yml @@ -80,34 +80,14 @@ steps: - name: Sync pictures from lfs to Minio image: rclone/rclone:latest - when: - branch: - exclude: - - main environment: RCLONE_CONFIG_CONTENT: from_secret: RCLONE_CONFIG_CONTENT_PRIVATE RCLONE_CONFIG: /tmp/rclone.conf commands: - echo "$RCLONE_CONFIG_CONTENT" > $RCLONE_CONFIG - - apk update - - apk add git make - - make upload_static - - - name: Sync pictures to the main Minio bucket - image: rclone/rclone:latest - when: - branch: - - main - environment: - RCLONE_CONFIG_CONTENT: - from_secret: RCLONE_CONFIG_CONTENT_PRIVATE - RCLONE_CONFIG: /tmp/rclone.conf - commands: - - echo "$RCLONE_CONFIG_CONTENT" > $RCLONE_CONFIG - - apk update - - apk add git make - - make sync_static_with_main + - apk update && apk add git perl + - ./scripts/upload-media.pl - name: Deploy a preview ApplicationSet image: alpine/k8s:1.24.10 diff --git a/content/posts/argocd-dynamic-environment-per-branch-part-2/index.md b/content/posts/argocd-dynamic-environment-per-branch-part-2/index.md new file mode 100644 index 0000000..5127b42 --- /dev/null +++ b/content/posts/argocd-dynamic-environment-per-branch-part-2/index.md @@ -0,0 +1,53 @@ +--- +title: "Argocd Dynamic Environment per Branch Part 2" +date: 2023-03-29T17:31:20+02:00 +draft: true +ShowToc: true +cover: + image: "cover.png" + caption: "Argocd Dynamic Environment per Branch Part 2" + relative: false + responsiveImages: false +--- + +So it's been a while since the last post. And I'd like to continue the topic, because I've updated some things. But at the same time I'd like to talk about the setup that I've got and why I think it is good. + +First, I'd like to show how I fixed the Minio issue from the previous post. + +>I’m using Minio as a storage for pictures, and currently all pictures (and other files) are stored in one folder regardless of the environment. + +I've started using `git lfs` for media data. But I still want to have small docker images so I've decided to add some logi around pushing media files to `Minio`. So I've added a Drone job: +```YAML + - name: Sync pictures from lfs to Minio + image: rclone/rclone:latest + when: + branch: + exclude: + - main + environment: + RCLONE_CONFIG_CONTENT: + from_secret: RCLONE_CONFIG_CONTENT_PRIVATE + RCLONE_CONFIG: /tmp/rclone.conf + commands: + - echo "$RCLONE_CONFIG_CONTENT" > $RCLONE_CONFIG + - apk update + - apk add git make + - make upload_static + + - name: Sync pictures to the main Minio bucket + image: rclone/rclone:latest + when: + branch: + - main + environment: + RCLONE_CONFIG_CONTENT: + from_secret: RCLONE_CONFIG_CONTENT_PRIVATE + RCLONE_CONFIG: /tmp/rclone.conf + commands: + - echo "$RCLONE_CONFIG_CONTENT" > $RCLONE_CONFIG + - apk update + - apk add git make + - make sync_static_with_main +``` + + diff --git a/scripts/upload-media.pl b/scripts/upload-media.pl new file mode 100755 index 0000000..23df3cf --- /dev/null +++ b/scripts/upload-media.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl +my $git_branch = `git rev-parse --abbrev-ref HEAD`; +my $git_commit_sha = `git rev-parse HEAD`; +my $main_branch = "main"; +my $common_bucket = "badhouseplants-minio:/badhouseplants-net"; +my $main_bucket = "badhouseplants-minio:/badhouseplants-net-main"; + +chop($git_branch); +chop($git_commit_sha); + +if ( $git_branch eq $main_branch) { + print "Syncing to the production bucket\n"; + print `rclone sync -P "$common_bucket/$git_commit_sha" "$main_bucket/"`; +} else { + print "Creating a new hashed dir in the common bucket\n"; + print `rclone copy -P static "$common_bucket/$git_commit_sha"`; +} + diff --git a/scripts/upload-media.sh b/scripts/upload-media.sh deleted file mode 100755 index 1bdce97..0000000 --- a/scripts/upload-media.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -set -e - -#=== 'prev-commit' solution by o_O Tync -#commit_hash=$(git rev-parse --verify HEAD) -commit=$(git log -1 --pretty="%H%n%ci") # hash \n date -commit_date=$(echo "$commit" | head -2 | tail -1) # 2010-12-28 05:16:23 +0300 -commit_hash=$(echo "$commit" | head -1) -echo "$(git rev-parse HEAD)" > /tmp/test -echo "prev_commit='$commit_hash'\ndate='$commit_date'\nbranch='$branch'\n" > /tmp/test.txt diff --git a/static/about/logo.png b/static/about/logo.png new file mode 100755 index 0000000..a6eb0e6 Binary files /dev/null and b/static/about/logo.png differ diff --git a/static/posts/design-a-scalable-system/chain-1.png b/static/posts/design-a-scalable-system/chain-1.png new file mode 100644 index 0000000..8edd0d5 Binary files /dev/null and b/static/posts/design-a-scalable-system/chain-1.png differ