feat: Add a script for pushing images to the bucket
build: Update the CI fix: Update the sctipt so it creates correct dirs
This commit is contained in:
parent
80cb94f767
commit
4e1fa24a21
24
.drone.yml
24
.drone.yml
@ -80,34 +80,14 @@ steps:
|
|||||||
|
|
||||||
- name: Sync pictures from lfs to Minio
|
- name: Sync pictures from lfs to Minio
|
||||||
image: rclone/rclone:latest
|
image: rclone/rclone:latest
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
exclude:
|
|
||||||
- main
|
|
||||||
environment:
|
environment:
|
||||||
RCLONE_CONFIG_CONTENT:
|
RCLONE_CONFIG_CONTENT:
|
||||||
from_secret: RCLONE_CONFIG_CONTENT_PRIVATE
|
from_secret: RCLONE_CONFIG_CONTENT_PRIVATE
|
||||||
RCLONE_CONFIG: /tmp/rclone.conf
|
RCLONE_CONFIG: /tmp/rclone.conf
|
||||||
commands:
|
commands:
|
||||||
- echo "$RCLONE_CONFIG_CONTENT" > $RCLONE_CONFIG
|
- echo "$RCLONE_CONFIG_CONTENT" > $RCLONE_CONFIG
|
||||||
- apk update
|
- apk update && apk add git perl
|
||||||
- apk add git make
|
- ./scripts/upload-media.pl
|
||||||
- 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
|
|
||||||
|
|
||||||
- name: Deploy a preview ApplicationSet
|
- name: Deploy a preview ApplicationSet
|
||||||
image: alpine/k8s:1.24.10
|
image: alpine/k8s:1.24.10
|
||||||
|
@ -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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
18
scripts/upload-media.pl
Executable file
18
scripts/upload-media.pl
Executable file
@ -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"`;
|
||||||
|
}
|
||||||
|
|
@ -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
|
|
BIN
static/about/logo.png
Executable file
BIN
static/about/logo.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 228 KiB |
BIN
static/posts/design-a-scalable-system/chain-1.png
Normal file
BIN
static/posts/design-a-scalable-system/chain-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 MiB |
Reference in New Issue
Block a user