From 2d3553df8c6cbdee5a731e631446b779d2ce6ffe Mon Sep 17 00:00:00 2001 From: Diego Lendoiro Date: Wed, 18 Jan 2023 10:33:38 +0100 Subject: [PATCH 1/3] PB-22392: added passbolt_publish variable --- .gitlab-ci/Jobs/publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci/Jobs/publish.yaml b/.gitlab-ci/Jobs/publish.yaml index b8c1f65..273c55b 100644 --- a/.gitlab-ci/Jobs/publish.yaml +++ b/.gitlab-ci/Jobs/publish.yaml @@ -74,6 +74,6 @@ publish-pro-non-root: - *docker-authentication - *publish-command rules: - - if: '$PASSBOLT_VERSION && $CI_COMMIT_BRANCH == "master" && $PASSBOLT_FLAVOUR == "pro"' + - if: '$PASSBOLT_VERSION && $CI_COMMIT_BRANCH == "master" && $PASSBOLT_PUBLISH == "pro"' when: on_success From 4dabe7eccde610a1ab264ced17f815539891e3d9 Mon Sep 17 00:00:00 2001 From: Diego Lendoiro Date: Wed, 18 Jan 2023 14:29:57 +0000 Subject: [PATCH 2/3] Feature/pb 22394 --- Gemfile | 1 + spec/docker_image/image_spec.rb | 33 ++++++++++++++----- spec/docker_runtime/runtime_spec.rb | 26 +++++++++++---- .../runtime_no_envs_spec.rb | 17 ++++++++-- spec/spec_helper.rb | 2 +- 5 files changed, 62 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index cc5bf5e..9841a5b 100644 --- a/Gemfile +++ b/Gemfile @@ -6,3 +6,4 @@ group :test do gem 'serverspec' gem 'pry' end + diff --git a/spec/docker_image/image_spec.rb b/spec/docker_image/image_spec.rb index 9d34df7..586dba7 100644 --- a/spec/docker_image/image_spec.rb +++ b/spec/docker_image/image_spec.rb @@ -12,7 +12,20 @@ 'PASSBOLT_GPG_KEYRING' => '/var/lib/passbolt/.gnupg' } - @image = Docker::Image.build_from_dir(ROOT_DOCKERFILES, { 'dockerfile' => $dockerfile, 'buildargs' => JSON.generate($buildargs) } ) + if ENV['GITLAB_CI'] + Docker.authenticate!( + 'username' => ENV['CI_REGISTRY_USER'].to_s, + 'password' => ENV['CI_REGISTRY_PASSWORD'].to_s, + 'serveraddress' => 'https://registry.gitlab.com/' + ) + if ENV['ROOTLESS'] + @image = Docker::Image.create('fromImage' => "#{ENV['CI_REGISTRY_IMAGE']}:#{ENV['PASSBOLT_FLAVOUR']}-rootless-latest") + else + @image = Docker::Image.create('fromImage' => "#{ENV['CI_REGISTRY_IMAGE']}:#{ENV['PASSBOLT_FLAVOUR']}-root-latest") + end + else + @image = Docker::Image.build_from_dir(ROOT_DOCKERFILES, { 'dockerfile' => $dockerfile, 'buildargs' => JSON.generate($buildargs) } ) + end set :docker_image, @image.id set :docker_container_create_options, { 'Cmd' => '/bin/sh' } end @@ -67,14 +80,18 @@ expect(file(wait_for)).to exist and be_executable end end - + describe 'entrypoint' do it 'is installed' do - expect(file('/docker-entrypoint.sh')).to exist and be_executable - expect(file('/passbolt/entrypoint.sh')).to exist and be_owned_by(passbolt_owner) - expect(file('/passbolt/env.sh')).to exist and be_owned_by(passbolt_owner) - expect(file('/passbolt/entropy.sh')).to exist and be_owned_by(passbolt_owner) - expect(file('/passbolt/deprecated_paths.sh')).to exist and be_executable + expect(file('/docker-entrypoint.sh')).to exist and be_executable.by(passbolt_owner) + if ENV['ROOTLESS'] == 'true' + expect(file('/passbolt/entrypoint-rootless.sh')).to exist and be_readable.by(passbolt_owner) + else + expect(file('/passbolt/entrypoint.sh')).to exist and be_readable.by(passbolt_owner) + end + expect(file('/passbolt/env.sh')).to exist and be_readable.by(passbolt_owner) + expect(file('/passbolt/entropy.sh')).to exist and be_readable.by(passbolt_owner) + expect(file('/passbolt/deprecated_paths.sh')).to exist and be_readable.by(passbolt_owner) end end @@ -137,7 +154,7 @@ describe 'ports exposed' do it 'exposes port' do exposed_ports.each do |port| - expect(@image.json['ContainerConfig']['ExposedPorts']).to include("#{port}/tcp") + expect(@image.json['Config']['ExposedPorts']).to include("#{port}/tcp") end end end diff --git a/spec/docker_runtime/runtime_spec.rb b/spec/docker_runtime/runtime_spec.rb index b474535..d1bec04 100644 --- a/spec/docker_runtime/runtime_spec.rb +++ b/spec/docker_runtime/runtime_spec.rb @@ -5,7 +5,7 @@ before(:all) do if ENV['GITLAB_CI'] @mysql_image = Docker::Image.create('fromImage' => 'registry.gitlab.com/passbolt/passbolt-ci-docker-images/mariadb-10.3:latest') - else + else @mysql_image = Docker::Image.create('fromImage' => 'mariadb:latest') end @@ -16,10 +16,10 @@ 'MYSQL_USER=passbolt', 'MYSQL_PASSWORD=±!@#$%^&*()_+=-}{|:;<>?' ], - "Healthcheck" => { + 'Healthcheck' => { "Test": [ - "CMD-SHELL", - "mysqladmin ping --silent" + 'CMD-SHELL', + 'mysqladmin ping --silent' ] }, 'Image' => @mysql_image.id) @@ -29,7 +29,21 @@ sleep 1 end - @image = Docker::Image.build_from_dir(ROOT_DOCKERFILES, { 'dockerfile' => $dockerfile, 'buildargs' => JSON.generate($buildargs) } ) + if ENV['GITLAB_CI'] + Docker.authenticate!( + 'username' => ENV['CI_REGISTRY_USER'].to_s, + 'password' => ENV['CI_REGISTRY_PASSWORD'].to_s, + 'serveraddress' => 'https://registry.gitlab.com/' + ) + if ENV['ROOTLESS'] + @image = Docker::Image.create('fromImage' => "#{ENV['CI_REGISTRY_IMAGE']}:#{ENV['PASSBOLT_FLAVOUR']}-rootless-latest") + else + @image = Docker::Image.create('fromImage' => "#{ENV['CI_REGISTRY_IMAGE']}:#{ENV['PASSBOLT_FLAVOUR']}-root-latest") + end + else + @image = Docker::Image.build_from_dir(ROOT_DOCKERFILES, { 'dockerfile' => $dockerfile, 'buildargs' => JSON.generate($buildargs) } ) + end + @container = Docker::Container.create( 'Env' => [ "DATASOURCES_DEFAULT_HOST=#{@mysql.json['NetworkSettings']['IPAddress']}", @@ -54,7 +68,7 @@ end let(:passbolt_host) { @container.json['NetworkSettings']['IPAddress'] } - let(:uri) { "/healthcheck/status.json" } + let(:uri) { '/healthcheck/status.json' } let(:curl) { "curl -sk -o /dev/null -w '%{http_code}' -H 'Host: passbolt.local' https://#{passbolt_host}:#{$https_port}/#{uri}" } describe 'php service' do diff --git a/spec/docker_runtime_no_envs/runtime_no_envs_spec.rb b/spec/docker_runtime_no_envs/runtime_no_envs_spec.rb index c819ce8..8fcbef9 100644 --- a/spec/docker_runtime_no_envs/runtime_no_envs_spec.rb +++ b/spec/docker_runtime_no_envs/runtime_no_envs_spec.rb @@ -5,7 +5,7 @@ before(:all) do if ENV['GITLAB_CI'] @mysql_image = Docker::Image.create('fromImage' => 'registry.gitlab.com/passbolt/passbolt-ci-docker-images/mariadb-10.3:latest') - else + else @mysql_image = Docker::Image.create('fromImage' => 'mariadb:latest') end @mysql = Docker::Container.create( @@ -28,7 +28,20 @@ sleep 1 end - @image = Docker::Image.build_from_dir(ROOT_DOCKERFILES, { 'dockerfile' => $dockerfile, 'buildargs' => JSON.generate($buildargs) } ) + if ENV['GITLAB_CI'] + Docker.authenticate!( + 'username' => ENV['CI_REGISTRY_USER'].to_s, + 'password' => ENV['CI_REGISTRY_PASSWORD'].to_s, + 'serveraddress' => 'https://registry.gitlab.com/' + ) + if ENV['ROOTLESS'] + @image = Docker::Image.create('fromImage' => "#{ENV['CI_REGISTRY_IMAGE']}:#{ENV['PASSBOLT_FLAVOUR']}-rootless-latest") + else + @image = Docker::Image.create('fromImage' => "#{ENV['CI_REGISTRY_IMAGE']}:#{ENV['PASSBOLT_FLAVOUR']}-root-latest") + end + else + @image = Docker::Image.build_from_dir(ROOT_DOCKERFILES, { 'dockerfile' => $dockerfile, 'buildargs' => JSON.generate($buildargs) } ) + end @container = Docker::Container.create( 'Env' => [ diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5aa2eb0..8838173 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -36,7 +36,7 @@ ) end -if ENV['ROOTLESS'] == true +if ENV['ROOTLESS'] == 'true' $cron_binary = '/usr/local/bin/supercronic' $dockerfile = 'debian/Dockerfile.rootless' $http_port = '8080' From 587a461946ab0735b917b5a1c79096a106a03989 Mon Sep 17 00:00:00 2001 From: Diego Lendoiro Date: Wed, 18 Jan 2023 15:34:55 +0100 Subject: [PATCH 3/3] Updated changelog --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 346fcaa..8907627 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [Unreleased](https://github.com/passbolt/passbolt_docker/compare/v3.8.0...HEAD) +## [Unreleased](https://github.com/passbolt/passbolt_docker/compare/v3.8.1...HEAD) + +## [3.8.1](https://github.com/passbolt/passbolt_docker/compare/v3.8.0...v3.8.1) - 2023-01-18 + +### Changed + +- Minor changes on the internal publishing process ## [3.8.0](https://github.com/passbolt/passbolt_docker/compare/v3.7.5...v3.8.0) - 2023-01-13