From 2b700240e487f8016e1414621a09031383c9aaf3 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Fri, 13 Oct 2023 12:21:54 +0800 Subject: [PATCH 1/2] DEV: Remove use of `--squash` flag Why this change? In CI, we are seeing the following warning message: ``` WARNING: experimental flag squash is removed with BuildKit. You should squash inside build using a multi-stage Dockerfile for efficiency. ``` Basically, the `--squash` flag has not been working for quite some time and is redundant. --- image/auto_build.rb | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/image/auto_build.rb b/image/auto_build.rb index b507ec6f5..8cb87fb28 100644 --- a/image/auto_build.rb +++ b/image/auto_build.rb @@ -1,13 +1,27 @@ # simple build file to be used locally by Sam # -require 'pty' -require 'optparse' +require "pty" +require "optparse" images = { - base_slim: { name: 'base', tag: "discourse/base:build_slim", squash: true, extra_args: '-f slim.Dockerfile' }, - base: { name: 'base', tag: "discourse/base:build", extra_args: '-f release.Dockerfile' }, - discourse_test_build: { name: 'discourse_test', tag: "discourse/discourse_test:build", squash: false}, - discourse_dev: { name: 'discourse_dev', tag: "discourse/discourse_dev:build", squash: false }, + base_slim: { + name: "base", + tag: "discourse/base:build_slim", + extra_args: "-f slim.Dockerfile", + }, + base: { + name: "base", + tag: "discourse/base:build", + extra_args: "-f release.Dockerfile", + }, + discourse_test_build: { + name: "discourse_test", + tag: "discourse/discourse_test:build", + }, + discourse_dev: { + name: "discourse_dev", + tag: "discourse/discourse_dev:build", + }, } def run(command) @@ -30,12 +44,19 @@ def run(command) end def build(image) - lines = run("cd #{image[:name]} && docker build . --no-cache --tag #{image[:tag]} #{image[:squash] ? '--squash' : ''} #{image[:extra_args] ? image[:extra_args] : ''}") - raise "Error building the image for #{image[:name]}: #{lines[-1]}" if lines[-1] =~ /successfully built/ + lines = + run( + "cd #{image[:name]} && docker build . --no-cache --tag #{image[:tag]} #{image[:extra_args] ? image[:extra_args] : ""}", + ) + if lines[-1] =~ /successfully built/ + raise "Error building the image for #{image[:name]}: #{lines[-1]}" + end end def dev_deps() - run("sed -e 's/\(db_name: discourse\)/\1_development/' ../templates/postgres.template.yml > discourse_dev/postgres.template.yml") + run( + "sed -e 's/\(db_name: discourse\)/\1_development/' ../templates/postgres.template.yml > discourse_dev/postgres.template.yml", + ) run("cp ../templates/redis.template.yml discourse_dev/redis.template.yml") end From c87c95b65e71f4a37035b427485ff381ee64ace2 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Fri, 13 Oct 2023 13:18:49 +0800 Subject: [PATCH 2/2] Add CircleCi config --- .circleci/config.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..5a4cde65a --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,18 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. +# See: https://circleci.com/docs/configuration-reference +version: 2.1 + +# Define a job to be invoked later in a workflow. +# See: https://circleci.com/docs/configuration-reference/#jobs +jobs: + build: + working_directory: image + docker: + - image: cimg/base:current + resource_class: arm.medium + steps: + - checkout + - run: + name: Build application Docker image + command: | + cd base && docker buildx build . --load --platform linux/arm64 --tag discourse/base:build_slim -f slim.Dockerfile \ No newline at end of file