Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce images size #1636

Merged
merged 37 commits into from
Jun 26, 2020
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5c4bab5
Use nodemon instead of PM2
May 24, 2020
a3daaeb
Reduce production image size
May 24, 2020
dfff4d9
Nit
May 24, 2020
c184da6
Update scripts
May 25, 2020
104092b
Fix plugin-dev
May 25, 2020
6ca77b1
Save 4mo
May 25, 2020
93bc34e
Move images
May 26, 2020
c76aafa
asynchronous extract
May 27, 2020
cd5a6b1
Fix images
May 27, 2020
ee0bb17
Nit
May 27, 2020
e423165
nit
May 27, 2020
437bdca
Reduce size
May 28, 2020
c429fb4
wip
May 28, 2020
b04ce12
Plugin-dev ok
May 28, 2020
9e0d229
merge ok
May 28, 2020
f87ed79
Add wait-elasticsearch
May 28, 2020
9b98ace
kuzzleio/kuzzle ok
Jun 19, 2020
6862c52
kuzzleio/alpine ok
Jun 19, 2020
ff1ae5e
all images ok
Jun 19, 2020
bb3818f
Add README
Jun 19, 2020
19f3314
Fix tests
Jun 19, 2020
383f8b5
trigger ci
Jun 19, 2020
271413d
fix test
Jun 19, 2020
0df3a7b
fix sh
Jun 19, 2020
119bb7d
use node for startup scripts
Jun 19, 2020
70e5fa8
Bump node 12.18.1
Jun 22, 2020
41d1cf5
Merge branch 'master' into reduce-production-image-size
Aschen Jun 22, 2020
17660d7
Fix dependencies install in tests
Jun 23, 2020
e331000
Update docker/scripts/run-dev.sh
Aschen Jun 23, 2020
f14f4c4
Update scripts
Jun 23, 2020
b33d5b9
Merge branch 'master' into reduce-production-image-size
Aschen Jun 23, 2020
bd5a9c2
Update scripts
Jun 23, 2020
8b219d4
Merge branch 'reduce-production-image-size' of github.com:kuzzleio/ku…
Jun 23, 2020
3764998
replace everest by scratch
Jun 24, 2020
5904564
Merge branch 'reduce-production-image-size' of github.com:kuzzleio/ku…
Jun 24, 2020
2525a86
fix scratch image
Jun 24, 2020
1ea882f
factorize steps
Jun 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

6 changes: 3 additions & 3 deletions .ci/privatebuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -68,11 +68,11 @@ ENV NODE_ENV=production

COPY --from=dependencies /var/app/ /var/app/

RUN ln -s /var/app/docker-compose/scripts/run.sh /usr/local/bin/kuzzle \
RUN ln -s /var/app/docker/scripts/run.sh /usr/local/bin/kuzzle \
&& chmod a+x /usr/local/bin/kuzzle \
&& chmod a+x /var/app/docker-compose/scripts/docker-entrypoint.sh
&& chmod a+x /var/app/docker/scripts/docker-entrypoint.sh

ENTRYPOINT ["/var/app/docker-compose/scripts/docker-entrypoint.sh"]
ENTRYPOINT ["/var/app/docker/scripts/docker-entrypoint.sh"]

CMD ["kuzzle", "start"]

2 changes: 2 additions & 0 deletions .ci/scripts/install-plugins.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -ex

working_dir=$(pwd)
plugins_dir="plugins/enabled"
protocols_dir="protocols/enabled"
33 changes: 4 additions & 29 deletions .ci/scripts/run-test-arm.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/sh

set -e

elastic_host=${kuzzle_services__storageEngine__client__node:-http://elasticsearch:9200}
set -ex

NODE_VERSION=$NODE_12_VERSION

@@ -12,33 +10,10 @@ export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh"
nvm use $NODE_VERSION


echo "[$(date --rfc-3339 seconds)] - Waiting for elasticsearch to be available"
while ! curl -f -s -o /dev/null "$elastic_host"
do
echo "[$(date --rfc-3339 seconds)] - Still trying to connect to $elastic_host"
sleep 1
done
# create a tmp index just to force the shards to init
echo "[$(date --rfc-3339 seconds)] - Elasticsearch is up. Waiting for shards to be active (can take a while)"
E=$(curl -s "$elastic_host/_cluster/health?wait_for_status=yellow&timeout=60s")

if ! (echo ${E} | grep -E '"status":"(yellow|green)"' > /dev/null); then
echo "============ Cluster health response"
echo $E
echo "============ Cluster allocation explanation"
curl -s http://$elastic_host/_cluster/allocation/explain?pretty
echo "[$(date --rfc-3339 seconds)] - Could not connect to elasticsearch in time. Aborting..."
exit 1
fi

node bin/start-kuzzle-server --enable-plugins functional-test-plugin &

echo "[$(date --rfc-3339 seconds)] - Starting Kuzzle..."
while ! curl -f -s -o /dev/null http://localhost:7512
do
echo "[$(date --rfc-3339 seconds)] - Still trying to connect to Kuzzle"
sleep 1
done
echo "[$(date)] - Starting Kuzzle..."

./bin/wait-kuzzle

npm run test:functional
49 changes: 6 additions & 43 deletions .ci/scripts/run-test.sh
Original file line number Diff line number Diff line change
@@ -1,57 +1,20 @@
#!/bin/sh

set -e

elastic_host=${kuzzle_services__storageEngine__client__node:-http://elasticsearch:9200}
set -ex

NODE_VERSION=$NODE_12_VERSION

echo "Testing Kuzzle against node v$NODE_VERSION"
n $NODE_VERSION

npm install --silent --unsafe-perm
npm install --silent --unsafe-perm --only=dev
chmod -R 777 node_modules/
docker-compose/scripts/install-plugins.sh

echo "[$(date --rfc-3339 seconds)] - Waiting for elasticsearch to be available"
spinner="/"
while ! curl -f -s -o /dev/null "$elastic_host"
do
printf '\r'
echo -n "[$(date --rfc-3339 seconds)] - Still trying to connect to $elastic_host [$spinner]"
if [ "$spinner" = "/" ]; then spinner="\\"; else spinner="/" ; fi
sleep 1
done
# create a tmp index just to force the shards to init
echo "[$(date --rfc-3339 seconds)] - Elasticsearch is up. Waiting for shards to be active (can take a while)"
E=$(curl -s "$elastic_host/_cluster/health?wait_for_status=yellow&timeout=60s")

if ! (echo ${E} | grep -E '"status":"(yellow|green)"' > /dev/null); then
echo "============ Cluster health response"
echo $E
echo "============ Cluster allocation explanation"
curl -s http://$elastic_host/_cluster/allocation/explain?pretty
echo "[$(date --rfc-3339 seconds)] - Could not connect to elasticsearch in time. Aborting..."
exit 1
fi

node bin/start-kuzzle-server --enable-plugins functional-test-plugin &
./docker/scripts/install-plugins.sh

echo "[$(date --rfc-3339 seconds)] - Starting Kuzzle..."
timeout=$((20 * 60))
while ! curl -f -s -o /dev/null http://localhost:7512
do
printf '\r'
echo -n "[$(date --rfc-3339 seconds)] - Still trying to connect to Kuzzle [$spinner]"
if [ "$spinner" = "/" ]; then spinner="\\"; else spinner="/" ; fi
echo "[$(date)] - Starting Kuzzle..."

timeout=$((timeout - 1))
if [ $timeout -eq 0 ]; then
echo "[$(date --rfc-3339 seconds)] - Timeout"
fi
node bin/start-kuzzle-server --enable-plugins functional-test-plugin &

sleep 1
done
./bin/wait-kuzzle

npm run test:functional
npm run $KUZZLE_FUNCTIONAL_TESTS
4 changes: 2 additions & 2 deletions .ci/test-aarch64.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ version: '3'
services:
kuzzle:
image: kuzzleio/core-dev-aarch64:2
command: sh -c 'chmod 755 /run-test-arm.sh && /run-test-arm.sh'
command: /run-test-arm.sh
volumes:
- "..:/var/app"
- "./scripts/run-test-arm.sh:/run-test-arm.sh"
@@ -21,7 +21,7 @@ services:
- kuzzle_server__protocols__mqtt__enabled=true
- kuzzle_server__protocols__mqtt__developmentMode=false
- kuzzle_limits__loginsPerSecond=50
- NODE_ENV=production
- NODE_ENV=development
- DEBUG=
- KUZZLE_SECRETS_FILE=/var/app/features-sdk/fixtures/secrets.enc.json
- KUZZLE_VAULT_KEY=secret-password
4 changes: 2 additions & 2 deletions .ci/test-armhf.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ version: '3'
services:
kuzzle:
image: kuzzleio/core-dev-armhf:2
command: sh -c 'chmod 755 /run-test-arm.sh && /run-test-arm.sh'
command: /run-test-arm.sh
volumes:
- "..:/var/app"
- "./scripts/run-test-arm.sh:/run-test-arm.sh"
@@ -21,7 +21,7 @@ services:
- kuzzle_server__protocols__mqtt__enabled=true
- kuzzle_server__protocols__mqtt__developmentMode=false
- kuzzle_limits__loginsPerSecond=50
- NODE_ENV=production
- NODE_ENV=development
- DEBUG=
- KUZZLE_SECRETS_FILE=/var/app/features-sdk/fixtures/secrets.enc.json
- KUZZLE_VAULT_KEY=secret-password
5 changes: 3 additions & 2 deletions .ci/test.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ version: '3'
services:
kuzzle:
image: kuzzleio/core-dev:2
command: sh -c 'chmod 755 /run-test.sh && /run-test.sh'
command: /run-test.sh
volumes:
- "..:/var/app"
- "./scripts/run-test.sh:/run-test.sh"
@@ -27,10 +27,11 @@ services:
- kuzzle_limits__loginsPerSecond=50
- kuzzle_server__protocols__mqtt__enabled=true
- kuzzle_server__protocols__mqtt__developmentMode=false
- NODE_ENV=production
- NODE_ENV=development
- DEBUG
- KUZZLE_SECRETS_FILE=/var/app/features-sdk/fixtures/secrets.enc.json
- KUZZLE_VAULT_KEY=secret-password
- KUZZLE_FUNCTIONAL_TESTS=${KUZZLE_FUNCTIONAL_TESTS:-test:functional}
# Travis env var must be propagated into the container
- TRAVIS
- TRAVIS_COMMIT
16 changes: 0 additions & 16 deletions .ci/wait-kuzzle.sh

This file was deleted.

8 changes: 6 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
**/node_modules
dump
index-dump
vagrant
vagrant/
Vagrantfile
**/.git
/.ci
.ci
.idea
.nyc_output
.sonar
@@ -13,3 +13,7 @@ sonar-project.properties
plugins/available/functional-test-plugin
plugins/enabled/functional-test-plugin
plugins/enabled/dummy

.git/
**Dockerfile
doc/
13 changes: 11 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -118,10 +118,19 @@ jobs:
# ---------------------------------------
- <<: *integration-tests
stage: Integration tests
name: Node.js 12
name: Node.js 12 - Functional tests legacy
env:
- KUZZLE_FUNCTIONAL_TESTS=test:functional:legacy
- *integration-tests-env

- <<: *integration-tests
stage: Integration tests
name: Node.js 12 - Functional tests sdk
env:
- KUZZLE_FUNCTIONAL_TESTS=test:functional:sdk
- *integration-tests-env


# ---------------------------------------
# Cross-platform tests
# ---------------------------------------
@@ -175,7 +184,7 @@ jobs:
language: minimal
services: docker
script:
- MODE=production bash build-docker-images.sh
- MODE=production bash docker/build-docker-images.sh

- <<: *doc-deploy
name: Documentation to next-docs.kuzzle.io
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ We use most of the [NPM Coding Style](https://docs.npmjs.com/misc/coding-style)

## Tools

For development only, we built a specific docker-compose file: `docker-compose/dev.yml`. You can use it to profile, debug, test a variable on the fly, add breakpoints and so on, thanks to [chrome-devtools](https://developer.chrome.com/devtools).
For development only, we built a specific docker-compose file: `docker-compose.yml`. You can use it to profile, debug, test a variable on the fly, add breakpoints and so on, thanks to [chrome-devtools](https://developer.chrome.com/devtools).
Check the logs at the start of Kuzzle using the development docker image to get the appropriate debug URL.

How to run the development stack (needs Docker 1.10+ and Docker Compose 1.8+):
@@ -52,14 +52,14 @@ Everytime a modification is detected in the source files, the server is automati

The development stack include a endpoint to access Kuzzle API through SSL on port `7443`.

The certificates are privately signed, using provided [CA certificate](docker-compose/nginx/kuzzleCA.crt).
The certificates are privately signed, using provided [CA certificate](docker/nginx/kuzzleCA.crt).
Domains accepted:
- localhost
- *.kuzzle.loc

You'll need to import the CA certificate to your browser and possibly your system local authorities to make it verified.
Once done, your browser should not complain when reaching https://localhost:7443.
The CA certificate is here: [docker-compose/nginx/kuzzleCA.crt](docker-compose/nginx/kuzzleCA.crt)
The CA certificate is here: [docker/nginx/kuzzleCA.crt](docker/nginx/kuzzleCA.crt)

Using node.js, for instance when using the sdk, you'll need to pass the CA cert using the `NODE_EXTRA_CA_CERTS` environment variable:

79 changes: 0 additions & 79 deletions Dockerfile

This file was deleted.

Loading