diff --git a/docker-compose.yml b/docker-compose.yml index b0c30ca66..ad291eac8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,138 +1,138 @@ -# This file defines the production settings. It is overwritten by docker-compose.override.yml, -# which defines the development settings. The override.yml is loaded by default. Therefore it -# is required to explicitly define if you want an production build: -# > docker-compose -f docker-compose.yml up - -version: "3.4" - -services: - ######################################################## - # FRONTEND ############################################# - ######################################################## - frontend: - image: gradido/frontend:latest - build: - context: ./frontend - target: production - networks: - - external-net - depends_on: - - nginx - ports: - - 8080:8080 - environment: - # Envs used in Dockerfile - # - DOCKER_WORKDIR="/app" - # - PORT="8080" - - BUILD_DATE - - BUILD_VERSION - - BUILD_COMMIT - - NODE_ENV="production" - # Application only envs - #- HOST=0.0.0.0 # This is nuxt specific, alternative value is HOST=webapp - #env_file: - # - ./frontend/.env - - ######################################################### - ## MARIADB ############################################## - ######################################################### - mariadb: - build: - context: . - dockerfile: ./mariadb/Dockerfile - target: mariadb_server - container_name: mariadb - environment: - - MARIADB_ALLOW_EMPTY_PASSWORD=1 - - MARIADB_USER=root - networks: - - internal-net - ports: - - 3306:3306 - volumes: - - db_vol:/var/lib/mysql - - ######################################################### - ## LOGIN SERVER ######################################### - ######################################################### - login-server: - build: - context: ./login_server/ - target: login_server - container_name: login-server - depends_on: - - mariadb - networks: - - internal-net - ports: - - 1200:1200 - - 1201:1201 - volumes: - - ./configs/login_server:/etc/grd_login - - ######################################################### - ## NGINX ################################################ - ######################################################### - ## nginx, connect login-server and community-server together (and php-fpm to community-server) - nginx: - build: - context: . - dockerfile: ./nginx/Dockerfile - container_name: nginx - networks: - - external-net - - internal-net - depends_on: - - community-server - - login-server - ports: - - 80:80 - - ######################################################### - ## COMMUNITY SERVER (cakephp with php-fpm) ############## - ######################################################### - community-server: - build: - context: . - dockerfile: ./community_server/Dockerfile - container_name: community-server - environment: - - DB_PASSWORD='' - - DB_USER='root' - - DB_DATABASE='gradido_community' - depends_on: - - mariadb - networks: - - internal-net - volumes: - - ./community_server/config/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini - - ######################################################### - ## GRADIDO NODE v1 ###################################### - ######################################################### - # gradido-node: - # build: - # context: . - # dockerfile: ./gn/docker/deprecated-hedera-node/Dockerfile - # volumes: - # - ${GN_INSTANCE_FOLDER}:/opt/instance - # container_name: ${GN_CONTAINER_NAME} - - ######################################################### - ## GRADIDO NODE test ################################### - ######################################################### - # gradido-node-test: - # build: - # context: . - # dockerfile: ./gn/docker/deprecated-hedera-node/Dockerfile - # container_name: gn-test - # working_dir: /opt/gn/build - # command: ["./unit_tests"] - -networks: - external-net: - internal-net: - internal: true - -volumes: - db_vol: +# This file defines the production settings. It is overwritten by docker-compose.override.yml, +# which defines the development settings. The override.yml is loaded by default. Therefore it +# is required to explicitly define if you want an production build: +# > docker-compose -f docker-compose.yml up + +version: "3.4" + +services: + ######################################################## + # FRONTEND ############################################# + ######################################################## + frontend: + image: gradido/frontend:latest + build: + context: ./frontend + target: production + networks: + - external-net + depends_on: + - nginx + ports: + - 8080:8080 + environment: + # Envs used in Dockerfile + # - DOCKER_WORKDIR="/app" + # - PORT="8080" + - BUILD_DATE + - BUILD_VERSION + - BUILD_COMMIT + - NODE_ENV="production" + # Application only envs + #- HOST=0.0.0.0 # This is nuxt specific, alternative value is HOST=webapp + #env_file: + # - ./frontend/.env + + ######################################################### + ## MARIADB ############################################## + ######################################################### + mariadb: + build: + context: . + dockerfile: ./mariadb/Dockerfile + target: mariadb_server + container_name: mariadb + environment: + - MARIADB_ALLOW_EMPTY_PASSWORD=1 + - MARIADB_USER=root + networks: + - internal-net + ports: + - 3306:3306 + volumes: + - db_vol:/var/lib/mysql + + ######################################################### + ## LOGIN SERVER ######################################### + ######################################################### + login-server: + build: + context: ./login_server/ + target: login_server + container_name: login-server + depends_on: + - mariadb + networks: + - internal-net + ports: + - 1200:1200 + - 1201:1201 + volumes: + - ./configs/login_server:/etc/grd_login + + ######################################################### + ## NGINX ################################################ + ######################################################### + ## nginx, connect login-server and community-server together (and php-fpm to community-server) + nginx: + build: + context: . + dockerfile: ./nginx/Dockerfile + container_name: nginx + networks: + - external-net + - internal-net + depends_on: + - community-server + - login-server + ports: + - 80:80 + + ######################################################### + ## COMMUNITY SERVER (cakephp with php-fpm) ############## + ######################################################### + community-server: + build: + context: . + dockerfile: ./community_server/Dockerfile + container_name: community-server + environment: + - DB_PASSWORD='' + - DB_USER='root' + - DB_DATABASE='gradido_community' + depends_on: + - mariadb + networks: + - internal-net + volumes: + - ./community_server/config/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini + + ######################################################### + ## GRADIDO NODE v1 ###################################### + ######################################################### + # gradido-node: + # build: + # context: . + # dockerfile: ./gn/docker/deprecated-hedera-node/Dockerfile + # volumes: + # - ${GN_INSTANCE_FOLDER}:/opt/instance + # container_name: ${GN_CONTAINER_NAME} + + ######################################################### + ## GRADIDO NODE test ################################### + ######################################################### + # gradido-node-test: + # build: + # context: . + # dockerfile: ./gn/docker/deprecated-hedera-node/Dockerfile + # container_name: gn-test + # working_dir: /opt/gn/build + # command: ["./unit_tests"] + +networks: + external-net: + internal-net: + internal: true + +volumes: + db_vol: diff --git a/docu/community-server.api.md b/docu/community-server.api.md index d45911c6f..bcd5da61d 100644 --- a/docu/community-server.api.md +++ b/docu/community-server.api.md @@ -1,131 +1,131 @@ -# community server api - -In this examples I assume that you use gradido with or docker-compose build on your local maschine - -## Konto Overview -return current account balance - -GET http://localhost/state-balances/ajaxGetBalance/-127182 - -If session is valid, return: -```json -{"state":"success","balance":174500} -``` -- balance: Gradido Cent, 4 Nachkommastellen (2 Reserve), 174500 = 17,45 GDD - -## List Transactions -List all transactions from logged in user, currently without paging -Ajax: -GET http://localhost/state-balances/ajaxListTransactions/-127182/ -or -GET http://localhost/state-balances/ajaxListTransactions/-127182/DESC -to get transaction in descending order - -Antwort: -Wenn alles okay: -```json -{"state":"success", "transactions": - [ - { - "name": "Max Mustermann", - "email": "Maxim Mustermann", - "type": "send", - "transaction_id": 2, - "date": "2021-02-19T13:25:36+00:00", - "balance": 1920000, - "memo": "a piece of cake :)", - "pubkey": "038a6f93270dc57b91d76bf110ad3863fcb7d1b08e7692e793fcdb4467e5b6a7" - } - ], - "transactionExecutingCount": 0, - "count": 1, - "gdtSum": 0, - "timeUsed": 0.04562687873840332 -} -``` - -- name: name of other involved party or empty if unknown (if other party don't belong to group) - - if type is send, name is name of receiver - - if type is receive, name is name of sender - - if type is creation currently I use a static string ("Gradido Akademie) -- email: optional, only if type is send or receive and other user is known -- pubkey: optional, only if type is send or receive and other user isn't known -- type: type of transaction - - creation: user has get gradidos created - - send: user has send another user gradidos - - receiver: user has received gradidos from another user -- transaction_id: id of transaction in db, in stage2 also the hedera sequence number of transaction -- date: date of ordering transaction (booking date) -- balance: Gradido Cent, 4 Nachkommastellen (2 Reserve), 1920000 = 192,00 GDD -- memo: Details about transaction -- pubkey: optional, if other party isn't known, hexadecimal representation of 32 Byte public key of user [0-9a-f] - -- transactionExecutingCount: how many transaction for this user currently pending and waiting for signing -- count: sum of finished transactions user is involved -- gdtSum: sum of gdt of user in cent with 2 places (Nachkommastellen) -- timeUsed: time used for getting data from db in seconds, only for analyse backend performance - -## Creation Transaction -Make a creation transaction -With new Option set in Login-Server: -```ini -unsecure.allow_auto_sign_transactions = 1 -``` -transactions can be auto-signed directly with handing in transaction. -Normally a forwarding to login-server check transactions side is neccessary to minimize security risks. - -POST http://localhost/transaction-creations/ajaxCreate -```json -{ - "session_id" : -127182, - "email": "max.musterman@gmail.de", - "amount": 10000000, - "target_date":"2021-02-19T13:25:36+00:00", - "memo":"AGE", - "auto_sign": true -} -``` -return if everything is ok: -```json -{"state":"success", "timeUsed": 0.0122} -``` -- timeUsed: time used for getting data from db in seconds, only for analyse backend performance - -## Send Coins Transaction -Make a simple GDD Transaction, send Coins from one user to other. -With new Option set in Login-Server: -```ini -unsecure.allow_auto_sign_transactions = 1 -``` -transactions can be auto-signed directly with handing in transaction. -Normally a forwarding to login-server check transactions side is neccessary to minimize security risks. - -POST http://localhost/transaction-send-coins/ajaxCreate -```json -{ - "session_id" : -127182, - "amount": 2000000, - "email": "max.musterman@gmail.de", - "memo":"Thank you :)", - "auto_sign": true -} -``` -- amout: amount to transfer, 2000000 = 200,00 GDD -- email: receiver email address, must be differ from user email -- memo: Details about transaction -- auto_sign: set to true to directly sign transaction if unsecure.allow_auto_sign_transactions = 1 is set - -return if everything is ok: -```json -{"state":"success", "timeUsed": 0.0122} -``` -- timeUsed: time used for getting data from db in seconds, only for analyse backend performance - -Than the transaction was created on community server, send to login-server, signed (if unsecure.allow_auto_sign_transactions = 1 and auto_sign = true) -and send back to community server and put into db. -After you get this answear you see the new transaction if you list transactions or call for the balance. - -Without auto-sign the transaction is pending on login-server and waits for the user to review it at -http://localhost/account/checkTransactions - - +# community server api + +In this examples I assume that you use gradido with or docker-compose build on your local maschine + +## Konto Overview +return current account balance + +GET http://localhost/state-balances/ajaxGetBalance/-127182 + +If session is valid, return: +```json +{"state":"success","balance":174500} +``` +- balance: Gradido Cent, 4 Nachkommastellen (2 Reserve), 174500 = 17,45 GDD + +## List Transactions +List all transactions from logged in user, currently without paging +Ajax: +GET http://localhost/state-balances/ajaxListTransactions/-127182/ +or +GET http://localhost/state-balances/ajaxListTransactions/-127182/DESC +to get transaction in descending order + +Antwort: +Wenn alles okay: +```json +{"state":"success", "transactions": + [ + { + "name": "Max Mustermann", + "email": "Maxim Mustermann", + "type": "send", + "transaction_id": 2, + "date": "2021-02-19T13:25:36+00:00", + "balance": 1920000, + "memo": "a piece of cake :)", + "pubkey": "038a6f93270dc57b91d76bf110ad3863fcb7d1b08e7692e793fcdb4467e5b6a7" + } + ], + "transactionExecutingCount": 0, + "count": 1, + "gdtSum": 0, + "timeUsed": 0.04562687873840332 +} +``` + +- name: name of other involved party or empty if unknown (if other party don't belong to group) + - if type is send, name is name of receiver + - if type is receive, name is name of sender + - if type is creation currently I use a static string ("Gradido Akademie) +- email: optional, only if type is send or receive and other user is known +- pubkey: optional, only if type is send or receive and other user isn't known +- type: type of transaction + - creation: user has get gradidos created + - send: user has send another user gradidos + - receiver: user has received gradidos from another user +- transaction_id: id of transaction in db, in stage2 also the hedera sequence number of transaction +- date: date of ordering transaction (booking date) +- balance: Gradido Cent, 4 Nachkommastellen (2 Reserve), 1920000 = 192,00 GDD +- memo: Details about transaction +- pubkey: optional, if other party isn't known, hexadecimal representation of 32 Byte public key of user [0-9a-f] + +- transactionExecutingCount: how many transaction for this user currently pending and waiting for signing +- count: sum of finished transactions user is involved +- gdtSum: sum of gdt of user in cent with 2 places (Nachkommastellen) +- timeUsed: time used for getting data from db in seconds, only for analyse backend performance + +## Creation Transaction +Make a creation transaction +With new Option set in Login-Server: +```ini +unsecure.allow_auto_sign_transactions = 1 +``` +transactions can be auto-signed directly with handing in transaction. +Normally a forwarding to login-server check transactions side is neccessary to minimize security risks. + +POST http://localhost/transaction-creations/ajaxCreate +```json +{ + "session_id" : -127182, + "email": "max.musterman@gmail.de", + "amount": 10000000, + "target_date":"2021-02-19T13:25:36+00:00", + "memo":"AGE", + "auto_sign": true +} +``` +return if everything is ok: +```json +{"state":"success", "timeUsed": 0.0122} +``` +- timeUsed: time used for getting data from db in seconds, only for analyse backend performance + +## Send Coins Transaction +Make a simple GDD Transaction, send Coins from one user to other. +With new Option set in Login-Server: +```ini +unsecure.allow_auto_sign_transactions = 1 +``` +transactions can be auto-signed directly with handing in transaction. +Normally a forwarding to login-server check transactions side is neccessary to minimize security risks. + +POST http://localhost/transaction-send-coins/ajaxCreate +```json +{ + "session_id" : -127182, + "amount": 2000000, + "email": "max.musterman@gmail.de", + "memo":"Thank you :)", + "auto_sign": true +} +``` +- amout: amount to transfer, 2000000 = 200,00 GDD +- email: receiver email address, must be differ from user email +- memo: Details about transaction +- auto_sign: set to true to directly sign transaction if unsecure.allow_auto_sign_transactions = 1 is set + +return if everything is ok: +```json +{"state":"success", "timeUsed": 0.0122} +``` +- timeUsed: time used for getting data from db in seconds, only for analyse backend performance + +Than the transaction was created on community server, send to login-server, signed (if unsecure.allow_auto_sign_transactions = 1 and auto_sign = true) +and send back to community server and put into db. +After you get this answear you see the new transaction if you list transactions or call for the balance. + +Without auto-sign the transaction is pending on login-server and waits for the user to review it at +http://localhost/account/checkTransactions + + diff --git a/mariadb/Dockerfile b/mariadb/Dockerfile index 526ebf250..d88257a8e 100644 --- a/mariadb/Dockerfile +++ b/mariadb/Dockerfile @@ -1,20 +1,20 @@ -######################################################################################################### -# mariadb server -######################################################################################################### -From mariadb/server:10.5 as mariadb_server - -ENV DOCKER_WORKDIR="/docker-entrypoint-initdb.d" - -RUN mkdir -p ${DOCKER_WORKDIR} -WORKDIR ${DOCKER_WORKDIR} - -# create databases -COPY ./mariadb/setup_dbs.sql a_setup_dbs.sql -# login server db -COPY ./login_server/skeema/ . -RUN cd ./gradido_login/ && for f in *.sql; do cp -- "$f" "../b_$f"; sed -i '1i use gradido_login;' "../b_$f"; done -# community server db -COPY ./community_server/skeema/ . -RUN cd ./gradido_community/ && for f in *.sql; do cp -- "$f" "../d_$f"; sed -i '1i use gradido_community;' "../d_$f"; done -RUN cd ./gradido_community/insert && for f in *.sql; do cp -- "$f" "../../e_$f"; sed -i '1i use gradido_community;' "../../e_$f"; done - +######################################################################################################### +# mariadb server +######################################################################################################### +From mariadb/server:10.5 as mariadb_server + +ENV DOCKER_WORKDIR="/docker-entrypoint-initdb.d" + +RUN mkdir -p ${DOCKER_WORKDIR} +WORKDIR ${DOCKER_WORKDIR} + +# create databases +COPY ./mariadb/setup_dbs.sql a_setup_dbs.sql +# login server db +COPY ./login_server/skeema/ . +RUN cd ./gradido_login/ && for f in *.sql; do cp -- "$f" "../b_$f"; sed -i '1i use gradido_login;' "../b_$f"; done +# community server db +COPY ./community_server/skeema/ . +RUN cd ./gradido_community/ && for f in *.sql; do cp -- "$f" "../d_$f"; sed -i '1i use gradido_community;' "../d_$f"; done +RUN cd ./gradido_community/insert && for f in *.sql; do cp -- "$f" "../../e_$f"; sed -i '1i use gradido_community;' "../../e_$f"; done + diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index 87a9a1456..d648fb564 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -1,9 +1,9 @@ -From phpdockerio/php74-fpm as php-fpm - -# Install selected extensions and other stuff -RUN apt-get update \ - && apt-get -y --no-install-recommends install curl php7.4-curl php7.4-fpm php7.4-mbstring php7.4-intl php7.4-xml php7.4-pdo php7.4-mysql\ - && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - - +From phpdockerio/php74-fpm as php-fpm + +# Install selected extensions and other stuff +RUN apt-get update \ + && apt-get -y --no-install-recommends install curl php7.4-curl php7.4-fpm php7.4-mbstring php7.4-intl php7.4-xml php7.4-pdo php7.4-mysql\ + && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + + WORKDIR "/var/www/cakephp" \ No newline at end of file