diff --git a/api/Dockerfile b/api/Dockerfile index 7e99cc457..b92e909e4 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,6 +1,7 @@ FROM python:3.10-alpine LABEL Maintainer="Rajesh Rajendran" LABEL Maintainer="KRAIEM Taha Yassine" +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main RUN apk add --no-cache build-base nodejs npm tini ARG envarg # Add Tini diff --git a/api/Dockerfile.alerts b/api/Dockerfile.alerts index 062a1cb3a..5830966b3 100644 --- a/api/Dockerfile.alerts +++ b/api/Dockerfile.alerts @@ -1,6 +1,7 @@ FROM python:3.10-alpine LABEL Maintainer="Rajesh Rajendran" LABEL Maintainer="KRAIEM Taha Yassine" +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main RUN apk add --no-cache build-base tini ARG envarg ENV APP_NAME=alerts \ @@ -16,4 +17,4 @@ COPY . . RUN mv env.default .env && mv app_alerts.py app.py && mv entrypoint_alerts.sh entrypoint.sh ENTRYPOINT ["/sbin/tini", "--"] -CMD ./entrypoint.sh \ No newline at end of file +CMD ./entrypoint.sh diff --git a/api/chalicelib/core/users.py b/api/chalicelib/core/users.py index 78499860b..1535534c8 100644 --- a/api/chalicelib/core/users.py +++ b/api/chalicelib/core/users.py @@ -241,7 +241,6 @@ def get(user_id, tenant_id): (CASE WHEN role = 'owner' THEN TRUE ELSE FALSE END) AS super_admin, (CASE WHEN role = 'admin' THEN TRUE ELSE FALSE END) AS admin, (CASE WHEN role = 'member' THEN TRUE ELSE FALSE END) AS member, - api_key, TRUE AS has_password FROM public.users LEFT JOIN public.basic_authentication ON users.user_id=basic_authentication.user_id WHERE diff --git a/api/chalicelib/core/weekly_report.py b/api/chalicelib/core/weekly_report.py index 952bf584b..afb0843ce 100644 --- a/api/chalicelib/core/weekly_report.py +++ b/api/chalicelib/core/weekly_report.py @@ -32,7 +32,8 @@ def cron(): if not helper.has_smtp(): print("!!! No SMTP configuration found, ignoring weekly report") return - with pg_client.PostgresClient(long_query=True) as cur: + _now = TimeUTC.now() + with pg_client.PostgresClient(unlimited_query=True) as cur: params = {"tomorrow": TimeUTC.midnight(delta_days=1), "3_days_ago": TimeUTC.midnight(delta_days=-3), "1_week_ago": TimeUTC.midnight(delta_days=-7), @@ -86,6 +87,9 @@ def cron(): AND issues.timestamp >= %(5_week_ago)s ) AS month_1_issues ON (TRUE);"""), params) projects_data = cur.fetchall() + _now2 = TimeUTC.now() + print(f">> Weekly report query: {_now2 - _now} ms") + _now = _now2 emails_to_send = [] for p in projects_data: params["project_id"] = p["project_id"] @@ -116,6 +120,9 @@ def cron(): ) AS timestamp_i ORDER BY timestamp_i;""", params)) days_partition = cur.fetchall() + _now2 = TimeUTC.now() + print(f">> Weekly report s-query-1: {_now2 - _now} ms project_id: {p['project_id']}") + _now = _now2 max_days_partition = max(x['issues_count'] for x in days_partition) for d in days_partition: if max_days_partition <= 0: @@ -132,6 +139,9 @@ def cron(): ORDER BY count DESC, type LIMIT 4;""", params)) issues_by_type = cur.fetchall() + _now2 = TimeUTC.now() + print(f">> Weekly report s-query-1: {_now2 - _now} ms project_id: {p['project_id']}") + _now = _now2 max_issues_by_type = sum(i["count"] for i in issues_by_type) for i in issues_by_type: i["type"] = get_issue_title(i["type"]) @@ -161,6 +171,9 @@ def cron(): GROUP BY timestamp_i ORDER BY timestamp_i;""", params)) issues_breakdown_by_day = cur.fetchall() + _now2 = TimeUTC.now() + print(f">> Weekly report s-query-1: {_now2 - _now} ms project_id: {p['project_id']}") + _now = _now2 for i in issues_breakdown_by_day: i["sum"] = sum(x["count"] for x in i["partition"]) for j in i["partition"]: @@ -207,6 +220,9 @@ def cron(): GROUP BY type ORDER BY issue_count DESC;""", params)) issues_breakdown_list = cur.fetchall() + _now2 = TimeUTC.now() + print(f">> Weekly report s-query-1: {_now2 - _now} ms project_id: {p['project_id']}") + _now = _now2 if len(issues_breakdown_list) > 4: others = {"type": "Others", "sessions_count": sum(i["sessions_count"] for i in issues_breakdown_list[4:]), diff --git a/backend/Dockerfile b/backend/Dockerfile index 3c3bebc3b..132fef1b0 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -19,6 +19,7 @@ RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o service -tags musl openrep FROM alpine AS entrypoint +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main RUN apk add --no-cache ca-certificates ENV TZ=UTC \ diff --git a/ee/api/Dockerfile b/ee/api/Dockerfile index 9e40d3ca6..1c5be7f36 100644 --- a/ee/api/Dockerfile +++ b/ee/api/Dockerfile @@ -1,6 +1,7 @@ FROM python:3.10-alpine LABEL Maintainer="Rajesh Rajendran" LABEL Maintainer="KRAIEM Taha Yassine" +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main RUN apk add --no-cache build-base libressl libffi-dev libressl-dev libxslt-dev libxml2-dev xmlsec-dev xmlsec nodejs npm tini ARG envarg ENV SOURCE_MAP_VERSION=0.7.4 \ @@ -20,4 +21,4 @@ COPY . . RUN mv env.default .env && mv /work_tmp/node_modules sourcemap-reader/. ENTRYPOINT ["/sbin/tini", "--"] -CMD ./entrypoint.sh \ No newline at end of file +CMD ./entrypoint.sh diff --git a/ee/api/Dockerfile.alerts b/ee/api/Dockerfile.alerts index 6382fa27f..a3bee2a28 100644 --- a/ee/api/Dockerfile.alerts +++ b/ee/api/Dockerfile.alerts @@ -1,6 +1,7 @@ FROM python:3.10-alpine LABEL Maintainer="Rajesh Rajendran" LABEL Maintainer="KRAIEM Taha Yassine" +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main RUN apk add --no-cache build-base tini ARG envarg ENV APP_NAME=alerts \ @@ -16,4 +17,4 @@ COPY . . RUN mv env.default .env && mv app_alerts.py app.py && mv entrypoint_alerts.sh entrypoint.sh ENTRYPOINT ["/sbin/tini", "--"] -CMD ./entrypoint.sh \ No newline at end of file +CMD ./entrypoint.sh diff --git a/ee/api/Dockerfile.crons b/ee/api/Dockerfile.crons index 155180006..e29b4440f 100644 --- a/ee/api/Dockerfile.crons +++ b/ee/api/Dockerfile.crons @@ -1,6 +1,7 @@ FROM python:3.10-alpine LABEL Maintainer="Rajesh Rajendran" LABEL Maintainer="KRAIEM Taha Yassine" +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main RUN apk add --no-cache build-base tini ARG envarg ENV APP_NAME=crons \ diff --git a/ee/api/chalicelib/core/users.py b/ee/api/chalicelib/core/users.py index 815d39106..ff43cca41 100644 --- a/ee/api/chalicelib/core/users.py +++ b/ee/api/chalicelib/core/users.py @@ -274,7 +274,6 @@ def get(user_id, tenant_id): (CASE WHEN role = 'owner' THEN TRUE ELSE FALSE END) AS super_admin, (CASE WHEN role = 'admin' THEN TRUE ELSE FALSE END) AS admin, (CASE WHEN role = 'member' THEN TRUE ELSE FALSE END) AS member, - api_key, origin, role_id, roles.name AS role_name, diff --git a/ee/api/chalicelib/core/weekly_report.py b/ee/api/chalicelib/core/weekly_report.py index 90256d795..96bda859e 100644 --- a/ee/api/chalicelib/core/weekly_report.py +++ b/ee/api/chalicelib/core/weekly_report.py @@ -32,7 +32,8 @@ def cron(): if not helper.has_smtp(): print("!!! No SMTP configuration found, ignoring weekly report") return - with pg_client.PostgresClient(long_query=True) as cur: + _now = TimeUTC.now() + with pg_client.PostgresClient(unlimited_query=True) as cur: params = {"tomorrow": TimeUTC.midnight(delta_days=1), "3_days_ago": TimeUTC.midnight(delta_days=-3), "1_week_ago": TimeUTC.midnight(delta_days=-7), @@ -87,6 +88,9 @@ def cron(): AND issues.timestamp >= %(5_week_ago)s ) AS month_1_issues ON (TRUE);"""), params) projects_data = cur.fetchall() + _now2 = TimeUTC.now() + print(f">> Weekly report query: {_now2 - _now} ms") + _now = _now2 emails_to_send = [] for p in projects_data: params["project_id"] = p["project_id"] @@ -117,6 +121,9 @@ def cron(): ) AS timestamp_i ORDER BY timestamp_i;""", params)) days_partition = cur.fetchall() + _now2 = TimeUTC.now() + print(f">> Weekly report s-query-1: {_now2 - _now} ms project_id: {p['project_id']}") + _now = _now2 max_days_partition = max(x['issues_count'] for x in days_partition) for d in days_partition: if max_days_partition <= 0: @@ -133,6 +140,9 @@ def cron(): ORDER BY count DESC, type LIMIT 4;""", params)) issues_by_type = cur.fetchall() + _now2 = TimeUTC.now() + print(f">> Weekly report s-query-1: {_now2 - _now} ms project_id: {p['project_id']}") + _now = _now2 max_issues_by_type = sum(i["count"] for i in issues_by_type) for i in issues_by_type: i["type"] = get_issue_title(i["type"]) @@ -162,6 +172,9 @@ def cron(): GROUP BY timestamp_i ORDER BY timestamp_i;""", params)) issues_breakdown_by_day = cur.fetchall() + _now2 = TimeUTC.now() + print(f">> Weekly report s-query-1: {_now2 - _now} ms project_id: {p['project_id']}") + _now = _now2 for i in issues_breakdown_by_day: i["sum"] = sum(x["count"] for x in i["partition"]) for j in i["partition"]: @@ -208,6 +221,9 @@ def cron(): GROUP BY type ORDER BY issue_count DESC;""", params)) issues_breakdown_list = cur.fetchall() + _now2 = TimeUTC.now() + print(f">> Weekly report s-query-1: {_now2 - _now} ms project_id: {p['project_id']}") + _now = _now2 if len(issues_breakdown_list) > 4: others = {"type": "Others", "sessions_count": sum(i["sessions_count"] for i in issues_breakdown_list[4:]), diff --git a/ee/api/entrypoint.sh b/ee/api/entrypoint.sh index 60aba72a6..724c7d6f1 100755 --- a/ee/api/entrypoint.sh +++ b/ee/api/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/sh sh env_vars.sh -source .env.override +source /tmp/.env.override cd sourcemap-reader nohup npm start &> /tmp/sourcemap-reader.log & cd .. diff --git a/ee/api/entrypoint_alerts.sh b/ee/api/entrypoint_alerts.sh index d2e6d677b..04e60ce1b 100755 --- a/ee/api/entrypoint_alerts.sh +++ b/ee/api/entrypoint_alerts.sh @@ -1,4 +1,4 @@ #!/bin/sh sh env_vars.sh -source .env.override +source /tmp/.env.override uvicorn app:app --host 0.0.0.0 --reload diff --git a/ee/api/entrypoint_crons.sh b/ee/api/entrypoint_crons.sh index ef29496b2..b6c03bf75 100755 --- a/ee/api/entrypoint_crons.sh +++ b/ee/api/entrypoint_crons.sh @@ -1,4 +1,4 @@ #!/bin/sh sh env_vars.sh -source .env.override +source /tmp/.env.override python app_crons.py $ACTION diff --git a/ee/api/env_vars.sh b/ee/api/env_vars.sh index a17610aab..22db81961 100755 --- a/ee/api/env_vars.sh +++ b/ee/api/env_vars.sh @@ -1,12 +1,12 @@ #!/bin/sh -touch .env.override +touch /tmp/.env.override if [[ -z "${ENV_CONFIG_OVERRIDE_PATH}" ]]; then echo 'no env-override' else override=$ENV_CONFIG_OVERRIDE_PATH if [ -f "$override" ]; then - cp $override .env.override + cp $override /tmp/.env.override else echo "$override does not exist." fi diff --git a/ee/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql b/ee/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql index 1ea5c6ab6..cdf316fa4 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql @@ -56,6 +56,7 @@ ALTER TABLE IF EXISTS events.resources PRIMARY KEY (session_id, message_id, timestamp); COMMIT; +CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS autocomplete_unique_project_id_md5value_type_idx ON autocomplete (project_id, md5(value), type); CREATE INDEX CONCURRENTLY IF NOT EXISTS projects_tenant_id_idx ON public.projects (tenant_id); CREATE INDEX CONCURRENTLY IF NOT EXISTS projects_project_id_deleted_at_n_idx ON public.projects (project_id) WHERE deleted_at IS NULL; ALTER TYPE metric_type ADD VALUE IF NOT EXISTS 'funnel'; @@ -211,4 +212,5 @@ $$ END IF; END $$; +DROP INDEX IF EXISTS autocomplete_unique; COMMIT; \ No newline at end of file diff --git a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql index b80486e5b..e236ce90e 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -658,7 +658,7 @@ $$ project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE ); - CREATE UNIQUE INDEX IF NOT EXISTS autocomplete_unique ON autocomplete (project_id, md5(value), type); + CREATE UNIQUE INDEX IF NOT EXISTS autocomplete_unique_project_id_md5value_type_idx ON autocomplete (project_id, md5(value), type); CREATE index IF NOT EXISTS autocomplete_project_id_idx ON autocomplete (project_id); CREATE INDEX IF NOT EXISTS autocomplete_type_idx ON public.autocomplete (type); diff --git a/ee/utilities/Dockerfile b/ee/utilities/Dockerfile index f3e605ccc..3c9d2f600 100644 --- a/ee/utilities/Dockerfile +++ b/ee/utilities/Dockerfile @@ -1,5 +1,6 @@ FROM node:18-alpine LABEL Maintainer="KRAIEM Taha Yassine" +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main RUN apk add --no-cache tini git libc6-compat && ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2 ARG envarg ENV ENTERPRISE_BUILD=${envarg} \ @@ -12,4 +13,4 @@ COPY package-lock.json . RUN npm install COPY . . ENTRYPOINT ["/sbin/tini", "--"] -CMD npm start \ No newline at end of file +CMD npm start diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 198c03c7a..b87d5c172 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -14,5 +14,6 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf # Default step in docker build FROM nginx:alpine LABEL maintainer=Rajesh +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main COPY --from=builder /work/public /var/www/openreplay COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/frontend/app/components/Header/Header.js b/frontend/app/components/Header/Header.js index 9e6efa0de..9726e83ee 100644 --- a/frontend/app/components/Header/Header.js +++ b/frontend/app/components/Header/Header.js @@ -64,7 +64,7 @@ const Header = (props) => { }, [siteId]) return ( -
+
diff --git a/frontend/app/components/Onboarding/components/OnboardingTabs/InstallDocs/InstallDocs.js b/frontend/app/components/Onboarding/components/OnboardingTabs/InstallDocs/InstallDocs.js index a89904907..d999397f1 100644 --- a/frontend/app/components/Onboarding/components/OnboardingTabs/InstallDocs/InstallDocs.js +++ b/frontend/app/components/Onboarding/components/OnboardingTabs/InstallDocs/InstallDocs.js @@ -4,7 +4,7 @@ import stl from './installDocs.module.css' import cn from 'classnames' import Highlight from 'react-highlight' import CircleNumber from '../../CircleNumber' -import { Slider, CopyButton } from 'UI' +import { CopyButton } from 'UI' import { Toggler } from 'UI'; const installationCommand = 'npm i @openreplay/tracker' @@ -30,8 +30,7 @@ function MyApp() { //... }` -function InstallDocs({ siteId, sites }) { - const site = sites.find(s => s.id === siteId); +function InstallDocs({ site }) { const _usageCode = usageCode.replace('PROJECT_KEY', site.projectKey) const _usageCodeSST = usageCodeSST.replace('PROJECT_KEY', site.projectKey) const [isSpa, setIsSpa] = useState(true) @@ -98,9 +97,6 @@ function InstallDocs({ siteId, sites }) { ) } -// export default InstallDocs - export default connect(state => ({ - siteId: state.getIn([ 'site', 'siteId' ]), - sites: state.getIn([ 'site', 'list' ]), + site: state.getIn([ 'site', 'instance' ]), }))(InstallDocs) \ No newline at end of file diff --git a/frontend/app/components/shared/SessionItem/SessionItem.tsx b/frontend/app/components/shared/SessionItem/SessionItem.tsx index aa5cd479d..17b8122c3 100644 --- a/frontend/app/components/shared/SessionItem/SessionItem.tsx +++ b/frontend/app/components/shared/SessionItem/SessionItem.tsx @@ -109,7 +109,7 @@ function SessionItem(props: RouteComponentProps & Props) {
e.stopPropagation()}>
-
+
-
-
{formatTimeOrDate(startedAt, timezone) }
+
+
+ +
{!isAssist && ( <> diff --git a/peers/Dockerfile b/peers/Dockerfile index c95415177..98475f750 100644 --- a/peers/Dockerfile +++ b/peers/Dockerfile @@ -1,6 +1,7 @@ FROM node:18-alpine LABEL Maintainer="KRAIEM Taha Yassine" RUN apk add --no-cache tini +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main ARG envarg ENV ENTERPRISE_BUILD=${envarg} @@ -10,4 +11,4 @@ COPY package-lock.json . RUN npm install COPY . . ENTRYPOINT ["/sbin/tini", "--"] -CMD npm start \ No newline at end of file +CMD npm start diff --git a/scripts/dockerfiles/ingress-controller/Dockerfile b/scripts/dockerfiles/ingress-controller/Dockerfile new file mode 100644 index 000000000..85f58d272 --- /dev/null +++ b/scripts/dockerfiles/ingress-controller/Dockerfile @@ -0,0 +1,5 @@ +from k8s.gcr.io/ingress-nginx/controller:v1.3.0 +# Fix critical vulnerability +user 0 +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main +user 101 diff --git a/scripts/dockerfiles/nginx/Dockerfile b/scripts/dockerfiles/nginx/Dockerfile index 53da15731..caf6b283b 100644 --- a/scripts/dockerfiles/nginx/Dockerfile +++ b/scripts/dockerfiles/nginx/Dockerfile @@ -1,23 +1,183 @@ -# Ability to add sticky sessions using any parameters -FROM openresty/openresty:buster as builder -workdir /work -ADD https://github.com/openresty/lua-resty-balancer/archive/refs/heads/master.tar.gz . -RUN apt update && \ - apt install gcc make -y && \ - tar -xf master.tar.gz && \ - cd lua-resty-balancer-master && \ - make +# Dockerfile - alpine +# https://github.com/openresty/docker-openresty + +ARG RESTY_IMAGE_BASE="alpine" +ARG RESTY_IMAGE_TAG="3.16" + +FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG} + +LABEL maintainer="Evan Wies " + +# Docker Build Arguments +ARG RESTY_IMAGE_BASE="alpine" +ARG RESTY_IMAGE_TAG="3.16" +ARG RESTY_VERSION="1.21.4.1" +ARG RESTY_OPENSSL_VERSION="1.1.1p" +ARG RESTY_OPENSSL_PATCH_VERSION="1.1.1f" +ARG RESTY_OPENSSL_URL_BASE="https://www.openssl.org/source" +ARG RESTY_PCRE_VERSION="8.45" +ARG RESTY_PCRE_BUILD_OPTIONS="--enable-jit" +ARG RESTY_PCRE_SHA256="4e6ce03e0336e8b4a3d6c2b70b1c5e18590a5673a98186da90d4f33c23defc09" +ARG RESTY_J="1" +ARG RESTY_CONFIG_OPTIONS="\ + --with-compat \ + --with-file-aio \ + --with-http_addition_module \ + --with-http_auth_request_module \ + --with-http_dav_module \ + --with-http_flv_module \ + --with-http_geoip_module=dynamic \ + --with-http_gunzip_module \ + --with-http_gzip_static_module \ + --with-http_image_filter_module=dynamic \ + --with-http_mp4_module \ + --with-http_random_index_module \ + --with-http_realip_module \ + --with-http_secure_link_module \ + --with-http_slice_module \ + --with-http_ssl_module \ + --with-http_stub_status_module \ + --with-http_sub_module \ + --with-http_v2_module \ + --with-http_xslt_module=dynamic \ + --with-ipv6 \ + --with-mail \ + --with-mail_ssl_module \ + --with-md5-asm \ + --with-sha1-asm \ + --with-stream \ + --with-stream_ssl_module \ + --with-threads \ + " +ARG RESTY_CONFIG_OPTIONS_MORE="" +ARG RESTY_LUAJIT_OPTIONS="--with-luajit-xcflags='-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT'" +ARG RESTY_PCRE_OPTIONS="--with-pcre-jit" + +ARG RESTY_ADD_PACKAGE_BUILDDEPS="" +ARG RESTY_ADD_PACKAGE_RUNDEPS="" +ARG RESTY_EVAL_PRE_CONFIGURE="" +ARG RESTY_EVAL_POST_MAKE="" + +# These are not intended to be user-specified +ARG _RESTY_CONFIG_DEPS="--with-pcre \ + --with-cc-opt='-DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl/include' \ + --with-ld-opt='-L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl/lib -Wl,-rpath,/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl/lib' \ + " + +LABEL resty_image_base="${RESTY_IMAGE_BASE}" +LABEL resty_image_tag="${RESTY_IMAGE_TAG}" +LABEL resty_version="${RESTY_VERSION}" +LABEL resty_openssl_version="${RESTY_OPENSSL_VERSION}" +LABEL resty_openssl_patch_version="${RESTY_OPENSSL_PATCH_VERSION}" +LABEL resty_openssl_url_base="${RESTY_OPENSSL_URL_BASE}" +LABEL resty_pcre_version="${RESTY_PCRE_VERSION}" +LABEL resty_pcre_build_options="${RESTY_PCRE_BUILD_OPTIONS}" +LABEL resty_pcre_sha256="${RESTY_PCRE_SHA256}" +LABEL resty_config_options="${RESTY_CONFIG_OPTIONS}" +LABEL resty_config_options_more="${RESTY_CONFIG_OPTIONS_MORE}" +LABEL resty_config_deps="${_RESTY_CONFIG_DEPS}" +LABEL resty_add_package_builddeps="${RESTY_ADD_PACKAGE_BUILDDEPS}" +LABEL resty_add_package_rundeps="${RESTY_ADD_PACKAGE_RUNDEPS}" +LABEL resty_eval_pre_configure="${RESTY_EVAL_PRE_CONFIGURE}" +LABEL resty_eval_post_make="${RESTY_EVAL_POST_MAKE}" +LABEL resty_luajit_options="${RESTY_LUAJIT_OPTIONS}" +LABEL resty_pcre_options="${RESTY_PCRE_OPTIONS}" + +RUN apk add --no-cache --virtual .build-deps \ + build-base \ + coreutils \ + curl \ + gd-dev \ + geoip-dev \ + libxslt-dev \ + linux-headers \ + make \ + perl-dev \ + readline-dev \ + zlib-dev \ + ${RESTY_ADD_PACKAGE_BUILDDEPS} \ + && apk add --no-cache \ + gd \ + geoip \ + libgcc \ + libxslt \ + zlib \ + ${RESTY_ADD_PACKAGE_RUNDEPS} \ + && cd /tmp \ + && if [ -n "${RESTY_EVAL_PRE_CONFIGURE}" ]; then eval $(echo ${RESTY_EVAL_PRE_CONFIGURE}); fi \ + && cd /tmp \ + && curl -fSL "${RESTY_OPENSSL_URL_BASE}/openssl-${RESTY_OPENSSL_VERSION}.tar.gz" -o openssl-${RESTY_OPENSSL_VERSION}.tar.gz \ + && tar xzf openssl-${RESTY_OPENSSL_VERSION}.tar.gz \ + && cd openssl-${RESTY_OPENSSL_VERSION} \ + && if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-5) = "1.1.1" ] ; then \ + echo 'patching OpenSSL 1.1.1 for OpenResty' \ + && curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-${RESTY_OPENSSL_PATCH_VERSION}-sess_set_get_cb_yield.patch | patch -p1 ; \ + fi \ + && if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-5) = "1.1.0" ] ; then \ + echo 'patching OpenSSL 1.1.0 for OpenResty' \ + && curl -s https://raw.githubusercontent.com/openresty/openresty/ed328977028c3ec3033bc25873ee360056e247cd/patches/openssl-1.1.0j-parallel_build_fix.patch | patch -p1 \ + && curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-${RESTY_OPENSSL_PATCH_VERSION}-sess_set_get_cb_yield.patch | patch -p1 ; \ + fi \ + && ./config \ + no-threads shared zlib -g \ + enable-ssl3 enable-ssl3-method \ + --prefix=/usr/local/openresty/openssl \ + --libdir=lib \ + -Wl,-rpath,/usr/local/openresty/openssl/lib \ + && make -j${RESTY_J} \ + && make -j${RESTY_J} install_sw \ + && cd /tmp \ + && curl -fSL https://downloads.sourceforge.net/project/pcre/pcre/${RESTY_PCRE_VERSION}/pcre-${RESTY_PCRE_VERSION}.tar.gz -o pcre-${RESTY_PCRE_VERSION}.tar.gz \ + && echo "${RESTY_PCRE_SHA256} pcre-${RESTY_PCRE_VERSION}.tar.gz" | shasum -a 256 --check \ + && tar xzf pcre-${RESTY_PCRE_VERSION}.tar.gz \ + && cd /tmp/pcre-${RESTY_PCRE_VERSION} \ + && ./configure \ + --prefix=/usr/local/openresty/pcre \ + --disable-cpp \ + --enable-utf \ + --enable-unicode-properties \ + ${RESTY_PCRE_BUILD_OPTIONS} \ + && make -j${RESTY_J} \ + && make -j${RESTY_J} install \ + && cd /tmp \ + && curl -fSL https://openresty.org/download/openresty-${RESTY_VERSION}.tar.gz -o openresty-${RESTY_VERSION}.tar.gz \ + && tar xzf openresty-${RESTY_VERSION}.tar.gz \ + && cd /tmp/openresty-${RESTY_VERSION} \ + && eval ./configure -j${RESTY_J} ${_RESTY_CONFIG_DEPS} ${RESTY_CONFIG_OPTIONS} ${RESTY_CONFIG_OPTIONS_MORE} ${RESTY_LUAJIT_OPTIONS} ${RESTY_PCRE_OPTIONS} \ + && make -j${RESTY_J} \ + && make -j${RESTY_J} install \ + && cd /tmp \ + && if [ -n "${RESTY_EVAL_POST_MAKE}" ]; then eval $(echo ${RESTY_EVAL_POST_MAKE}); fi \ + && rm -rf \ + openssl-${RESTY_OPENSSL_VERSION}.tar.gz openssl-${RESTY_OPENSSL_VERSION} \ + pcre-${RESTY_PCRE_VERSION}.tar.gz pcre-${RESTY_PCRE_VERSION} \ + openresty-${RESTY_VERSION}.tar.gz openresty-${RESTY_VERSION} \ + && apk del .build-deps \ + && mkdir -p /var/run/openresty \ + && ln -sf /dev/stdout /usr/local/openresty/nginx/logs/access.log \ + && ln -sf /dev/stderr /usr/local/openresty/nginx/logs/error.log + +# Add additional binaries into PATH for convenience +ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin + +# Copy nginx configuration files +COPY nginx.conf /usr/local/openresty/nginx/conf/nginx.conf +COPY nginx.vh.default.conf /etc/nginx/conf.d/default.conf + +CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"] + +# Use SIGQUIT instead of default SIGTERM to cleanly drain requests +# See https://github.com/openresty/docker-openresty/blob/master/README.md#tips--pitfalls +STOPSIGNAL SIGQUIT -FROM openresty/openresty:buster +# Openreplay Custom configs +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main # Adding prometheus monitoring support ADD https://raw.githubusercontent.com/knyar/nginx-lua-prometheus/master/prometheus.lua /usr/local/openresty/lualib/ ADD https://raw.githubusercontent.com/knyar/nginx-lua-prometheus/master/prometheus_keys.lua /usr/local/openresty/lualib/ ADD https://raw.githubusercontent.com/knyar/nginx-lua-prometheus/master/prometheus_resty_counter.lua /usr/local/openresty/lualib/ -COPY --from=builder /work/lua-resty-balancer-master/*.so /usr/local/openresty/lualib/lua-resty-chash/ -COPY --from=builder /work/lua-resty-balancer-master/lib /usr/local/openresty/lualib/lua-resty-chash/lib/ - RUN chmod 0644 /usr/local/openresty/lualib/*.lua # Enabling monitoring on port 9145 diff --git a/scripts/dockerfiles/nginx/nginx.vh.default.conf b/scripts/dockerfiles/nginx/nginx.vh.default.conf new file mode 100644 index 000000000..3ad957225 --- /dev/null +++ b/scripts/dockerfiles/nginx/nginx.vh.default.conf @@ -0,0 +1,58 @@ +# nginx.vh.default.conf -- docker-openresty +# +# This file is installed to: +# `/etc/nginx/conf.d/default.conf` +# +# It tracks the `server` section of the upstream OpenResty's `nginx.conf`. +# +# This config (and any other configs in `etc/nginx/conf.d/`) is loaded by +# default by the `include` directive in `/usr/local/openresty/nginx/conf/nginx.conf`. +# +# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files +# + + +server { + listen 80; + server_name localhost; + + #charset koi8-r; + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/local/openresty/nginx/html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/local/openresty/nginx/html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root /usr/local/openresty/nginx/html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +} diff --git a/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql b/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql index c079b9b69..edc751da9 100644 --- a/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql +++ b/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql @@ -45,6 +45,7 @@ ALTER TABLE IF EXISTS events.resources PRIMARY KEY (session_id, message_id, timestamp); COMMIT; +CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS autocomplete_unique_project_id_md5value_type_idx ON autocomplete (project_id, md5(value), type); CREATE INDEX CONCURRENTLY IF NOT EXISTS projects_project_id_deleted_at_n_idx ON public.projects (project_id) WHERE deleted_at IS NULL; ALTER TYPE metric_type ADD VALUE IF NOT EXISTS 'funnel'; @@ -199,4 +200,5 @@ $$ END IF; END $$; +DROP INDEX IF EXISTS autocomplete_unique; COMMIT; \ No newline at end of file diff --git a/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 797460ee8..5f23d7a79 100644 --- a/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -839,7 +839,7 @@ $$ project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE ); - CREATE UNIQUE INDEX autocomplete_unique ON autocomplete (project_id, md5(value), type); + CREATE UNIQUE INDEX autocomplete_unique_project_id_md5value_type_idx ON autocomplete (project_id, md5(value), type); CREATE index autocomplete_project_id_idx ON autocomplete (project_id); CREATE INDEX autocomplete_type_idx ON public.autocomplete (type); diff --git a/utilities/Dockerfile b/utilities/Dockerfile index 7c3a66719..cb9d081f1 100644 --- a/utilities/Dockerfile +++ b/utilities/Dockerfile @@ -1,6 +1,7 @@ FROM node:18-alpine LABEL Maintainer="KRAIEM Taha Yassine" RUN apk add --no-cache tini +RUN apk upgrade busybox --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main ARG envarg ENV ENTERPRISE_BUILD=${envarg} \ MAXMINDDB_FILE=/root/geoip.mmdb @@ -12,4 +13,4 @@ COPY package-lock.json . RUN npm install COPY . . ENTRYPOINT ["/sbin/tini", "--"] -CMD npm start \ No newline at end of file +CMD npm start