From b82b965d03550dcb88196dfacfa3b859a1654219 Mon Sep 17 00:00:00 2001 From: kickhead13 Date: Thu, 18 Jun 2026 17:17:26 +0300 Subject: [PATCH 1/3] Introducing docker bake to simplify deployment The bake helps us deploy new versions of od-official-server through a single command. --- Jenkinsfile | 14 ++------------ README.md | 20 ++++++++++++++++++-- compose.ci.yaml | 21 --------------------- compose.yaml | 17 ----------------- docker-bake.hcl | 22 ++++++++++++++++++++++ 5 files changed, 42 insertions(+), 52 deletions(-) delete mode 100644 compose.ci.yaml delete mode 100644 compose.yaml create mode 100644 docker-bake.hcl diff --git a/Jenkinsfile b/Jenkinsfile index 09ce664..55ce199 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,28 +1,18 @@ -def version="" pipeline { agent any - environment { - API_PORT='1313' - WS_PORT='9002' - } - stages { stage('Push Image to Docker Registry') { steps { script { - withDockerRegistry(url: 'https://registry.onlinedi.vision:5000', credentialsId:'docker-registry') { - version="v" + sh(script:'echo ${GIT_BRANCH} | cut -d/ -f3- | xargs echo -n', returnStdout: true) - echo "VERSION TO BE DEPLOYED: $version" - sh "docker build . -t od-official-server:${version} --build-context 'bare-repo=test-env-compose/rootfs/repo'" - sh "docker tag od-official-server:${version} registry.onlinedi.vision:5000/od-official-server:${version}" - sh "docker push registry.onlinedi.vision:5000/od-official-server:${version}" + sh "docker buildx bake --set release.output=\"type=registry\"" } } } } stage ('Deploying to K8S') { + def version="v" + sh(script:'echo ${GIT_BRANCH} | cut -d/ -f3- | xargs echo -n', returnStdout: true) steps { build job: 'PROD/K8S-INFRA/DEPLOY', parameters: [[$class: 'StringParameterValue', name: 'DEPLOYMENT', value: 'od-official-server'], [$class: 'StringParameterValue', name: 'NEW_VERSION', value: version]] } diff --git a/README.md b/README.md index 161dabe..bb94d57 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ For more in depth analysis of what it does please either check out the code of ` The "Test Env" sets up some random credentials (such as keys for encryption, and so on...). To have better control of what the keys are you can edit `launch-test-env.sh`, specifically these lines: ```sh -export SALT_ENCRYPTION_IV="ffA_1D6s^jf!6\$xx" -export SALT_ENCRYPTION_KEY='#a1aA3!h4a@ah3a4' +export SALT_ENCRYPTION_IV="FFFFFFFFFFFFFFFF" +export SALT_ENCRYPTION_KEY='aaaaaaaaaaaaaaaa' export SCYLLA_CASSANDRA_PASSWORD='cassandra' export API_PORT=1313 export NO_OF_WORKERS=32 @@ -36,3 +36,19 @@ These being the lines that set up the necessary environment variables for `od-of Please checkout [CONTRIBUTING.md](./CONTRIBUTING.md) and [TESTING.md](./TESTING.md). +## Building server images with docker bake + +To simply build a local server image you can run the following command: +```sh +GIT_BRANCH="refs/tags/1.2.3" docker buildx bake --set release.output="type=docker" +``` + +If you'd like to publish this image to the registry you can use: +```sh +GIT_BRANCH="refs/tags/1.2.3" docker buildx bake --set release.output="type=registry" +``` + +> ![WARNING] +> `GIT_BRANCH` is the ref to the tag in git. Whatever you set it to will be used +> to tag the image you create. For example `GIT_BRANCH="refs/tags/1.2.3` will tag +> your image as `registry.onlinedi.vision:5000/od-official-server:v1.2.3`. diff --git a/compose.ci.yaml b/compose.ci.yaml deleted file mode 100644 index 49d1173..0000000 --- a/compose.ci.yaml +++ /dev/null @@ -1,21 +0,0 @@ -services: - od-official-server: - build: - context: . - dockerfile: Dockerfile.test - args: - - SALT_ENCRYPTION_KEY=${SALT_ENCRYPTION_KEY} - - SALT_ENCRYPTION_IV=${SALT_ENCRYPTION_IV} - - SCYLLA_CASSANDRA_PASSWORD=${SCYLLA_CASSANDRA_PASSWORD} - - SCYLLA_DB_USER=cassandra - - API_PORT=1313 - mem_limit: 1G - cpus: '2' - ports: - - "127.0.0.1:1313:1313" - environment: - - SALT_ENCRYPTION_KEY - - SALT_ENCRYPTION_IV - - SCYLLA_CASSANDRA_PASSWORD - - SCYLLA_DB_USER=cassandra - - API_PORT=1313 diff --git a/compose.yaml b/compose.yaml deleted file mode 100644 index 9bb0c4a..0000000 --- a/compose.yaml +++ /dev/null @@ -1,17 +0,0 @@ -services: - od-official-server: - build: - context: . - additional_contexts: - bare-repo: test-env-compose/rootfs/repo - mem_limit: 1G - cpus: '2' - ports: - - "127.0.0.1:1313:1313" - environment: - - NO_OF_WORKERS=32 - - SALT_ENCRYPTION_KEY - - SALT_ENCRYPTION_IV - - SCYLLA_CASSANDRA_PASSWORD - - SCYLLA_DB_USER - - API_PORT=1313 diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..16d31cb --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,22 @@ +variable "GIT_BRANCH" {} + +group "default" { + targets = [ "release" ] +} + +function "tag" { + params = [ branch ] + result = "v${split("/", branch)[2]}" +} + +target "release" { + target = "runtime" + contexts = { + bare-repo = "test-env-compose/rootfs/repo" + } + args = { + GIT_BRANCH = "${GIT_BRANCH}" + } + output = [ "type=cacheonly" ] + tags = [ "registry.onlinedi.vision:5000/od-official-server:${tag("${GIT_BRANCH}")}" ] +} From f83f2c2f1f88060550ee541d401e620036c537ed Mon Sep 17 00:00:00 2001 From: kickhead13 Date: Thu, 18 Jun 2026 17:53:42 +0300 Subject: [PATCH 2/3] running actions on bake --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9049fe5..f41307c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -21,4 +21,4 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Docker Image run: | - docker compose build + docker buildx bake From 282c25852c3d6e9bb07c1e18dca6daf90992987c Mon Sep 17 00:00:00 2001 From: kickhead13 Date: Thu, 18 Jun 2026 17:59:28 +0300 Subject: [PATCH 3/3] oops... forgot env var in action for bake --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f41307c..619a91a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -21,4 +21,4 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Docker Image run: | - docker buildx bake + GIT_BRANCH='refs/tags/0.0.0' docker buildx bake