diff --git a/.github/actions/dockerhub/action.yml b/.github/actions/dockerhub/action.yml deleted file mode 100644 index bd1ddacecb..0000000000 --- a/.github/actions/dockerhub/action.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Build and Deploy Docker -description: Build and deploy Docker image - -inputs: - DOCKER_USERNAME: - description: Dockerhub Username - required: true - DOCKER_PASSWORD: - description: Dockerhub Username - required: true - BRANCH: - description: Branch to use in the build and deploy script - required: true - -runs: - using: "composite" - steps: - - name: Create JS from TS files - run: | - npm ci - npm run build - shell: bash - - - name: Build and deploy Docker images - run: | - ./docker/build-docker-images.sh - env: - MODE: production - BRANCH: ${{ inputs.BRANCH }} - DOCKER_USERNAME: ${{ inputs.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ inputs.DOCKER_PASSWORD }} - shell: bash diff --git a/.github/workflows/kuzzle-core.yml b/.github/workflows/kuzzle-core.yml new file mode 100644 index 0000000000..f89fcd80ae --- /dev/null +++ b/.github/workflows/kuzzle-core.yml @@ -0,0 +1,42 @@ +name: kuzzleio/kuzzle + +on: + push: + branches: + - master + +jobs: + dockerhub-deploy: + name: Kuzzle core Node.js + runs-on: ubuntu-22.04 + steps: + - name: Checkout project + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Get current version from package.json + shell: bash + id: get-version + run: | + echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT + echo "major-version=$(jq -r .version package.json | cut -d. -f 1)" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/images/kuzzle/Dockerfile + push: true + platforms: "linux/amd64,linux/arm64" + tags: kuzzleio/kuzzle:${{ steps.get-version.outputs.major-version }},kuzzleio/kuzzle:latest,kuzzleio/kuzzle:${{ steps.get-version.outputs.version }} diff --git a/.github/workflows/kuzzle-plugin-dev.yml b/.github/workflows/kuzzle-plugin-dev.yml new file mode 100644 index 0000000000..0e1bf25d95 --- /dev/null +++ b/.github/workflows/kuzzle-plugin-dev.yml @@ -0,0 +1,42 @@ +name: kuzzleio/plugin-dev + +on: + push: + branches: + - master + +jobs: + dockerhub-deploy: + name: Kuzzle plugin-dev Node.js + runs-on: ubuntu-22.04 + steps: + - name: Checkout project + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Get current version from package.json + shell: bash + id: get-version + run: | + echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT + echo "major-version=$(jq -r .version package.json | cut -d. -f 1)" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/images/plugin-dev/Dockerfile + push: true + platforms: "linux/amd64,linux/arm64" + tags: kuzzleio/plugin-dev:${{ steps.get-version.outputs.major-version }},kuzzleio/plugin-dev:latest,kuzzleio/plugin-dev:${{ steps.get-version.outputs.version }} diff --git a/.github/workflows/kuzzle-runner.workflow.yml b/.github/workflows/kuzzle-runner.workflow.yml index 2560b52686..9c1414c454 100644 --- a/.github/workflows/kuzzle-runner.workflow.yml +++ b/.github/workflows/kuzzle-runner.workflow.yml @@ -22,7 +22,6 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - id: buildx uses: docker/setup-buildx-action@v3 - name: Login to DockerHub diff --git a/.github/workflows/workflow-deployments.yaml b/.github/workflows/workflow-deployments.yaml index 4c97ca1cd7..48aa1ff557 100644 --- a/.github/workflows/workflow-deployments.yaml +++ b/.github/workflows/workflow-deployments.yaml @@ -21,11 +21,6 @@ on: default: "20" type: string - docker_platforms: - description: "Docker platforms" - required: true - default: "linux/amd64,linux/arm64" - type: string workflow_dispatch: inputs: doc_deploy: @@ -34,12 +29,6 @@ on: default: true type: boolean - dockerhub_deploy: - description: "Deploy to DockerHub" - required: true - default: true - type: boolean - npm_deploy: description: "Deploy to NPM" required: true @@ -64,11 +53,6 @@ on: default: "20" type: string - docker_platforms: - description: "Docker platforms" - required: true - default: "linux/amd64,linux/arm64" - type: string jobs: # ----------------------------------------------------------------------------- @@ -99,57 +83,6 @@ jobs: ref: ${{ github.ref_name == 'master' && 'master' || 'develop' }} client_payload: '{"repo_name":"${{ steps.extract-refs.outputs.repo }}","branch":"${{ github.head_ref }}","version":"${{ steps.extract-refs.outputs.major-version }}"}' - dockerhub-deploy: - name: Build and deploy images to Dockerhub - if: ${{ (github.event_name != 'workflow_dispatch' || inputs.dockerhub_deploy) && github.ref_name == 'master' }} - runs-on: ubuntu-22.04 - steps: - - name: Checkout project - uses: actions/checkout@v3 - - - name: Install additional libraries - uses: ./.github/actions/install-packages - - - name: Node version ${{ inputs.node_lts_active_version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ inputs.node_lts_active_version }} - cache: 'npm' - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Get current version from package.json - shell: bash - id: get-version - run: | - echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT - echo "major-version=$(jq -r .version package.json | cut -d. -f 1)" >> $GITHUB_OUTPUT - - - name: Build TS files - run: | - npm ci - npm run build - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: ./docker/images/kuzzle/Dockerfile - push: true - platforms: ${{ inputs.docker_platforms }} - tags: kuzzleio/kuzzle:${{ steps.get-version.outputs.major-version }},kuzzleio/kuzzle:latest,kuzzleio/kuzzle:${{ steps.get-version.outputs.version }} - npm-deploy: name: Build and deploy release on NPM.js if: ${{ (github.event_name != 'workflow_dispatch' || inputs.npm_deploy) && github.ref_name == 'master' }} diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index 8fdb502ae4..229e189275 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -11,7 +11,6 @@ env: NODE_LTS_MAINTENANCE_VERSION: "16" NODE_LTS_ACTIVE_VERSION: "18" NODE_LTS_CURRENT_VERSION: "20" - DOCKER_PLATFORMS: "linux/amd64,linux/arm64" jobs: prepare-matrix: @@ -26,7 +25,6 @@ jobs: node_lts_maintenance_version: ${{ env.NODE_LTS_MAINTENANCE_VERSION }} node_lts_active_version: ${{ env.NODE_LTS_ACTIVE_VERSION }} node_lts_current_version: ${{ env.NODE_LTS_CURRENT_VERSION }} - docker_platforms: ${{ env.DOCKER_PLATFORMS }} error-codes-check: name: Documentation - Error codes check @@ -213,4 +211,3 @@ jobs: node_lts_maintenance_version: ${{ needs.prepare-matrix.outputs.node_lts_maintenance_version }} node_lts_active_version: ${{ needs.prepare-matrix.outputs.node_lts_active_version }} node_lts_current_version: ${{ needs.prepare-matrix.outputs.node_lts_current_version }} - docker_platforms: ${{ needs.prepare-matrix.outputs.docker_platforms }} diff --git a/docker/build-docker-images.sh b/docker/build-docker-images.sh deleted file mode 100755 index f4028a66d5..0000000000 --- a/docker/build-docker-images.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash - -set -ex - -kuzzle_latest_major=2 - -# Arguments - -mode=$MODE -branch=$BRANCH - -if [ -z "$mode" ]; then - echo "This script has three mode that you can use with the variable MODE" - echo " - MODE=test (or empty string): Just print the command that will be run in other modes" - echo " - MODE=local: Build and tag images locally" - echo " - MODE=production: Build and tag images then push them to Dockerhub" - echo "" -fi - -################################################################################ -# Script used to build kuzzleio/plugin-dev and kuzzleio/kuzzle Docker images ## -################################################################################ - -print_something() { - something=$1 - - echo "" - echo "##############################################################" - echo "#" - echo "# $something" - echo "#" - echo "" -} - -run_or_echo () { - command=$1 - - if [ "$mode" == "production" ] || [ "$mode" == "local" ]; then - $command - else - echo "> $command" - fi -} - -docker_build() { - local image=$1 - local kuzzle_tag=$2 - local dockerfile_path="./docker/images/$3/Dockerfile" - - print_something "Build image kuzzleio/$image:$kuzzle_tag" - - run_or_echo "docker build -f $dockerfile_path -t kuzzleio/$image:$kuzzle_tag ." -} - -docker_tag() { - local image=$1 - local from_tag=$2 - local to_tag=$3 - - print_something "Tag image kuzzleio/$image:$from_tag to kuzzleio/$image:$to_tag" - - run_or_echo "docker tag kuzzleio/$image:$from_tag kuzzleio/$image:$to_tag" -} - -docker_push() { - local image=$1 - local tag=$2 - - if [ "$mode" == "local" ]; then - return - fi - - print_something "Push image kuzzleio/$image:$tag to Dockerhub" - - - run_or_echo "docker push kuzzleio/$image:$tag" -} - -if [ "$mode" == "production" ]; then - if [ -z "$DOCKER_PASSWORD" ]; then - echo "Unable to find DOCKER_PASSWORD for account kuzzleteam" - exit 1 - fi - - run_or_echo "docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD" -fi - -if [[ "$BRANCH" == *"-dev" ]]; then - # Build triggered by a merge on branch *-dev - # image name example: kuzzleio/kuzzle:2-dev - docker_build 'plugin-dev' "$BRANCH" 'plugin-dev' - docker_push 'plugin-dev' "$BRANCH" - - docker_build 'kuzzle' "$BRANCH" 'kuzzle' - docker_push 'kuzzle' "$BRANCH" - -elif [[ "$BRANCH" == "master" ]] || [[ "$BRANCH" == *"-stable" ]]; then - release_tag=$(grep version package.json | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') - major_version=$(echo $release_tag | cut -d. -f 1) - - # Build triggered by a new release - # image name example: kuzzleio/kuzzle:1.10.3 - docker_build 'plugin-dev' "$release_tag" 'plugin-dev' - docker_push 'plugin-dev' "$release_tag" - - docker_build 'kuzzle' "$release_tag" 'kuzzle' - docker_push 'kuzzle' "$release_tag" - - # If this is a release of the current major version - # we can push with the 'latest' tag - # image name example: kuzzleio/kuzzle:latest - if [[ "$major_version" == "$kuzzle_latest_major" ]]; then - docker_tag 'plugin-dev' "$release_tag" 'latest' - docker_tag 'kuzzle' "$release_tag" 'latest' - - docker_push 'plugin-dev' 'latest' - docker_push 'kuzzle' 'latest' - fi - - # Also push the major tag. - # This tag is a pointer to the latest version of a major version - # image name example: kuzzleio/kuzzle:1 - docker_tag 'plugin-dev' "$release_tag" "$major_version" - docker_tag 'kuzzle' "$release_tag" "$major_version" - - docker_push 'plugin-dev' "$major_version" - docker_push 'kuzzle' "$major_version" -else - echo "Incorrect value for BRANCH variable ("$BRANCH"). Exiting." -fi - diff --git a/docker/images/kuzzle/Dockerfile b/docker/images/kuzzle/Dockerfile index f10619fbec..16411a9ea1 100644 --- a/docker/images/kuzzle/Dockerfile +++ b/docker/images/kuzzle/Dockerfile @@ -1,7 +1,8 @@ ################################################################################ # Production build image ################################################################################ -FROM node:18-bullseye-slim AS builder +ARG NODE_LTS_VERSION="18" +FROM node:${NODE_LTS_VERSION}-bullseye-slim AS builder RUN set -x \ && apt-get update \ @@ -14,36 +15,28 @@ RUN set -x \ libzmq3-dev \ libunwind-dev -ADD ./bin /app/bin -ADD ./config /app/config -ADD ./lib /app/lib -ADD ./package.json /app/package.json -ADD ./package-lock.json /app/package-lock.json -ADD ./index.js /app/index.js -ADD ./.kuzzlerc.sample.jsonc /app/.kuzzlerc.sample.jsonc - WORKDIR /app -ENV NODE_ENV=production +ADD ./bin bin +ADD ./config config +ADD ./lib lib +ADD ./package.json package.json +ADD ./package-lock.json package-lock.json +ADD ./index.ts index.ts +ADD ./tsconfig.json tsconfig.json -# Install dependencies -RUN npm ci --production +RUN npm ci +RUN npm run build +RUN npm prune --production -ADD ./docker/scripts/clean-node.sh /usr/bin/clean-node +RUN rm -rf tsconfig.json index.ts ADD ./plugins/available/ /app/plugins/available/ -RUN set -x \ - # Remove useless leftover dependencies - && rm -rf node_modules/rxjs/ \ - # Strip binaries - ; strip node_modules/re2/build/Release/re2.node \ - ; true - ################################################################################ # Production build 2 image ################################################################################ -FROM node:18-bullseye-slim AS minifier +FROM node:${NODE_LTS_VERSION}-bullseye-slim AS minifier ENV NODE_ENV=production @@ -58,7 +51,7 @@ RUN set -x \ ################################################################################ # Production image ################################################################################ -FROM node:18-bullseye-slim +FROM node:${NODE_LTS_VERSION}-bullseye-slim LABEL io.kuzzle.vendor="Kuzzle " LABEL description="Run your Kuzzle backend in production mode" diff --git a/docker/images/plugin-dev/Dockerfile b/docker/images/plugin-dev/Dockerfile index 1c147c09d8..6f723fd579 100644 --- a/docker/images/plugin-dev/Dockerfile +++ b/docker/images/plugin-dev/Dockerfile @@ -1,7 +1,8 @@ ################################################################################ # Plugin development build image ################################################################################ -FROM node:18-bullseye-slim as builder +ARG NODE_LTS_VERSION="18" +FROM node:${NODE_LTS_VERSION}-bullseye-slim AS builder RUN set -x \ && apt-get update && apt-get install -y \ @@ -10,42 +11,31 @@ RUN set -x \ g++ \ python3 \ libzmq3-dev \ - libunwind-dev \ - && npm install -g --unsafe-perm --production \ - ergol \ - kourou \ - pm2 \ - && curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | sh -s -- -b /usr/local/bin - -ADD ./bin /app/bin -ADD ./config /app/config -ADD ./lib /app/lib -ADD ./package.json /app/package.json -ADD ./package-lock.json /app/package-lock.json -ADD ./index.js /app/index.js -ADD ./.kuzzlerc.sample.jsonc /app/.kuzzlerc.sample.jsonc + libunwind-dev +RUN npm install ergol kourou WORKDIR /app -# Install dependencies -RUN npm ci --production +ADD ./bin bin +ADD ./config config +ADD ./lib lib +ADD ./package.json package.json +ADD ./package-lock.json package-lock.json +ADD ./index.ts index.ts -ADD ./docker/scripts/clean-node.sh /usr/bin/clean-node +RUN npm ci +RUN npm run build +RUN npm prune --production -ADD ./plugins/available/ /app/plugins/available/ +RUN rm -rf tsconfig.json index.ts -RUN set -x \ - # Remove useless leftover dependencies - && rm -rf node_modules/rxjs/ \ - # Strip binaries - && strip /usr/local/bin/node \ - && strip node_modules/re2/build/Release/re2.node +ADD ./plugins/available/ plugins/available/ ################################################################################ # Plugin development image ################################################################################ -FROM bitnami/minideb:bullseye +FROM node:${NODE_LTS_VERSION}-bullseye-slim LABEL io.kuzzle.vendor="Kuzzle " LABEL description="Develop new plugin or protocol for Kuzzle with ease" diff --git a/docker/scripts/clean-node.sh b/docker/scripts/clean-node.sh deleted file mode 100755 index 03622b88c6..0000000000 --- a/docker/scripts/clean-node.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env sh - -set -e - -# Remove non-production dependencies -npm prune --production - -# Remove useless files -# @todo remove when https://github.com/tj/node-prune/pull/68 is merged -rm -rf .git/ -find . -type d -name "man" | xargs rm -rf -find . -type f \( -name "*.o" -o -name "*.h" -o -name "package-lock.json" -o -name "*.mk" -o -name "*Makefile*" -o -name "*.c" -o -name "*.cpp" -o -name "*.hpp" \) -exec rm {} \; - -# Minify JS & JSON -# I wasn't able to find a portable way to do string comparison with if -( echo $NODE_ENV | grep production ) || exit 0 diff --git a/docker/scripts/docker-compose.test.yml b/docker/scripts/docker-compose.test.yml deleted file mode 100644 index b076010c06..0000000000 --- a/docker/scripts/docker-compose.test.yml +++ /dev/null @@ -1,120 +0,0 @@ -version: '3.4' - -x-kuzzle-config: &kuzzle-config - image: kuzzleio/core-dev:2 - command: sh -c 'chmod 755 /run-test.sh && /run-test.sh' - volumes: - - '.:/var/app' - - './docker/scripts/run-test.sh:/run-test.sh' - - './docker/fixtures:/fixtures' - cap_add: - - SYS_PTRACE - ulimits: - nofile: 65536 - sysctls: - - net.core.somaxconn=8192 - depends_on: - redis: - condition: service_healthy - elasticsearch: - condition: service_healthy - environment: - - kuzzle_services__storageEngine__client__node=http://elasticsearch:9200 - - kuzzle_services__storageEngine__commonMapping__dynamic=true - - kuzzle_services__internalCache__node__host=redis - - kuzzle_services__memoryStorage__node__host=redis - - kuzzle_server__protocols__mqtt__enabled=true - - kuzzle_server__protocols__mqtt__developmentMode=false - - kuzzle_limits__loginsPerSecond=50 - - NODE_ENV=${NODE_ENV:-development} - - DEBUG=${DEBUG:-kuzzle:*,-kuzzle:network:protocols:websocket,-kuzzle:events} - # - DEBUG=${DEBUG:-none} - - DEBUG_DEPTH=${DEBUG_DEPTH:-0} - - DEBUG_MAX_ARRAY_LENGTH=${DEBUG_MAX_ARRAY:-100} - - DEBUG_EXPAND=${DEBUG_EXPAND:-off} - - DEBUG_SHOW_HIDDEN={$DEBUG_SHOW_HIDDEN:-on} - - DEBUG_COLORS=${DEBUG_COLORS:-on} - - KUZZLE_VAULT_KEY=${KUZZLE_VAULT_KEY:-secret-password} - - KUZZLE_SECRETS_FILE=${KUZZLE_SECRETS_FILE:-/var/app/features/fixtures/secrets.enc.json} - # Variables used by the development scripts - - NODE_16_VERSION=16.19.1 - - NODE_18_VERSION=18.17.0 - - NODE_20_VERSION=20.0.0 - - WITHOUT_KUZZLE # Run only Elasticsearch and Redis - - REBUILD # Force a rebuild of npm modules - -services: - nginx: - image: nginx:1.19-alpine - container_name: kuzzle_nginx - depends_on: - - kuzzle_node_1 - - kuzzle_node_2 - - kuzzle_node_3 - ports: - - '7512:7512' - volumes: - - ./docker/nginx-dev:/etc/nginx/conf.d - - kuzzle_node_1: - <<: *kuzzle-config - container_name: kuzzle_node_1 - ports: - - '17510:7512' # Kuzzle API port - - '1883:1883' # Kuzzle MQTT port - - '9229:9229' # Debug port - healthcheck: - test: ['CMD', 'curl', '-f', 'http://kuzzle:7512/_healthcheck'] - timeout: 1s - interval: 2s - retries: 10 - - kuzzle_node_2: - <<: *kuzzle-config - container_name: kuzzle_node_2 - ports: - - '17511:7512' # Kuzzle API port - - '11883:1883' # Kuzzle MQTT port - - '9230:9229' # Debug port - healthcheck: - test: ['CMD', 'curl', '-f', 'http://kuzzle:7512/_healthcheck'] - timeout: 1s - interval: 2s - retries: 10 - - kuzzle_node_3: - <<: *kuzzle-config - container_name: kuzzle_node_3 - ports: - - '17512:7512' # Kuzzle API port - - '11884:1883' # Kuzzle MQTT port - - '9231:9229' # Debug port - healthcheck: - test: ['CMD', 'curl', '-f', 'http://kuzzle:7512/_healthcheck'] - timeout: 1s - interval: 2s - retries: 10 - - redis: - image: redis:6 - container_name: kuzzle_redis - ports: - - '6379:6379' - healthcheck: - test: ['CMD', 'redis-cli', 'ping'] - interval: 1s - timeout: 3s - retries: 30 - - elasticsearch: - image: kuzzleio/elasticsearch:7 - container_name: kuzzle_elasticsearch - ports: - - '9200:9200' - healthcheck: - test: ['CMD', 'curl', '-f', 'http://localhost:9200'] - interval: 2s - timeout: 2s - retries: 10 - ulimits: - nofile: 65536 diff --git a/package-lock.json b/package-lock.json index b279a379ab..a42dfd17f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kuzzle", - "version": "2.27.2", + "version": "2.27.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kuzzle", - "version": "2.27.2", + "version": "2.27.3", "license": "Apache-2.0", "dependencies": { "@elastic/elasticsearch": "https://github.com/elastic/elasticsearch-js/archive/refs/tags/v7.13.0.tar.gz", diff --git a/package.json b/package.json index d9cf3bcecf..9786e120ce 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "kuzzle", "author": "The Kuzzle Team ", - "version": "2.27.2", + "version": "2.27.3", "description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.", "bin": "bin/start-kuzzle-server", "scripts": {