From 235f7f120902d01627e64b46a3e656bf839d2e24 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 10:55:32 +0700 Subject: [PATCH 01/30] added new drone file --- .drone.yml | 82 +++++++++--------------------------------------------- 1 file changed, 13 insertions(+), 69 deletions(-) diff --git a/.drone.yml b/.drone.yml index 0ddbd29c..207c2ae1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,78 +7,22 @@ platform: arch: amd64 steps: - - name: compress - image: alpine - commands: - - rm -rf ./app.tar.bz2 - - tar -cjf ./app.tar.bz2 -C ./ . - - name: upload - image: drillster/drone-rsync - when: - branch: - - master - - develop - environment: - RSYNC_KEY: - from_secret: rsync_key - RSYNC_USER: - from_secret: rsync_user - PLUGIN_ARGS: -zz -O --no-perms - settings: - port: 22522 - hosts: - - vault48.org - source: ./ - user: ${rsync_user} - key: ${rsync_key} - target: /tmp/vault-frontend-${DRONE_BRANCH} - include: - - "app.tar.bz2" - exclude: - - "*" - name: build - image: appleboy/drone-ssh + image: plugins/docker when: branch: - - master - develop - environment: - BUILD_PATH: - from_secret: build_path - ENV_PATH: - from_secret: env_path settings: - host: vault48.org + dockerfile: docker/www/Dockerfile + tag: + - ${DRONE_BRANCH} + custom_labels: + - commit: DRONE_COMMIT_SHA username: - from_secret: rsync_user - key: - from_secret: rsync_key - envs: [build_path, env_path] - port: 22522 - script_stop: true - script: - - mkdir -p $${BUILD_PATH}/${DRONE_BRANCH} - - rm -rf $${BUILD_PATH}/${DRONE_BRANCH}/* - - cd $${BUILD_PATH}/${DRONE_BRANCH} - - tar -xjf /tmp/vault-frontend-${DRONE_BRANCH}/app.tar.bz2 -C ./ - - cp -a $${ENV_PATH}/${DRONE_BRANCH}/. $${BUILD_PATH}/${DRONE_BRANCH} - - docker-compose build - - docker-compose up -d - - name: telgram_notify - image: appleboy/drone-telegram - when: - status: - - success - - failure - settings: - token: - from_secret: telegram_token - to: - from_secret: telegram_chat_id - format: markdown - message: > - {{#success build.status}}πŸ€“{{else}}😨{{/success}} - [{{repo.name}} / {{commit.branch}}]({{ build.link }}) - ``` - {{ commit.message }} - ``` + from_secret: global_docker_login + password: + from_secret: global_docker_password + repo: + from_secret: project_name + registry: + from_secret: global_docker_registry From 214383de321ef1ddb5e62464a77bea48bf53cb12 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 10:56:29 +0700 Subject: [PATCH 02/30] commented-out unnecessary build stages --- docker/www/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/www/Dockerfile b/docker/www/Dockerfile index 46e2cf2a..09850941 100644 --- a/docker/www/Dockerfile +++ b/docker/www/Dockerfile @@ -1,9 +1,9 @@ # stage1 as builder FROM node:dubnium-alpine as builder COPY package.json yarn.lock ./ -RUN yarn +#RUN yarn COPY . . -RUN yarn build +#RUN yarn build FROM nginx:alpine COPY docker/www/nginx.conf /etc/nginx/nginx.conf From 113270878af31866944c08ffb31ac30a15550fec Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 10:58:49 +0700 Subject: [PATCH 03/30] commented-out unnecessary build stages --- docker/www/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/www/Dockerfile b/docker/www/Dockerfile index 09850941..9e9208f6 100644 --- a/docker/www/Dockerfile +++ b/docker/www/Dockerfile @@ -8,6 +8,6 @@ COPY . . FROM nginx:alpine COPY docker/www/nginx.conf /etc/nginx/nginx.conf RUN rm -rf /usr/share/nginx/html/* -COPY --from=builder /build /usr/share/nginx/html +#COPY --from=builder /build /usr/share/nginx/html EXPOSE ${EXPOSE} 80 ENTRYPOINT ["nginx", "-g", "daemon off;"] From 78c0c6e9ad8f482ccfaf663a1e17f9339427bc0f Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 11:11:03 +0700 Subject: [PATCH 04/30] added dynamic repo --- .drone.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 207c2ae1..dc0f4be5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -22,7 +22,6 @@ steps: from_secret: global_docker_login password: from_secret: global_docker_password - repo: - from_secret: project_name + repo: $${global_docker_registry}/$${project_name} registry: from_secret: global_docker_registry From e265a01ebc472bbcd9f86589f28f0525fb8c7415 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 11:13:21 +0700 Subject: [PATCH 05/30] added dynamic repo --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index dc0f4be5..e71f378d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -22,6 +22,6 @@ steps: from_secret: global_docker_login password: from_secret: global_docker_password - repo: $${global_docker_registry}/$${project_name} registry: from_secret: global_docker_registry + repo: ${global_docker_registry}/${DRONE_REPO_NAME} From a828d509e5207ca59f6aa1cb0e27c783065898b7 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 11:21:21 +0700 Subject: [PATCH 06/30] added registry global env --- .drone.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index e71f378d..f5492996 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,6 +6,10 @@ platform: os: linux arch: amd64 +environment: + REGISTRY: + from_secret: global_docker_registry + steps: - name: build image: plugins/docker @@ -24,4 +28,4 @@ steps: from_secret: global_docker_password registry: from_secret: global_docker_registry - repo: ${global_docker_registry}/${DRONE_REPO_NAME} + repo: ${REGISTRY}/${DRONE_REPO_NAME} From 7d8bc15a0ba5867e6a4a34fc5f100f33a382c6cb Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 11:22:58 +0700 Subject: [PATCH 07/30] added registry global env --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index f5492996..01d2ddab 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,11 +21,11 @@ steps: tag: - ${DRONE_BRANCH} custom_labels: - - commit: DRONE_COMMIT_SHA + - commit: ${DRONE_COMMIT_SHA} username: from_secret: global_docker_login password: from_secret: global_docker_password registry: from_secret: global_docker_registry - repo: ${REGISTRY}/${DRONE_REPO_NAME} + repo: $${REGISTRY}/${DRONE_REPO_NAME} From 74166e64678f9d9af4f4f9c7bd9f24b816aa36c4 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 11:27:46 +0700 Subject: [PATCH 08/30] added registry global env --- .drone.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 01d2ddab..22645579 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,7 +7,7 @@ platform: arch: amd64 environment: - REGISTRY: + registry: from_secret: global_docker_registry steps: @@ -21,11 +21,11 @@ steps: tag: - ${DRONE_BRANCH} custom_labels: - - commit: ${DRONE_COMMIT_SHA} + commit: ${DRONE_COMMIT_SHA} username: from_secret: global_docker_login password: from_secret: global_docker_password registry: from_secret: global_docker_registry - repo: $${REGISTRY}/${DRONE_REPO_NAME} + repo: "${registry}/${DRONE_REPO_NAME}" From c855f33d35724cd167719168f0ca7a492a092949 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 11:40:42 +0700 Subject: [PATCH 09/30] added template --- .drone.yml | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/.drone.yml b/.drone.yml index 22645579..e134cf10 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,31 +1,7 @@ -kind: pipeline -name: build -type: docker - -platform: - os: linux - arch: amd64 - -environment: +kind: template +load: registry.yaml +data: registry: from_secret: global_docker_registry + dockerfile: docker/www/Dockerfile -steps: - - name: build - image: plugins/docker - when: - branch: - - develop - settings: - dockerfile: docker/www/Dockerfile - tag: - - ${DRONE_BRANCH} - custom_labels: - commit: ${DRONE_COMMIT_SHA} - username: - from_secret: global_docker_login - password: - from_secret: global_docker_password - registry: - from_secret: global_docker_registry - repo: "${registry}/${DRONE_REPO_NAME}" From bbae869a1c12d0cff85d327c543112c0dcb9d68b Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 11:45:44 +0700 Subject: [PATCH 10/30] added template --- .drone.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index e134cf10..4bc23f15 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,7 +1,5 @@ kind: template load: registry.yaml data: - registry: - from_secret: global_docker_registry + registry: global_docker_registry dockerfile: docker/www/Dockerfile - From c960509a4d43b7b32791decefc9796babba45a4c Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 11:49:34 +0700 Subject: [PATCH 11/30] added template --- .drone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 4bc23f15..3024e24a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,5 +1,6 @@ kind: template load: registry.yaml data: - registry: global_docker_registry + registry: + from_secret: global_docker_registry dockerfile: docker/www/Dockerfile From 49e0241f40679e953eb811d7b60fc0498d3f577d Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 11:55:49 +0700 Subject: [PATCH 12/30] added template --- .drone.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 3024e24a..c4d6453b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,5 @@ kind: template load: registry.yaml data: - registry: - from_secret: global_docker_registry dockerfile: docker/www/Dockerfile + From 92fce4c7836e1afcc95b9df98d3b2f9dc7d1399f Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 11:58:04 +0700 Subject: [PATCH 13/30] added branches to template --- .drone.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.drone.yml b/.drone.yml index c4d6453b..33f97c1b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,4 +2,7 @@ kind: template load: registry.yaml data: dockerfile: docker/www/Dockerfile + branches: + - master + - develop From 3164cd97531fedb9fa313f6d145bd2ffb4d4f50a Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 12:00:19 +0700 Subject: [PATCH 14/30] added branches to template --- .drone.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 33f97c1b..41feb424 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,4 +5,7 @@ data: branches: - master - develop - + when: + branch: + - master + - develop From 952c2a3f824d9057a75b8121d6bd8d11b8a53f85 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 12:02:09 +0700 Subject: [PATCH 15/30] made build based on template --- .drone.yml | 8 +------- docker/www/Dockerfile | 7 +++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.drone.yml b/.drone.yml index 41feb424..c4d6453b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,10 +2,4 @@ kind: template load: registry.yaml data: dockerfile: docker/www/Dockerfile - branches: - - master - - develop - when: - branch: - - master - - develop + diff --git a/docker/www/Dockerfile b/docker/www/Dockerfile index 9e9208f6..a910e3aa 100644 --- a/docker/www/Dockerfile +++ b/docker/www/Dockerfile @@ -1,13 +1,12 @@ -# stage1 as builder FROM node:dubnium-alpine as builder COPY package.json yarn.lock ./ -#RUN yarn +RUN yarn COPY . . -#RUN yarn build +RUN yarn build FROM nginx:alpine COPY docker/www/nginx.conf /etc/nginx/nginx.conf RUN rm -rf /usr/share/nginx/html/* -#COPY --from=builder /build /usr/share/nginx/html +COPY --from=builder /build /usr/share/nginx/html EXPOSE ${EXPOSE} 80 ENTRYPOINT ["nginx", "-g", "daemon off;"] From b2ab42bdf14b81d322617886a397b364fdec1e6e Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 12:08:27 +0700 Subject: [PATCH 16/30] made build based on template --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index c4d6453b..0a053472 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,4 +2,3 @@ kind: template load: registry.yaml data: dockerfile: docker/www/Dockerfile - From 9c16946b0de22bf24c1b8cb0dd409e8468fbfaaa Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 12:18:27 +0700 Subject: [PATCH 17/30] changed env file --- .env | 2 ++ .gitignore | 1 - docker/www/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 00000000..7cbd9050 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +REACT_APP_API_HOST = https://pig.vault48.org/ +REACT_APP_REMOTE_CURRENT = https://pig.vault48.org/static/ diff --git a/.gitignore b/.gitignore index 1e572c99..a0d7b1b9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ /npm-debug.log /.idea /dist -/.env diff --git a/docker/www/Dockerfile b/docker/www/Dockerfile index a910e3aa..e920f159 100644 --- a/docker/www/Dockerfile +++ b/docker/www/Dockerfile @@ -8,5 +8,5 @@ FROM nginx:alpine COPY docker/www/nginx.conf /etc/nginx/nginx.conf RUN rm -rf /usr/share/nginx/html/* COPY --from=builder /build /usr/share/nginx/html -EXPOSE ${EXPOSE} 80 ENTRYPOINT ["nginx", "-g", "daemon off;"] + From 77b39fcc24514d465bf36338e73b82108efd5364 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 12:43:50 +0700 Subject: [PATCH 18/30] added .env.development file to repo --- .drone.yml | 35 +++++++++++++++++++++++++++++++---- .env | 2 -- .env.development | 2 ++ .env_example | 3 --- docker/www/Dockerfile | 1 - 5 files changed, 33 insertions(+), 10 deletions(-) delete mode 100644 .env create mode 100644 .env.development delete mode 100644 .env_example diff --git a/.drone.yml b/.drone.yml index 0a053472..0060ee1c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,4 +1,31 @@ -kind: template -load: registry.yaml -data: - dockerfile: docker/www/Dockerfile +kind: pipeline +name: build +type: docker + +platform: + os: linux + arch: amd64 + +steps: + - name: build + image: plugins/docker + when: + branch: + - master + environment: + - REACT_APP_API_HOST: https://pig.vault48.org/ + - REACT_APP_REMOTE_CURRENT: https://pig.vault48.org/static/ + settings: + dockerfile: docker/www/Dockerfile + tag: + - ${DRONE_BRANCH} + custom_labels: + - "commit=${DRONE_COMMIT_SHA}" + username: + from_secret: global_docker_login + password: + from_secret: global_docker_password + registry: + from_secret: global_docker_registry + repo: + from_secret: docker_repo diff --git a/.env b/.env deleted file mode 100644 index 7cbd9050..00000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -REACT_APP_API_HOST = https://pig.vault48.org/ -REACT_APP_REMOTE_CURRENT = https://pig.vault48.org/static/ diff --git a/.env.development b/.env.development new file mode 100644 index 00000000..f0b95934 --- /dev/null +++ b/.env.development @@ -0,0 +1,2 @@ +REACT_APP_API_HOST: https://pig.staging.vault48.org/ +REACT_APP_REMOTE_CURRENT: https://pig.staging.vault48.org/static/ diff --git a/.env_example b/.env_example deleted file mode 100644 index 06034750..00000000 --- a/.env_example +++ /dev/null @@ -1,3 +0,0 @@ -REACT_APP_API_HOST = https://pig.staging.vault48.org/ -REACT_APP_REMOTE_CURRENT = https://pig.staging.vault48.org/static/ -EXPOSE = 4000 diff --git a/docker/www/Dockerfile b/docker/www/Dockerfile index e920f159..b9583777 100644 --- a/docker/www/Dockerfile +++ b/docker/www/Dockerfile @@ -9,4 +9,3 @@ COPY docker/www/nginx.conf /etc/nginx/nginx.conf RUN rm -rf /usr/share/nginx/html/* COPY --from=builder /build /usr/share/nginx/html ENTRYPOINT ["nginx", "-g", "daemon off;"] - From 4edee8e92c8b9839e6e9d4be519034bbe68bc461 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 12:44:37 +0700 Subject: [PATCH 19/30] fixed branch to develop --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 0060ee1c..383daaf1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ steps: image: plugins/docker when: branch: - - master + - develop environment: - REACT_APP_API_HOST: https://pig.vault48.org/ - REACT_APP_REMOTE_CURRENT: https://pig.vault48.org/static/ From 953db4a2c75951aabec130078792b9ae68e16d06 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 14:08:05 +0700 Subject: [PATCH 20/30] added variables for develop and master --- .drone.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 383daaf1..38a7f0e8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,11 +7,11 @@ platform: arch: amd64 steps: - - name: build + - name: build-master image: plugins/docker when: branch: - - develop + - master environment: - REACT_APP_API_HOST: https://pig.vault48.org/ - REACT_APP_REMOTE_CURRENT: https://pig.vault48.org/static/ @@ -29,3 +29,25 @@ steps: from_secret: global_docker_registry repo: from_secret: docker_repo + - name: build-develop + image: plugins/docker + when: + branch: + - develop + environment: + - REACT_APP_API_HOST: https://pig.staging.vault48.org/ + - REACT_APP_REMOTE_CURRENT: https://pig.staging.vault48.org/static/ + settings: + dockerfile: docker/www/Dockerfile + tag: + - ${DRONE_BRANCH} + custom_labels: + - "commit=${DRONE_COMMIT_SHA}" + username: + from_secret: global_docker_login + password: + from_secret: global_docker_password + registry: + from_secret: global_docker_registry + repo: + from_secret: docker_repo From de979101277b1e0f46a542d8c233f38691fba8eb Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 14:09:11 +0700 Subject: [PATCH 21/30] added variables for develop and master --- .drone.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 38a7f0e8..8ad662b4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,8 +13,8 @@ steps: branch: - master environment: - - REACT_APP_API_HOST: https://pig.vault48.org/ - - REACT_APP_REMOTE_CURRENT: https://pig.vault48.org/static/ + REACT_APP_API_HOST: https://pig.vault48.org/ + REACT_APP_REMOTE_CURRENT: https://pig.vault48.org/static/ settings: dockerfile: docker/www/Dockerfile tag: @@ -35,8 +35,8 @@ steps: branch: - develop environment: - - REACT_APP_API_HOST: https://pig.staging.vault48.org/ - - REACT_APP_REMOTE_CURRENT: https://pig.staging.vault48.org/static/ + REACT_APP_API_HOST: https://pig.staging.vault48.org/ + REACT_APP_REMOTE_CURRENT: https://pig.staging.vault48.org/static/ settings: dockerfile: docker/www/Dockerfile tag: From c95685bc272db534ad03e73efdb3e9949028310e Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 14:35:16 +0700 Subject: [PATCH 22/30] added env variables to builder --- docker/www/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/www/Dockerfile b/docker/www/Dockerfile index b9583777..b8f6cd6e 100644 --- a/docker/www/Dockerfile +++ b/docker/www/Dockerfile @@ -2,7 +2,7 @@ FROM node:dubnium-alpine as builder COPY package.json yarn.lock ./ RUN yarn COPY . . -RUN yarn build +RUN REACT_APP_API_HOST=${REACT_APP_API_HOST} REACT_APP_REMOTE_CURRENT=${REACT_APP_REMOTE_CURRENT} yarn build FROM nginx:alpine COPY docker/www/nginx.conf /etc/nginx/nginx.conf From dd378270312c8ba1182e64afbe3e14bacd7f4100 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 14:38:02 +0700 Subject: [PATCH 23/30] added env variables to builder --- .drone.yml | 3 +++ docker/www/Dockerfile | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 8ad662b4..403ec443 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,6 +39,9 @@ steps: REACT_APP_REMOTE_CURRENT: https://pig.staging.vault48.org/static/ settings: dockerfile: docker/www/Dockerfile + build_args_from_env: + - REACT_APP_API_HOST + - REACT_APP_REMOTE_CURRENT tag: - ${DRONE_BRANCH} custom_labels: diff --git a/docker/www/Dockerfile b/docker/www/Dockerfile index b8f6cd6e..299b4eab 100644 --- a/docker/www/Dockerfile +++ b/docker/www/Dockerfile @@ -2,7 +2,11 @@ FROM node:dubnium-alpine as builder COPY package.json yarn.lock ./ RUN yarn COPY . . -RUN REACT_APP_API_HOST=${REACT_APP_API_HOST} REACT_APP_REMOTE_CURRENT=${REACT_APP_REMOTE_CURRENT} yarn build +ARG REACT_APP_REMOTE_CURRENT +ARG REACT_APP_REMOTE_CURRENT +ENV REACT_APP_REMOTE_CURRENT $REACT_APP_REMOTE_CURRENT +ENV REACT_APP_REMOTE_CURRENT $REACT_APP_REMOTE_CURRENT +RUN yarn build FROM nginx:alpine COPY docker/www/nginx.conf /etc/nginx/nginx.conf From 6ff05be97cf730c3247cdc9f28c023714755759c Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 14:46:14 +0700 Subject: [PATCH 24/30] added env variables to builder --- docker/www/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/www/Dockerfile b/docker/www/Dockerfile index 299b4eab..aaaf2188 100644 --- a/docker/www/Dockerfile +++ b/docker/www/Dockerfile @@ -2,9 +2,9 @@ FROM node:dubnium-alpine as builder COPY package.json yarn.lock ./ RUN yarn COPY . . +ARG REACT_APP_API_HOST ARG REACT_APP_REMOTE_CURRENT -ARG REACT_APP_REMOTE_CURRENT -ENV REACT_APP_REMOTE_CURRENT $REACT_APP_REMOTE_CURRENT +ENV REACT_APP_API_HOST $REACT_APP_API_HOST ENV REACT_APP_REMOTE_CURRENT $REACT_APP_REMOTE_CURRENT RUN yarn build From 2c569a9aca5c003f68ac8b2849d1e84e26e592c8 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 30 Sep 2021 14:53:52 +0700 Subject: [PATCH 25/30] changed drone.yml --- .drone.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.drone.yml b/.drone.yml index 403ec443..c84cd569 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,6 +17,9 @@ steps: REACT_APP_REMOTE_CURRENT: https://pig.vault48.org/static/ settings: dockerfile: docker/www/Dockerfile + build_args_from_env: + - REACT_APP_API_HOST + - REACT_APP_REMOTE_CURRENT tag: - ${DRONE_BRANCH} custom_labels: From 277f0fea43e40640329897c0a96d29fbbb0a8a88 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 6 Oct 2021 12:09:33 +0700 Subject: [PATCH 26/30] added highlight for new comments --- src/components/comment/Comment/index.tsx | 7 +- .../containers/CommentWrapper/index.tsx | 9 +- .../CommentWrapper/styles.module.scss | 24 ++++- src/components/node/NodeBottomBlock/index.tsx | 3 + src/components/node/NodeComments/index.tsx | 87 ++++++++++--------- .../node/NodeCommentsBlock/index.tsx | 18 +++- src/constants/comment.ts | 2 + src/layouts/NodeLayout/index.tsx | 4 +- src/redux/node/actions.ts | 6 -- src/redux/node/api.ts | 6 +- src/redux/node/constants.ts | 1 - src/redux/node/handlers.ts | 16 ---- src/redux/node/reducer.ts | 7 +- src/redux/node/sagas.ts | 11 +-- src/redux/node/types.ts | 2 +- src/redux/types.ts | 1 + src/utils/fn.ts | 20 ++++- src/utils/hooks/node/useGrouppedComments.ts | 17 ++++ src/utils/hooks/useScrollToTop.ts | 11 ++- 19 files changed, 158 insertions(+), 94 deletions(-) create mode 100644 src/utils/hooks/node/useGrouppedComments.ts diff --git a/src/components/comment/Comment/index.tsx b/src/components/comment/Comment/index.tsx index 622103e8..edd5005a 100644 --- a/src/components/comment/Comment/index.tsx +++ b/src/components/comment/Comment/index.tsx @@ -5,6 +5,8 @@ import { CommentContent } from '~/components/comment/CommentContent'; import styles from './styles.module.scss'; import { CommendDeleted } from '../../node/CommendDeleted'; import * as MODAL_ACTIONS from '~/redux/modal/actions'; +import classNames from 'classnames'; +import { NEW_COMMENT_CLASSNAME } from '~/constants/comment'; type IProps = HTMLAttributes & { is_empty?: boolean; @@ -30,11 +32,14 @@ const Comment: FC = memo( }) => { return (
diff --git a/src/components/containers/CommentWrapper/index.tsx b/src/components/containers/CommentWrapper/index.tsx index 2f80e466..59e5acb1 100644 --- a/src/components/containers/CommentWrapper/index.tsx +++ b/src/components/containers/CommentWrapper/index.tsx @@ -13,6 +13,7 @@ type IProps = DivProps & { isLoading?: boolean; isSame?: boolean; isForm?: boolean; + isNew?: boolean; }; const CommentWrapper: FC = ({ @@ -23,13 +24,15 @@ const CommentWrapper: FC = ({ isSame, isForm, children, + isNew, ...props }) => (
diff --git a/src/components/containers/CommentWrapper/styles.module.scss b/src/components/containers/CommentWrapper/styles.module.scss index f457a747..b44c96d0 100644 --- a/src/components/containers/CommentWrapper/styles.module.scss +++ b/src/components/containers/CommentWrapper/styles.module.scss @@ -1,5 +1,13 @@ @import "src/styles/variables"; +@keyframes highlight { + 0% { opacity: 0.75; } + 25% { opacity: 0.5; } + 50% { opacity: 0.75; } + 75% { opacity: 0; } + 100% { opacity: 0; } +} + .wrap { @include outer_shadow; @@ -10,15 +18,27 @@ min-width: 0; border-radius: $radius; - &:global(.is_empty) { + &.is_empty { opacity: 0.5; } - &:global(.is_same) { + &.is_same { margin: 0 !important; border-radius: 0; } + &.is_new::after { + content: ' '; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + animation: highlight 1s 0.25s forwards; + background: transparentize($wisegreen, 0.7); + border-radius: $radius; + } + @include tablet { flex-direction: column; } diff --git a/src/components/node/NodeBottomBlock/index.tsx b/src/components/node/NodeBottomBlock/index.tsx index a10bd12b..314c9d22 100644 --- a/src/components/node/NodeBottomBlock/index.tsx +++ b/src/components/node/NodeBottomBlock/index.tsx @@ -23,6 +23,7 @@ interface IProps { commentsCount: number; isLoadingComments: boolean; related: INodeRelated; + lastSeenCurrent?: string; } const NodeBottomBlock: FC = ({ @@ -34,6 +35,7 @@ const NodeBottomBlock: FC = ({ commentsCount, commentsOrder, related, + lastSeenCurrent, }) => { const { inline } = useNodeBlocks(node, isLoading); const { is_user } = useUser(); @@ -50,6 +52,7 @@ const NodeBottomBlock: FC = ({ {inline &&
{inline}
} = memo(({ comments, user, count = 0, order = 'DESC' }) => { - const dispatch = useDispatch(); - const left = useMemo(() => Math.max(0, count - comments.length), [comments, count]); +const NodeComments: FC = memo( + ({ comments, user, count = 0, order = 'DESC', lastSeenCurrent }) => { + const dispatch = useDispatch(); + const left = useMemo(() => Math.max(0, count - comments.length), [comments, count]); - const groupped: ICommentGroup[] = useMemo( - () => (order === 'DESC' ? [...comments].reverse() : comments).reduce(groupCommentsByUser, []), - [comments, order] - ); + const groupped: ICommentGroup[] = useGrouppedComments(comments, order, lastSeenCurrent); - const onDelete = useCallback( - (id: IComment['id'], locked: boolean) => dispatch(nodeLockComment(id, locked)), - [dispatch] - ); - const onLoadMoreComments = useCallback(() => dispatch(nodeLoadMoreComments()), [dispatch]); - const onShowPhotoswipe = useCallback( - (images: IFile[], index: number) => dispatch(modalShowPhotoswipe(images, index)), - [dispatch] - ); + const onDelete = useCallback( + (id: IComment['id'], locked: boolean) => dispatch(nodeLockComment(id, locked)), + [dispatch] + ); + const onLoadMoreComments = useCallback(() => dispatch(nodeLoadMoreComments()), [dispatch]); + const onShowPhotoswipe = useCallback( + (images: IFile[], index: number) => dispatch(modalShowPhotoswipe(images, index)), + [dispatch] + ); - const more = useMemo( - () => - left > 0 && ( -
- ΠŸΠΎΠΊΠ°Π·Π°Ρ‚ΡŒ Π΅Ρ‰Ρ‘{' '} - {plural(Math.min(left, COMMENTS_DISPLAY), 'ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ', 'коммСнтария', 'ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠ΅Π²')} - {left > COMMENTS_DISPLAY ? ` ΠΈΠ· ${left} ΠΎΡΡ‚Π°Π²ΡˆΠΈΡ…ΡΡ` : ''} -
- ), - [left, onLoadMoreComments] - ); + const more = useMemo( + () => + left > 0 && ( +
+ ΠŸΠΎΠΊΠ°Π·Π°Ρ‚ΡŒ Π΅Ρ‰Ρ‘{' '} + {plural(Math.min(left, COMMENTS_DISPLAY), 'ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ', 'коммСнтария', 'ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠ΅Π²')} + {left > COMMENTS_DISPLAY ? ` ΠΈΠ· ${left} ΠΎΡΡ‚Π°Π²ΡˆΠΈΡ…ΡΡ` : ''} +
+ ), + [left, onLoadMoreComments] + ); - return ( -
- {order === 'DESC' && more} + return ( +
+ {order === 'DESC' && more} - {groupped.map(group => ( - - ))} + {groupped.map(group => ( + + ))} - {order === 'ASC' && more} -
- ); -}); + {order === 'ASC' && more} +
+ ); + } +); export { NodeComments }; diff --git a/src/components/node/NodeCommentsBlock/index.tsx b/src/components/node/NodeCommentsBlock/index.tsx index f111dbff..d23c017e 100644 --- a/src/components/node/NodeCommentsBlock/index.tsx +++ b/src/components/node/NodeCommentsBlock/index.tsx @@ -10,18 +10,32 @@ interface IProps { node: INode; comments: IComment[]; count: number; + lastSeenCurrent?: string; isLoading: boolean; isLoadingComments: boolean; } -const NodeCommentsBlock: FC = ({ isLoading, isLoadingComments, node, comments, count }) => { +const NodeCommentsBlock: FC = ({ + isLoading, + isLoadingComments, + node, + comments, + count, + lastSeenCurrent, +}) => { const user = useUser(); const { inline } = useNodeBlocks(node, isLoading); return isLoading || isLoadingComments || (!comments.length && !inline) ? ( ) : ( - + ); }; diff --git a/src/constants/comment.ts b/src/constants/comment.ts index 9689c167..4d46d0f5 100644 --- a/src/constants/comment.ts +++ b/src/constants/comment.ts @@ -36,3 +36,5 @@ export const COMMENT_BLOCK_RENDERERS = { [COMMENT_BLOCK_TYPES.MARK]: CommentTextBlock, [COMMENT_BLOCK_TYPES.EMBED]: CommentEmbedBlock, }; + +export const NEW_COMMENT_CLASSNAME = 'newComment'; diff --git a/src/layouts/NodeLayout/index.tsx b/src/layouts/NodeLayout/index.tsx index 48b56896..4728ea09 100644 --- a/src/layouts/NodeLayout/index.tsx +++ b/src/layouts/NodeLayout/index.tsx @@ -36,10 +36,11 @@ const NodeLayout: FC = memo( comment_count, is_loading_comments, related, + lastSeenCurrent, } = useShallowSelect(selectNode); useNodeCoverImage(current); - useScrollToTop([id]); + useScrollToTop([id, comments, is_loading_comments]); useLoadNode(id, is_loading); useOnNodeSeen(current); @@ -65,6 +66,7 @@ const NodeLayout: FC = memo( related={related} isLoadingComments={is_loading_comments} isLoading={is_loading} + lastSeenCurrent={lastSeenCurrent} />