Skip to content

Commit cb0af9d

Browse files
committed
Merge branch 'release/v2.8.1'
2 parents 8e1c638 + 73d568c commit cb0af9d

12 files changed

+296
-22
lines changed

.dockerignore

-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ Gemfile.lock
88
Rakefile
99
*.md
1010
*.yml
11-
scripts
1211
env

CHANGELOG.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## [Unreleased](https://github.com/passbolt/passbolt_docker/compare/v2.7.1...HEAD)
5+
## [Unreleased](https://github.com/passbolt/passbolt_docker/compare/v2.8.1...HEAD)
6+
7+
## [2.8.1](https://github.com/passbolt/passbolt_docker/compare/v2.7.1...v2.8.1) - 2019-04-01
8+
9+
### Added
10+
11+
- Documentation for new env variable APP_BASE to use passbolt in a subfolder
12+
- Added wait-for.sh to the docker image as part of [#123](https://github.com/passbolt/passbolt_docker/pull/123)
13+
14+
### Fixed
15+
16+
- Now passbolt checks for the mysql status outside of the docker image [#97](https://github.com/passbolt/passbolt_docker/issues/97)
617

718
## [2.7.1](https://github.com/passbolt/passbolt_docker/compare/v2.7.0...v2.7.1) - 2019-02-13
819

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM php:7.2-fpm
22

33
LABEL maintainer="[email protected]"
44

5-
ARG PASSBOLT_VERSION="2.7.1"
5+
ARG PASSBOLT_VERSION="2.8.1"
66
ARG PASSBOLT_URL="https://github.com/passbolt/passbolt_api/archive/v${PASSBOLT_VERSION}.tar.gz"
77

88
ARG PHP_EXTENSIONS="gd \
@@ -78,6 +78,7 @@ RUN apt-get update \
7878
COPY conf/passbolt.conf /etc/nginx/conf.d/default.conf
7979
COPY conf/supervisor/*.conf /etc/supervisor/conf.d/
8080
COPY bin/docker-entrypoint.sh /docker-entrypoint.sh
81+
COPY scripts/wait-for.sh /usr/bin/wait-for.sh
8182

8283
EXPOSE 80 443
8384

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Passbolt docker image provides several environment variables to configure differ
7676

7777
| Variable name | Description | Default value |
7878
| ----------------------------------- | -------------------------------- | ------------------- |
79+
| APP_BASE | it allows people to specify the base subdir the application is running in | null |
7980
| APP_FULL_BASE_URL | Passbolt base url | false |
8081
| DATASOURCES_DEFAULT_HOST | Database hostname | localhost |
8182
| DATASOURCES_DEFAULT_PORT | Database port | 3306 |

bin/docker-entrypoint.sh

+3-14
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,18 @@ gen_ssl_cert() {
7070
}
7171

7272
install() {
73-
tables=$(mysql \
74-
-u "${DATASOURCES_DEFAULT_USERNAME:-passbolt}" \
75-
-h "${DATASOURCES_DEFAULT_HOST:-localhost}" \
76-
-P "${DATASOURCES_DEFAULT_PORT:-3306}" \
77-
-BN -e "SHOW TABLES FROM ${DATASOURCES_DEFAULT_DATABASE:-passbolt}" \
78-
-p"${DATASOURCES_DEFAULT_PASSWORD:-P4ssb0lt}" |wc -l)
79-
app_config="/var/www/passbolt/config/app.php"
73+
local app_config="/var/www/passbolt/config/app.php"
8074

8175
if [ ! -f "$app_config" ]; then
8276
su -c 'cp /var/www/passbolt/config/app.default.php /var/www/passbolt/config/app.php' -s /bin/bash www-data
8377
fi
8478

85-
if [ -z "${PASSBOLT_GPG_SERVER_KEY_FINGERPRINT+xxx}" ]; then
79+
if [ -z "${PASSBOLT_GPG_SERVER_KEY_FINGERPRINT+xxx}" ] && [ ! -f '/var/www/passbolt/config/passbolt.php' ]; then
8680
gpg_auto_fingerprint="$(su -c "gpg --list-keys --with-colons ${PASSBOLT_KEY_EMAIL:-passbolt@yourdomain.com} |grep fpr |head -1| cut -f10 -d:" -ls /bin/bash www-data)"
8781
export PASSBOLT_GPG_SERVER_KEY_FINGERPRINT=$gpg_auto_fingerprint
8882
fi
8983

90-
if [ "$tables" -eq 0 ]; then
91-
su -c '/var/www/passbolt/bin/cake passbolt install --no-admin' -s /bin/bash www-data
92-
else
93-
su -c '/var/www/passbolt/bin/cake passbolt migrate' -s /bin/bash www-data
94-
echo "Enjoy! ☮"
95-
fi
84+
su -c '/var/www/passbolt/bin/cake passbolt install --no-admin' -s /bin/bash www-data || su -c '/var/www/passbolt/bin/cake passbolt migrate' -s /bin/bash www-data && echo "Enjoy! ☮"
9685
}
9786

9887
email_cron_job() {

docker-compose-dev.yml

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ services:
2121
volumes:
2222
- gpg_volume:/var/www/passbolt/config/gpg
2323
- images_volume:/var/www/passbolt/webroot/img/public/images
24-
- ./scripts/wait-for.sh:/usr/bin/wait-for.sh
2524
command: ["/usr/bin/wait-for.sh", "db:3306", "--", "/docker-entrypoint.sh"]
2625
ports:
2726
- 80:80

docker-compose-pro.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- "127.0.0.1:3306:3306"
1111

1212
passbolt:
13-
image: passbolt/passbolt:2.7.1-pro-debian
13+
image: passbolt/passbolt:2.8.1-pro-debian
1414
tty: true
1515
depends_on:
1616
- db
@@ -20,7 +20,6 @@ services:
2020
- gpg_volume:/var/www/passbolt/config/gpg
2121
- images_volume:/var/www/passbolt/webroot/img/public
2222
- ./license:/var/www/passbolt/config/license
23-
- ./scripts/wait-for.sh:/usr/bin/wait-for.sh
2423
tmpfs:
2524
- /run
2625
command: ["/usr/bin/wait-for.sh", "db:3306", "--", "/docker-entrypoint.sh"]

docker-compose.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- "127.0.0.1:3306:3306"
1111

1212
passbolt:
13-
image: passbolt/passbolt:2.7.1-debian
13+
image: passbolt/passbolt:2.8.1-debian
1414
tty: true
1515
depends_on:
1616
- db
@@ -19,7 +19,6 @@ services:
1919
volumes:
2020
- gpg_volume:/var/www/passbolt/config/gpg
2121
- images_volume:/var/www/passbolt/webroot/img/public
22-
- ./scripts/wait-for.sh:/usr/bin/wait-for.sh
2322
tmpfs:
2423
- /run
2524
command: ["/usr/bin/wait-for.sh", "db:3306", "--", "/docker-entrypoint.sh"]

spec/docker_image/image_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'curl', 'gd', 'intl', 'json', 'mcrypt', 'mysqlnd', 'xsl', 'phar',
3535
'posix', 'xml', 'zlib', 'ctype', 'pdo', 'gnupg', 'pdo_mysql'
3636
] }
37+
let(:wait_for) { '/usr/bin/wait-for.sh' }
3738

3839
describe 'passbolt required php extensions' do
3940
it 'has php extensions installed' do
@@ -61,6 +62,12 @@
6162
end
6263
end
6364

65+
describe 'wait-for' do
66+
it 'is installed' do
67+
expect(file(wait_for)).to exist and be_executable
68+
end
69+
end
70+
6471
describe 'passbolt directory structure' do
6572
it 'must exist and be directories' do
6673
expect(file(passbolt_home)).to be_a_directory
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
require 'spec_helper'
2+
3+
describe 'passbolt_api service' do
4+
5+
before(:all) do
6+
@mysql_image = Docker::Image.create('fromImage' => 'mariadb:latest')
7+
@mysql = Docker::Container.create(
8+
'Env' => [
9+
'MYSQL_ROOT_PASSWORD=test',
10+
'MYSQL_DATABASE=passbolt',
11+
'MYSQL_USER=passbolt',
12+
'MYSQL_PASSWORD=±!@#$%^&*()_+=-}{|:;<>?'
13+
],
14+
"Healthcheck" => {
15+
"Test": [
16+
"CMD-SHELL",
17+
"mysqladmin ping --silent"
18+
]
19+
},
20+
'Image' => @mysql_image.id)
21+
@mysql.start
22+
23+
while @mysql.json['State']['Health']['Status'] != 'healthy'
24+
sleep 1
25+
end
26+
27+
@image = Docker::Image.build_from_dir(ROOT_DOCKERFILES)
28+
29+
@container = Docker::Container.create(
30+
'Env' => [
31+
"DATASOURCES_DEFAULT_HOST=#{@mysql.json['NetworkSettings']['IPAddress']}",
32+
],
33+
'Binds' => [ "#{FIXTURES_PATH + '/passbolt.php'}:/var/www/passbolt/config/passbolt.php" ],
34+
'Image' => @image.id)
35+
36+
@container.start
37+
@container.logs(stdout: true)
38+
39+
set :docker_container, @container.id
40+
sleep 17
41+
end
42+
43+
after(:all) do
44+
@mysql.kill
45+
@container.kill
46+
end
47+
48+
let(:passbolt_host) { @container.json['NetworkSettings']['IPAddress'] }
49+
let(:uri) { "/healthcheck/status.json" }
50+
let(:curl) { "curl -sk -o /dev/null -w '%{http_code}' -H 'Host: passbolt.local' https://#{passbolt_host}/#{uri}" }
51+
52+
describe 'php service' do
53+
it 'is running supervised' do
54+
expect(service('php-fpm')).to be_running.under('supervisor')
55+
end
56+
57+
it 'has its port open' do
58+
expect(@container.json['Config']['ExposedPorts']).to have_key('9000/tcp')
59+
end
60+
end
61+
62+
describe 'email cron' do
63+
it 'is running supervised' do
64+
expect(service('cron')).to be_running.under('supervisor')
65+
end
66+
end
67+
68+
describe 'web service' do
69+
it 'is running supervised' do
70+
expect(service('nginx')).to be_running.under('supervisor')
71+
end
72+
73+
it 'is listening on port 80' do
74+
expect(@container.json['Config']['ExposedPorts']).to have_key('80/tcp')
75+
end
76+
77+
it 'is listening on port 443' do
78+
expect(@container.json['Config']['ExposedPorts']).to have_key('443/tcp')
79+
end
80+
end
81+
82+
describe 'passbolt status' do
83+
it 'returns 200' do
84+
expect(command(curl).stdout).to eq '200'
85+
end
86+
end
87+
88+
describe 'passbolt serverkey unaccessible' do
89+
let(:uri) { '/config/gpg/serverkey.asc' }
90+
it "returns 404" do
91+
expect(command(curl).stdout).to eq '404'
92+
end
93+
end
94+
95+
describe 'passbolt serverkey private unaccessible' do
96+
let(:uri) { '/config/gpg/serverkey_private.asc' }
97+
it 'returns 404' do
98+
expect(command(curl).stdout).to eq '404'
99+
end
100+
end
101+
102+
describe 'passbolt conf unaccessible' do
103+
let(:uri) { '/config/app.php' }
104+
it 'returns 404' do
105+
expect(command(curl).stdout).to eq '404'
106+
end
107+
end
108+
describe 'passbolt tmp folder is unaccessible' do
109+
let(:uri) { '/tmp/cache/database/empty' }
110+
it 'returns 404' do
111+
expect(command(curl).stdout).to eq '404'
112+
end
113+
end
114+
115+
describe 'hide information' do
116+
let(:curl) { "curl -Isk -H 'Host: passbolt.local' https://#{passbolt_host}/" }
117+
it 'hides php version' do
118+
expect(command("#{curl} | grep 'X-Powered-By: PHP'").stdout).to be_empty
119+
end
120+
121+
it 'hides nginx version' do
122+
expect(command("#{curl} | grep 'Server:'").stdout.strip).to match(/^Server:\s+nginx$/)
123+
end
124+
end
125+
126+
end

0 commit comments

Comments
 (0)