├── server-builder ├── .gitignore ├── build.d │ ├── 00-provision │ ├── 20-hosts │ └── 10-build-tools ├── Dockerfile ├── .editorconfig └── Makefile ├── webapp-builder ├── .gitignore ├── build.d │ ├── 10-yarn-global-modules │ ├── 00-provision │ └── 20-hosts ├── Dockerfile ├── .editorconfig └── README.md ├── .gitignore ├── server-corredor ├── src │ └── healthcheck.sh ├── Makefile ├── build.d │ ├── 00_install │ ├── 10_users │ ├── 80_corteza_ext │ └── 20_unpack └── Dockerfile ├── server ├── Makefile ├── src │ └── healthcheck.sh ├── build.d │ ├── 30_datadir │ ├── 00_install │ ├── 10_users │ ├── 21_unpack_webapp │ └── 20_unpack ├── .dockerignore └── Dockerfile ├── webapp ├── build.d │ ├── 00_install │ └── 20_unpack ├── Makefile ├── src │ ├── entrypoint.sh │ ├── autoconfig.sh │ └── nginx.conf ├── .dockerignore └── Dockerfile ├── Makefile ├── DCO ├── security.md ├── README.adoc ├── CONTRIBUTING.md ├── Makefile.inc └── LICENSE /server-builder/.gitignore: -------------------------------------------------------------------------------- 1 | /*.iml 2 | -------------------------------------------------------------------------------- /webapp-builder/.gitignore: -------------------------------------------------------------------------------- 1 | /*.iml 2 | -------------------------------------------------------------------------------- /webapp-builder/build.d/10-yarn-global-modules: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | yarn global add modclean 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /*.iml 3 | /.env* 4 | /.dev* 5 | /TODO 6 | *.tar.* 7 | *.yaml 8 | */build.d/*.tar.gz 9 | -------------------------------------------------------------------------------- /server-corredor/src/healthcheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | 6 | 7 | nc -z -v ${HEALTHCHECK_ADDR} 8 | -------------------------------------------------------------------------------- /server-builder/build.d/00-provision: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | apk add --no-cache git make bash openssh-client alpine-sdk 4 | -------------------------------------------------------------------------------- /server/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build release latest unstable 2 | 3 | include ../Makefile.inc 4 | 5 | IMAGE ?= $(IMAGE_PFIX)server 6 | -------------------------------------------------------------------------------- /webapp-builder/build.d/00-provision: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | apk add --no-cache bash git coreutils make openssh-client 4 | 5 | # 6 | -------------------------------------------------------------------------------- /webapp/build.d/00_install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | apk add --no-cache \ 6 | curl \ 7 | 8 | rm -rf /tmp/* 9 | -------------------------------------------------------------------------------- /webapp/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build release latest unstable 2 | 3 | include ../Makefile.inc 4 | 5 | IMAGE ?= $(IMAGE_PFIX)webapp 6 | 7 | -------------------------------------------------------------------------------- /server-corredor/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build release latest unstable 2 | 3 | include ../Makefile.inc 4 | 5 | IMAGE ?= $(IMAGE_PFIX)server-corredor 6 | -------------------------------------------------------------------------------- /server/src/healthcheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | curl --silent --fail --fail-early http://127.0.0.1:${C_HTTP_PORT}/healthcheck || exit 1 6 | -------------------------------------------------------------------------------- /webapp-builder/build.d/20-hosts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | mkdir -p /root/.ssh 6 | ssh-keyscan -p 40957 -H mantle.crust.tech >> /root/.ssh/known_hosts 7 | -------------------------------------------------------------------------------- /server/build.d/30_datadir: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | mkdir -p ${STORAGE_PATH} 6 | chmod -R u+Xrw,g+Xrw ${STORAGE_PATH} 7 | chown -R "${C_USER}":"${C_GROUP}" ${STORAGE_PATH} 8 | -------------------------------------------------------------------------------- /webapp-builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12.14-alpine 2 | 3 | COPY build.d /build.d 4 | 5 | RUN chmod +x /build.d/* && \ 6 | run-parts --exit-on-error /build.d && \ 7 | rm -rf /build.d 8 | -------------------------------------------------------------------------------- /webapp/src/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | if [ ! -z "${1:-}" ]; then 6 | exec "$@" 7 | else 8 | sh /autoconfig.sh && exec nginx -g "daemon off;" 9 | fi 10 | -------------------------------------------------------------------------------- /server/build.d/00_install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | apk add --no-cache \ 6 | ca-certificates \ 7 | tzdata \ 8 | libcap \ 9 | curl 10 | 11 | rm -rf /tmp/* 12 | -------------------------------------------------------------------------------- /server-builder/build.d/20-hosts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | echo "nameserver 8.8.8.8 8.8.4.4" > /etc/resolv.conf 6 | 7 | mkdir -p /root/.ssh 8 | ssh-keyscan -p 40957 -H mantle.crust.tech >> /root/.ssh/known_hosts 9 | -------------------------------------------------------------------------------- /server-builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.16-alpine 2 | 3 | ENV GOFLAGS="-mod=vendor" 4 | ENV CGO_ENABLED=1 5 | 6 | COPY build.d /build.d 7 | 8 | RUN chmod +x /build.d/* && \ 9 | run-parts --exit-on-error /build.d && \ 10 | rm -rf /build.d 11 | -------------------------------------------------------------------------------- /server/build.d/10_users: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | addgroup -g "${C_GID}" "${C_GROUP}" 6 | adduser -D -u "${C_UID}" -G "${C_GROUP}" -h "${C_HOME_DIR}" "${C_USER}" 7 | 8 | chmod -R u+Xr-w,g+Xr-w "${C_HOME_DIR}" 9 | chown -R "${C_USER}":"${C_GROUP}" "${C_HOME_DIR}" 10 | -------------------------------------------------------------------------------- /server-builder/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | end_of_line = lf 8 | insert_final_newline = true 9 | 10 | # Tab indentation (no size specified) 11 | [Makefile] 12 | indent_style = tab 13 | -------------------------------------------------------------------------------- /webapp-builder/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | end_of_line = lf 8 | insert_final_newline = true 9 | 10 | # Tab indentation (no size specified) 11 | [Makefile] 12 | indent_style = tab 13 | -------------------------------------------------------------------------------- /webapp/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .ipynb_checkpoints 3 | notebooks 4 | unused 5 | Dockerfile 6 | .DS_Store 7 | .gitignore 8 | README.md 9 | env.* 10 | devops 11 | 12 | # To prevent storing dev/temporary container data 13 | *.csv 14 | tmp 15 | 16 | # Ignore all packages expect ones properly formatted 17 | *.tar.gz 18 | !corteza-webapp-*-*.tar.gz 19 | -------------------------------------------------------------------------------- /webapp-builder/README.md: -------------------------------------------------------------------------------- 1 | # Corteza backend builder 2 | 3 | Creates docker image with Corteza backend builder support. 4 | Used for testing and building Corteza backend codebase 5 | 6 | Tasks in Makefile will help you with image building and pushing. 7 | Git `master` branch produces image with `latest` tag, 8 | releases should be done through git tag. 9 | -------------------------------------------------------------------------------- /server/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .ipynb_checkpoints 3 | notebooks 4 | unused 5 | Dockerfile 6 | .DS_Store 7 | .gitignore 8 | README.md 9 | env.* 10 | devops 11 | 12 | # To prevent storing dev/temporary container data 13 | *.csv 14 | tmp 15 | 16 | # Ignore all packages expect ones properly formatted 17 | *.tar.gz 18 | !corteza-server-*-*.*-*-*.tar.gz 19 | -------------------------------------------------------------------------------- /server-builder/build.d/10-build-tools: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "installing overalls" 4 | go get -u github.com/go-playground/overalls 5 | 6 | echo "installing gomock" 7 | go get -u github.com/golang/mock/gomock 8 | 9 | echo "installing mockgen" 10 | go get -u github.com/golang/mock/mockgen 11 | 12 | echo "installing gotest" 13 | go get -u github.com/rakyll/gotest 14 | -------------------------------------------------------------------------------- /server-corredor/build.d/00_install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | #set -eux # debugging 5 | 6 | # Cairo&co are needed for PDF rendering 7 | apk add --no-cache \ 8 | ca-certificates \ 9 | tzdata \ 10 | git \ 11 | build-base \ 12 | g++ \ 13 | cairo-dev \ 14 | jpeg-dev \ 15 | pango-dev \ 16 | giflib-dev \ 17 | libcap \ 18 | curl 19 | 20 | rm -rf /tmp/* 21 | -------------------------------------------------------------------------------- /server-builder/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build release latest unstable 2 | 3 | 4 | DOCKER = docker 5 | IMAGE ?= cortezaproject/corteza-server-builder 6 | TAG = 1.16 7 | 8 | build: 9 | $(DOCKER) build $(DOCKER_BUILD_OPTS) --tag $(IMAGE):$(TAG) . 10 | 11 | release: 12 | $(DOCKER) push $(IMAGE):$(TAG) 13 | 14 | latest: 15 | $(DOCKER) tag $(IMAGE):$(TAG) $(IMAGE):latest 16 | $(DOCKER) push $(IMAGE):latest 17 | -------------------------------------------------------------------------------- /server-corredor/build.d/10_users: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | addgroup -g "${C_GID}" "${C_GROUP}" 6 | adduser -D -u "${C_UID}" -G "${C_GROUP}" -h "${C_HOME_DIR}" "${C_USER}" 7 | 8 | chmod -R u+Xr-w,g+Xr-w "${C_HOME_DIR}" 9 | chown -R "${C_USER}":"${C_GROUP}" "${C_HOME_DIR}" 10 | 11 | # Make sure node still bind ports <1024 even when ran as non-root 12 | setcap cap_net_bind_service=+ep $(which node) 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all server webapp server-corredor server-builder webapp-builder 2 | 3 | # All known outputs (output = directory on root) 4 | BUILDERS = server-builder webapp-builder 5 | CORTEZA_OUTPOUTS = server webapp server-corredor 6 | 7 | # webapp needs to be build before server as server 8 | # includes images from it 9 | all: webapp server server-corredor 10 | 11 | $(CORTEZA_OUTPOUTS): 12 | $(MAKE) -C $@ 13 | -------------------------------------------------------------------------------- /server-corredor/build.d/80_corteza_ext: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | copyExtScripts () { 6 | mkdir -p "${C_EXT_DST}/${1}" 7 | cp -r \ 8 | "${C_HOME_DIR:?}/${C_EXT_DIR}-${C_EXT_BRANCH}/${1}" \ 9 | "${C_EXT_DST}/" 10 | } 11 | 12 | curl --location "${C_EXT_URL:?}" | tar -xz -C "${C_HOME_DIR}" 13 | 14 | copyExtScripts crm 15 | copyExtScripts service-solution 16 | 17 | rm -rf "${C_HOME_DIR:?}/${C_EXT_DIR}" 18 | 19 | -------------------------------------------------------------------------------- /webapp/build.d/20_unpack: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -eu 4 | 5 | TAR_FLAGS=-xzmok 6 | 7 | unpack() { 8 | APP=${1} 9 | VER=${2} 10 | DST=${3} 11 | PKG="${C_FLAVOUR}-webapp-${APP}-${VER}.${C_PKG_EXT}" 12 | URL="${C_REMOTE_BASE_URL}/${PKG}" 13 | TMP="/build.d/${PKG}" 14 | 15 | mkdir -p "${C_BASE_DIR}/${DST}" 16 | 17 | if [ -f "${TMP}" ]; then 18 | echo "Unpacking ${APP} from provided package" 19 | echo "${TMP}" 20 | tar ${TAR_FLAGS} -f "${TMP}" -C "${C_BASE_DIR}/${DST}" 21 | else 22 | echo "Downloading ${APP} from" 23 | echo "${URL}" 24 | curl --silent --location "${URL?}" | tar ${TAR_FLAGS} -C "${C_BASE_DIR}/${DST}" 25 | fi 26 | } 27 | 28 | unpack "one" "${C_VERSION_WEBAPP_ONE}" "" 29 | unpack "admin" "${C_VERSION_WEBAPP_ADMIN}" "admin" 30 | unpack "compose" "${C_VERSION_WEBAPP_COMPOSE}" "compose" 31 | unpack "workflow" "${C_VERSION_WEBAPP_WORKFLOW}" "workflow" 32 | -------------------------------------------------------------------------------- /server-corredor/build.d/20_unpack: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | TAR_FLAGS=-xzmok 6 | 7 | HOME_TMP="${C_HOME_DIR}/tmp" 8 | 9 | LOCAL_PATH="/build.d/${C_PKG_NAME}" 10 | REMOTE_URL="${C_REMOTE_BASE_URL}/${C_PKG_NAME}" 11 | 12 | mkdir -p "${HOME_TMP}" 13 | 14 | # See if COPY in Dockerfile picked up any local dist files 15 | # and use them instead of downloading the whole package 16 | # 17 | # Used mainly for debugging 18 | if [ -f "${LOCAL_PATH}" ]; then 19 | ls -lsa ${LOCAL_PATH} 20 | tar ${TAR_FLAGS} -f "${LOCAL_PATH}" -C "${HOME_TMP?}"; 21 | else 22 | echo "Downloading Corredor" 23 | echo ${REMOTE_URL?} 24 | curl --location "${REMOTE_URL?}" | tar ${TAR_FLAGS} -C "${HOME_TMP?}" 25 | fi 26 | 27 | #mv "${HOME_TMP}/${C_FLAVOUR}-server-corredor/"* "${C_HOME_DIR?}/" 28 | mv "${HOME_TMP}/corteza-server-corredor/"* "${C_HOME_DIR?}/" 29 | 30 | rm -rf "${HOME_TMP?}" 31 | 32 | chmod -R u+Xr-w,g+Xr-w "${C_HOME_DIR?}" 33 | chown -R "${C_USER}":"${C_GROUP}" "${C_HOME_DIR?}" 34 | -------------------------------------------------------------------------------- /webapp/src/autoconfig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | ################################################################################ 6 | # (re)generate configuration files 7 | 8 | # Where to put the configs 9 | BASEDIR=${BASEDIR:-"/webapp"} 10 | 11 | FEDERATION_ENABLED=${FEDERATION_ENABLED:-""} 12 | 13 | 14 | # See if VIRTUAL_HOST exists 15 | # if it does, it should hold the hostname of where these webapps are served 16 | VIRTUAL_HOST=${VIRTUAL_HOST:-"local.cortezaproject.org"} 17 | 18 | # Assume API is using same scheme as webapps 19 | API_SCHEME=${API_SCHEME:-""} 20 | 21 | # Prefix to use with VIRTUAL_HOST when building API domain 22 | API_PREFIX=${API_PREFIX:-"api."} 23 | 24 | API_BASEURL=${API_BASEURL:-"${API_SCHEME}//${API_PREFIX}${VIRTUAL_HOST}"} 25 | 26 | CONFIG="window.CortezaAPI = '${API_BASEURL}'\n" 27 | 28 | echo -e "${CONFIG}" | tee \ 29 | ${BASEDIR}/admin/config.js \ 30 | ${BASEDIR}/compose/config.js \ 31 | ${BASEDIR}/workflow/config.js \ 32 | > ${BASEDIR}/config.js 33 | -------------------------------------------------------------------------------- /server/build.d/21_unpack_webapp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -eu 4 | 5 | TAR_FLAGS=-xzmok 6 | 7 | unpack() { 8 | APP=${1} 9 | VER=${2} 10 | DST=${3} 11 | PKG="${C_FLAVOUR}-webapp-${APP}-${VER}.tar.gz" 12 | URL="${C_REMOTE_BASE_URL}/${PKG}" 13 | TMP="/build.d/${PKG}" 14 | 15 | mkdir -p "${C_BASE_DIR}/${DST}" 16 | 17 | if [ -f "${TMP}" ]; then 18 | echo "Unpacking ${APP} from provided package" 19 | echo "${TMP}" 20 | tar ${TAR_FLAGS} -f "${TMP}" -C "${C_BASE_DIR}/${DST}" 21 | else 22 | echo "Downloading ${APP} from" 23 | echo "${URL}" 24 | curl --silent --location "${URL?}" | tar ${TAR_FLAGS} -C "${C_BASE_DIR}/${DST}" 25 | fi 26 | } 27 | 28 | 29 | if [ "corteza" = "${C_FLAVOUR}" ]; then 30 | unpack "one" "${C_VERSION_WEBAPP_ONE}" "" 31 | else 32 | unpack "unify" "${C_VERSION_WEBAPP_ONE}" "" 33 | fi 34 | 35 | unpack "admin" "${C_VERSION_WEBAPP_ADMIN}" "admin" 36 | unpack "compose" "${C_VERSION_WEBAPP_COMPOSE}" "compose" 37 | unpack "workflow" "${C_VERSION_WEBAPP_WORKFLOW}" "workflow" 38 | -------------------------------------------------------------------------------- /server/build.d/20_unpack: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | #set -eux # debugging 5 | 6 | TAR_FLAGS=-xzmok 7 | 8 | HOME_TMP="${C_HOME_DIR}/tmp" 9 | 10 | 11 | mkdir -p "${HOME_TMP}" 12 | 13 | NAME="${C_FLAVOUR}-server" 14 | PKG_NAME="${NAME}-${C_VERSION}-${C_OS}-${C_ARCH}.tar.gz" 15 | LOCAL_PATH="/build.d/${PKG_NAME}" 16 | REMOTE_URL="${C_REMOTE_BASE_URL}/${PKG_NAME}" 17 | 18 | # See if COPY in Dockerfile picked up any local dist files 19 | # and use them instead of downloading the whole package 20 | # 21 | # Used mainly for debugging 22 | if [ -f "${LOCAL_PATH}" ]; then 23 | echo "Local packages found:" 24 | ls -lsa ${LOCAL_PATH} 25 | tar ${TAR_FLAGS} -f "${LOCAL_PATH}" -C "${HOME_TMP}"; 26 | else 27 | echo "Downloading server from" 28 | echo "${REMOTE_URL}" 29 | curl --silent --location "${REMOTE_URL?}" | tar ${TAR_FLAGS} -C "${HOME_TMP}" 30 | fi 31 | 32 | mv "${HOME_TMP}/${NAME}/"* "${C_HOME_DIR}/" 33 | rm -rf "${HOME_TMP}" 34 | 35 | BIN="${C_HOME_DIR}/bin/${NAME}" 36 | 37 | # Released packages have "-server" named binaries 38 | # 39 | # we'll link them to simple "server" that can be used as entrypoint 40 | ln -s "${BIN}" "${C_HOME_DIR}/bin/server" 41 | setcap cap_net_bind_service=+ep "${BIN}" 42 | -------------------------------------------------------------------------------- /webapp/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.11 AS builder 2 | 3 | ARG C_FLAVOUR="corteza" 4 | ARG C_VERSION="2020.12.0" 5 | ARG C_VERSION_WEBAPP_ONE="${C_VERSION}" 6 | ARG C_VERSION_WEBAPP_ADMIN="${C_VERSION}" 7 | ARG C_VERSION_WEBAPP_COMPOSE="${C_VERSION}" 8 | ARG C_VERSION_WEBAPP_WORKFLOW="${C_VERSION}" 9 | ARG C_REMOTE_BASE_URL="https://releases.cortezaproject.org/files" 10 | ARG C_BASE_DIR="/webapp" 11 | ARG C_HTTP_PORT="80" 12 | ARG C_PKG_EXT="tar.gz" 13 | 14 | COPY *.tar.gz build.d /build.d/ 15 | RUN chmod +x /build.d/??_* \ 16 | && run-parts --exit-on-error /build.d \ 17 | && rm -rf /build.d 18 | 19 | FROM nginx:1.17-alpine 20 | 21 | ARG C_BASE_DIR="/webapp" 22 | ARG C_HTTP_PORT="80" 23 | ENV C_HTTP_PORT $C_HTTP_PORT 24 | 25 | RUN nginx -t 26 | 27 | COPY --from=builder "/webapp" "/webapp" 28 | COPY src/entrypoint.sh src/autoconfig.sh / 29 | COPY src/nginx.conf /etc/nginx/nginx.conf 30 | 31 | RUN chmod +x /*.sh 32 | 33 | # A simple check, should not waste time on waiting, timeouts... 34 | 35 | HEALTHCHECK --interval=30s --start-period=10s --timeout=30s \ 36 | CMD wget --quiet --tries=1 --spider "http://127.0.0.1:${C_HTTP_PORT}/config.js" || exit 1 37 | 38 | EXPOSE ${C_HTTP_PORT} 39 | 40 | WORKDIR "/${C_BASE_DIR}" 41 | 42 | ENTRYPOINT ["/entrypoint.sh"] 43 | -------------------------------------------------------------------------------- /webapp/src/nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes 1; 3 | 4 | error_log /dev/stdout warn; 5 | # error_log /dev/stdout debug; 6 | 7 | pid /var/run/nginx.pid; 8 | 9 | events { 10 | worker_connections 1024; 11 | } 12 | 13 | http { 14 | include /etc/nginx/mime.types; 15 | default_type application/octet-stream; 16 | 17 | log_format json escape=json 18 | '{' 19 | '"@timestamp":"$time_iso8601",' 20 | '"remote_addr":"$remote_addr",' 21 | '"request":"$request",' 22 | '"status":$status,' 23 | '"body_bytes_sent":$body_bytes_sent,' 24 | '"request_time":$request_time,' 25 | '"http_referrer":"$http_referer",' 26 | '"http_user_agent":"$http_user_agent"' 27 | '}'; 28 | 29 | access_log /dev/stdout json; 30 | 31 | sendfile on; 32 | keepalive_timeout 300; 33 | 34 | server { 35 | listen 80 default_server; 36 | listen [::]:80 default_server; 37 | server_name _; 38 | 39 | index index.html; 40 | 41 | root /webapp; 42 | 43 | 44 | location /admin { 45 | try_files $uri /admin/index.html; 46 | } 47 | 48 | location /compose { 49 | try_files $uri /compose/index.html; 50 | } 51 | 52 | location /workflow { 53 | try_files $uri /workflow/index.html; 54 | } 55 | 56 | location / { 57 | try_files $uri /index.html; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /DCO: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 660 York Street, Suite 102, 6 | San Francisco, CA 94110 USA 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this 9 | license document, but changing it is not allowed. 10 | 11 | 12 | Developer's Certificate of Origin 1.1 13 | 14 | By making a contribution to this project, I certify that: 15 | 16 | (a) The contribution was created in whole or in part by me and I 17 | have the right to submit it under the open source license 18 | indicated in the file; or 19 | 20 | (b) The contribution is based upon previous work that, to the best 21 | of my knowledge, is covered under an appropriate open source 22 | license and I have the right under that license to submit that 23 | work with modifications, whether created in whole or in part 24 | by me, under the same open source license (unless I am 25 | permitted to submit under a different license), as indicated 26 | in the file; or 27 | 28 | (c) The contribution was provided directly to me by some other 29 | person who certified (a), (b) or (c) and I have not modified 30 | it. 31 | 32 | (d) I understand and agree that this project and the contribution 33 | are public and that a record of the contribution (including all 34 | personal information I submit with it, including my sign-off) is 35 | maintained indefinitely and may be redistributed consistent with 36 | this project or the open source license(s) involved. 37 | -------------------------------------------------------------------------------- /security.md: -------------------------------------------------------------------------------- 1 | # Security 2 | 3 | At Corteza, the security of our products and services is important to us. 4 | All of our source code repositories are managed through GitHub organisations. 5 | Here is the list of [Corteza Repositories](https://github.com/orgs/cortezaproject/repositories) 6 | 7 | If you believe you have found a security vulnerability in any Corteza repository, please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please send email to [info@cortezaproject.org](mailto:info@cortezaproject.org). 14 | 15 | You should receive a response within 24 business hours. If for some reason you do not, 16 | please follow up via email to ensure we received your original message. 17 | 18 | Please include the requested information listed below (as much as you can provide) 19 | to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue, 22 | * full paths of source file(s) related to the manifestation of the issue, 23 | * the location of the affected source code (tag/branch/commit or direct URL), 24 | * any special configuration required to reproduce the issue, 25 | * step-by-step instructions to reproduce the issue, 26 | * proof-of-concept or exploit code (if possible), 27 | * impact of the issue, including how an attacker might exploit the issue. 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | ## Preferred Languages 32 | 33 | We prefer all communications to be in English. 34 | 35 | ## Policy 36 | 37 | [Corteza Privacy Policy](https://cortezaproject.org/privacy-policy/) 38 | -------------------------------------------------------------------------------- /server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.11 2 | 3 | ARG C_OS="linux" 4 | ARG C_ARCH="amd64" 5 | ARG C_FLAVOUR="corteza" 6 | ARG C_VERSION="2020.12.0" 7 | ARG C_VERSION_WEBAPP="${C_VERSION}" 8 | ARG C_VERSION_WEBAPP_ONE="${C_VERSION_WEBAPP}" 9 | ARG C_VERSION_WEBAPP_ADMIN="${C_VERSION_WEBAPP}" 10 | ARG C_VERSION_WEBAPP_COMPOSE="${C_VERSION_WEBAPP}" 11 | ARG C_VERSION_WEBAPP_WORKFLOW="${C_VERSION_WEBAPP}" 12 | ARG C_REMOTE_BASE_URL="https://releases.cortezaproject.org/files" 13 | ARG C_HOME_DIR="/${C_FLAVOUR}" 14 | ARG C_BASE_DIR="${C_HOME_DIR}/webapp" 15 | ARG C_USER="${C_FLAVOUR}" 16 | ARG C_GROUP="${C_FLAVOUR}" 17 | ARG C_UID="4242" 18 | ARG C_GID="4242" 19 | ARG C_HTTP_PORT="80" 20 | 21 | # Making a couple of assumptions about environment 22 | 23 | # Data will most likely be mounted on /data 24 | ENV STORAGE_PATH "/data" 25 | 26 | # Corredor server will run under "corredor" docker container service 27 | ENV CORREDOR_ADDR "corredor:80" 28 | 29 | # Where can server binaries can be found 30 | ENV PATH "${C_HOME_DIR}/bin:${PATH}" 31 | 32 | # Where Corteza API is running? 33 | ENV C_HTTP_PORT $C_HTTP_PORT 34 | ENV HTTP_ADDR "0.0.0.0:${C_HTTP_PORT}" 35 | 36 | # Make sure server looks in the right direction when serving client apps 37 | # This still needs to be explicitly enabled with HTTP_WEBAPP_ENABLED 38 | ENV HTTP_WEBAPP_BASE_DIR "$C_BASE_DIR" 39 | 40 | COPY *.tar.gz build.d /build.d/ 41 | COPY src/healthcheck.sh /bin/healthcheck 42 | RUN chmod +x /bin/healthcheck \ 43 | && chmod +x /build.d/??_* \ 44 | && run-parts --exit-on-error /build.d \ 45 | && rm -rf /build.d 46 | 47 | USER $C_USER 48 | 49 | VOLUME /data 50 | 51 | WORKDIR ${C_HOME_DIR} 52 | 53 | HEALTHCHECK --interval=30s --start-period=1m --timeout=30s --retries=3 CMD sh /bin/healthcheck 54 | 55 | EXPOSE ${C_HTTP_PORT} 56 | 57 | ENTRYPOINT [ "bin/server" ] 58 | CMD ["serve-api"] 59 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = Demo & production Docker image building scripts for Corteza 2 | 3 | == Outputs 4 | 5 | === Docker images 6 | 7 | server:: 8 | Backend server and HTTP REST API server: combines compose and system backends and their APIs. 9 | 10 | webapp:: 11 | Frontend client applications (one, admin, compose). Static files served by NginX web server. 12 | 13 | corredor:: 14 | Automation server 15 | 16 | == Building images 17 | 18 | Build and push all images (from root) 19 | [source] 20 | ---- 21 | make VERSION=2020.12.0 22 | ---- 23 | 24 | This will build server, webapp and corredor. 25 | 26 | Each image can be built independently by changing into one of the directories and running `make` 27 | 28 | == Release packages (binaries and bundles) 29 | 30 | Most important thing to keep in mind is that package MUST released on https://releases.cortezaproject.org/files/. 31 | This happens in the final step of the CI pipeline on each repository. 32 | 33 | As an alternative you can place testing release package inside build.d/ where it's detected by image build scripts. 34 | 35 | == Versions 36 | 37 | Valid version formats: 38 | 39 | 40 | `202-`:: 41 | Will suffix with .0 patch. See next format. 42 | 43 | `202--`:: 44 | Builds image with `--` and `-` tag. 45 | 46 | ``:: 47 | Builds image with `` 48 | 49 | If `LATEST=yes` is set and non-arbitrary-string version is used, images are also tagged with `latest` 50 | 51 | 52 | .Examples: 53 | [source] 54 | ---- 55 | make VERSION=2020.12 56 | make VERSION=unstable 57 | make VERSION=2020.12.2 LATEST=yes 58 | ---- 59 | 60 | 61 | === Version mix & match 62 | 63 | Webapp and server images build supports version cascading (see `Makefile.inc` for details). 64 | 65 | .Compiling specific feature build for server with base unstable version for webapp with exception of compose: 66 | [source] 67 | ---- 68 | make VERSION=2020.12.x-feature-xyz VERSION_WEBAPP=unstable VERSION_WEBAPP_COMPOSE=2020.12.x-feature-xyz 69 | ---- 70 | 71 | This will build image with `2020.12.x-feature-xyz` tag with all but compose webapps on unstable version 72 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | Corteza projects are [Apache 2.0 licensed](LICENSE) and accept contributions via 4 | GitHub pull requests. This document outlines some of the conventions on 5 | development workflow, commit message formatting, contact points and other 6 | resources to make it easier to get your contribution accepted. 7 | 8 | # Certificate of Origin 9 | 10 | By contributing to this project you agree to the Developer Certificate of 11 | Origin (DCO). This document was created by the Linux Kernel community and is a 12 | simple statement that you, as a contributor, have the legal right to make the 13 | contribution. See the [DCO](DCO) file for details. 14 | 15 | # Getting Started 16 | 17 | - Fork the repository on GitHub 18 | - Read the [Wiki](https://github.com/crusttech/crust/wiki) for build and test instructions 19 | - Play with the project, submit bugs, submit patches! 20 | 21 | ## Contribution Flow 22 | 23 | This is a rough outline of what a contributor's workflow looks like: 24 | 25 | - Create a topic branch from where you want to base your work (usually master). 26 | - Make commits of logical units. 27 | - Make sure your commit messages are in the proper format (see below). 28 | - Push your changes to a topic branch in your fork of the repository. 29 | - Make sure the tests pass, and add any new tests as appropriate. 30 | - Submit a pull request to the original repository. 31 | 32 | Thanks for your contributions! 33 | 34 | ### Format of the Commit Message 35 | 36 | See [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/). 37 | 38 | Summary of the article and the seven rules of a great Git commit message 39 | 40 | 1. Separate subject from body with a blank line 41 | 2. Limit the subject line to 50 characters 42 | 3. Capitalize the subject line 43 | 4. Do not end the subject line with a period 44 | 5. Use the imperative mood in the subject line 45 | 6. Wrap the body at 72 characters 46 | 7. Use the body to explain what and why vs. how 47 | 48 | We are not terribly strict against a particular commit message format, but 49 | the general rule is to avoid non-descriptive single-word commit messages like "fix". 50 | 51 | We might ask you to rewrite/rebase your commit messages if they land too far from the 52 | rules above. 53 | -------------------------------------------------------------------------------- /server-corredor/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12.14-alpine AS build 2 | 3 | ARG C_FLAVOUR="corteza" 4 | ARG C_VERSION="2020.12.0" 5 | ARG C_REMOTE_BASE_URL="https://releases.cortezaproject.org/files" 6 | 7 | # Temporary workaround -- Corredor's Corteza/Crust flavours are the same 8 | # so it's safe to do this 9 | #ARG C_PKG_NAME="${C_FLAVOUR}-server-corredor-${C_VERSION}.tar.gz" 10 | ARG C_PKG_NAME="corteza-server-corredor-${C_VERSION}.tar.gz" 11 | 12 | ARG C_HOME_DIR="/corredor" 13 | ARG C_USER="corredor" 14 | ARG C_GROUP="corredor" 15 | ARG C_UID="4242" 16 | ARG C_GID="4242" 17 | ARG C_GRPC_PORT="80" 18 | ARG C_EXT_DIR="corteza-ext" 19 | ARG C_EXT_BRANCH="2020.12.x" 20 | ARG C_EXT_URL="https://github.com/cortezaproject/${C_EXT_DIR}/archive/${C_EXT_BRANCH}.tar.gz" 21 | ARG C_EXT_DST="/extensions" 22 | 23 | # Create app directory 24 | WORKDIR ${C_HOME_DIR} 25 | 26 | COPY *.tar.gz build.d /build.d/ 27 | COPY src/healthcheck.sh /bin/healthcheck 28 | RUN chmod +x /bin/healthcheck \ 29 | && chmod +x /build.d/??_* \ 30 | && run-parts --exit-on-error /build.d \ 31 | && rm -rf /build.d 32 | 33 | # GRPC's env-vars 34 | # https://github.com/grpc/grpc/blob/master/doc/environment_variables.md 35 | ENV GRPC_VERBOSITY=ERROR 36 | 37 | # Set Corredor's default ENV values 38 | ENV CORREDOR_ENVIRONMENT=prod 39 | ENV CORREDOR_LOG_PRETTY=false 40 | ENV CORREDOR_LOG_LEVEL=info 41 | ENV CORREDOR_LOG_ENABLED=true 42 | 43 | ENV C_GRPC_PORT=${C_GRPC_PORT} 44 | ENV CORREDOR_ADDR=0.0.0.0:${C_GRPC_PORT} 45 | ENV HEALTHCHECK_ADDR=localhost:${C_GRPC_PORT} 46 | 47 | # Production mode 48 | ENV CORREDOR_SERVER_CERTIFICATES_ENABLED=false 49 | ENV CORREDOR_SCRIPTS_AUTO_UPDATE_DEPENDENCIES=false 50 | ENV CORREDOR_EXT_SERVER_SCRIPTS_WATCH=false 51 | ENV CORREDOR_EXT_CLIENT_SCRIPTS_WATCH=false 52 | 53 | ENV CORREDOR_EXT_SEARCH_PATHS=${C_EXT_DST}/*:/corredor/usr/*:/corredor/usr 54 | 55 | # This assumes that container will be part of the docker-compose setup were corteza is 56 | # ran under "server" service and can be directly accessed via internal docker network 57 | ENV CORREDOR_EXEC_CSERVERS_API_BASEURL_TEMPLATE "http://server/api/{service}" 58 | 59 | ENV YARN_CACHE_FOLDER=/dev/shm/yarn_cache 60 | 61 | USER $C_USER 62 | 63 | # Client & server scripts location for user scripts & extensions 64 | VOLUME /corredor/usr 65 | 66 | # TLS certificates should be placed here if CORREDOR_SERVER_CERTIFICATES_ENABLED 67 | VOLUME /corredor/certs 68 | 69 | HEALTHCHECK --interval=30s --start-period=1m --timeout=30s --retries=3 CMD sh /bin/healthcheck 70 | 71 | EXPOSE ${C_GRPC_PORT} 72 | 73 | ENTRYPOINT ["/corredor/node_modules/.bin/ts-node"] 74 | CMD ["src/server.ts"] 75 | -------------------------------------------------------------------------------- /Makefile.inc: -------------------------------------------------------------------------------- 1 | # Binaries 2 | DOCKER = docker 3 | 4 | # This makes sure that regex match for vVALID, vPATCH and vRC is working 5 | SHELL = /bin/bash 6 | 7 | # Other, centralised settings 8 | FLAVOUR ?= corteza 9 | 10 | ifeq ($(VERSION),) 11 | $(error VERSION is not set. Make sure you specify it, eg: make build VERSION=2021.3.0) 12 | endif 13 | 14 | # Trying to build old version? 15 | vPRE2021 := $(shell [[ $(VERSION) =~ ^2020 ]] && echo "yes") 16 | ifneq ($(vPRE2021),) 17 | $(error Refusing to build versions older than 2021.3.x, please checkout 2020.12.x branch of this repo and build with that) 18 | endif 19 | 20 | 21 | vFULL := $(VERSION) 22 | 23 | 24 | # Is this a valid version (fits in a "yyyy.<3, 6 9 or 12>." format)? 25 | vVALID := $(shell [[ $(vFULL) =~ ^202[0-9].(3|6|9|12)(.[0-9]+)?$$ ]] && echo "yes") 26 | 27 | # Is this a patch? 28 | vPATCH := $(shell [[ $(vFULL) =~ ^202[0-9].(3|6|9|12).([0-9]+)$$ ]] && echo "yes") 29 | 30 | # Is this a release candidate? 31 | vRC := $(shell [[ $(vFULL) =~ \-rc.([0-9]+)$$ ]] && echo "yes") 32 | 33 | ifneq ($(vVALID),) 34 | ifeq ($(vPATCH),) 35 | vFULL := $(addsuffix .0,$(vFULL)) 36 | endif 37 | endif 38 | 39 | 40 | 41 | 42 | # The actual shorten version: 43 | vSHORT := $(word 1,$(subst ., ,$(vFULL))).$(word 2,$(subst ., ,$(vFULL))) 44 | 45 | ifeq ($(FLAVOUR),crust) 46 | IMAGE_PFIX = crusttech/crust- 47 | else 48 | IMAGE_PFIX = cortezaproject/corteza- 49 | endif 50 | 51 | VERSION ?= $(vFULL) 52 | VERSION_WEBAPP ?= $(VERSION) 53 | VERSION_WEBAPP_ONE ?= $(VERSION_WEBAPP) 54 | VERSION_WEBAPP_ADMIN ?= $(VERSION_WEBAPP) 55 | VERSION_WEBAPP_COMPOSE ?= $(VERSION_WEBAPP) 56 | 57 | # Docker build flags, build arguments and combined options 58 | DOCKER_BUILD_FLAGS ?= --no-cache --rm # example: make build.server DOCKER_BUILD_FLAGS=--rm 59 | DOCKER_BUILD_FLAGS += --build-arg C_FLAVOUR=$(FLAVOUR) 60 | DOCKER_BUILD_FLAGS += --build-arg C_VERSION=$(VERSION) 61 | DOCKER_BUILD_FLAGS += --build-arg C_VERSION_WEBAPP=$(VERSION_WEBAPP) 62 | DOCKER_BUILD_FLAGS += --build-arg C_VERSION_WEBAPP_ONE=$(VERSION_WEBAPP_ONE) 63 | DOCKER_BUILD_FLAGS += --build-arg C_VERSION_WEBAPP_ADMIN=$(VERSION_WEBAPP_ADMIN) 64 | DOCKER_BUILD_FLAGS += --build-arg C_VERSION_WEBAPP_COMPOSE=$(VERSION_WEBAPP_COMPOSE) 65 | 66 | all: | build push 67 | 68 | # Generic docker build 69 | build: 70 | $(DOCKER) build $(DOCKER_BUILD_FLAGS) --tag $(IMAGE):$(vFULL) . 71 | ifeq ($(vVALID),yes) 72 | docker tag $(IMAGE):$(vFULL) $(IMAGE):$(vSHORT) 73 | ifeq ($(LATEST),yes) 74 | docker tag $(IMAGE):$(vFULL) $(IMAGE):latest 75 | endif 76 | endif 77 | 78 | # Generic docker push 79 | push: 80 | # @ echo "VERSION = <" $(VERSION) ">" 81 | # @ echo "vFULL = <" $(vFULL) ">" 82 | # @ echo "vVALID = <" $(vVALID) ">" 83 | # @ echo "vPATCH = <" $(vPATCH) ">" 84 | # @ echo "vRC = <" $(vRC) ">" 85 | ifeq ($(vRC),yes) 86 | @ echo "Refusing to automatically push release-candidate to docker hub, you can do it manually:" 87 | @ echo docker push $(IMAGE):$(vFULL) 88 | else 89 | $(DOCKER) push $(IMAGE):$(vFULL) 90 | ifeq ($(vVALID),yes) 91 | docker push $(IMAGE):$(vSHORT) 92 | ifeq ($(LATEST),yes) 93 | docker push $(IMAGE):latest 94 | endif 95 | endif 96 | endif 97 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------