From 7ffb0ea5d4e69e5518e0a0de214eba829d4e31db Mon Sep 17 00:00:00 2001 From: AlexeyNaumchuk <90253604+AlexeyNaumchuk@users.noreply.github.com> Date: Mon, 27 Mar 2023 16:48:12 +0200 Subject: [PATCH 1/7] Create publish-dh.yml --- .github/workflows/publish-dh.yml | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/publish-dh.yml diff --git a/.github/workflows/publish-dh.yml b/.github/workflows/publish-dh.yml new file mode 100644 index 000000000..ab664640b --- /dev/null +++ b/.github/workflows/publish-dh.yml @@ -0,0 +1,44 @@ +on: + push: + tags: [ 'v*.*.*' ] + +env: + REGISTRY: docker.io + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log into Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.IMAGE_NAME }} + tags: | + type=ref,event=tag + type=semver,pattern={{major}}.{{minor}}.{{patch}} + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + build-args: | + CI_GILAB_TOKEN=${{ secrets.CI_GILAB_TOKEN }} From 0359c59d3092ec45e474d73462ed16f5f6641998 Mon Sep 17 00:00:00 2001 From: "alexey.naumchuk" Date: Mon, 27 Mar 2023 17:58:05 +0200 Subject: [PATCH 2/7] Add werf, nginx --- .github/workflows/build.yml | 39 +++++++++++ .github/workflows/publish-dh.yml | 44 ------------- nginx.conf | 107 +++++++++++++++++++++++++++++++ werf.yaml | 36 +++++++++++ 4 files changed, 182 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/publish-dh.yml create mode 100644 nginx.conf create mode 100644 werf.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..68c39d2a1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +on: + push: + branches: + - '*' + tags: + - '*.*.*' + +jobs: + converge: + name: Converge + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install werf + uses: werf/actions/install@v1.2 + + - name: Log in to registry + # This is where you will update the personal access token to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Run echo + run: | + werf version + docker version + echo $GITHUB_REPOSITORY + echo $GITHUB_SHA + + - name: Run Build + run: | + . $(werf ci-env github --as-file) + werf build --save-build-report=true --build-report-path=images-report.json + docker pull $(cat images-report.json | jq -r .Images.web.DockerImageName) + docker tag $(cat images-report.json | jq -r .Images.web.DockerImageName) ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA + docker push ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA diff --git a/.github/workflows/publish-dh.yml b/.github/workflows/publish-dh.yml deleted file mode 100644 index ab664640b..000000000 --- a/.github/workflows/publish-dh.yml +++ /dev/null @@ -1,44 +0,0 @@ -on: - push: - tags: [ 'v*.*.*' ] - -env: - REGISTRY: docker.io - IMAGE_NAME: ${{ github.repository }} - - -jobs: - build: - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Log into Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.IMAGE_NAME }} - tags: | - type=ref,event=tag - type=semver,pattern={{major}}.{{minor}}.{{patch}} - - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - build-args: | - CI_GILAB_TOKEN=${{ secrets.CI_GILAB_TOKEN }} diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 000000000..b2e6213b0 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,107 @@ +# you must set worker processes based on your CPU cores, nginx does not benefit from setting more than that +worker_processes auto; #some last versions calculate it automatically + +# number of file descriptors used for nginx +# the limit for the maximum FDs on the server is usually set by the OS. +# if you don't set FD's then OS settings will be used which is by default 2000 +worker_rlimit_nofile 100000; + +# only log critical errors +error_log /var/log/nginx/error.log crit; + +# provides the configuration file context in which the directives that affect connection processing are specified. +events { + # determines how much clients will be served per worker + # max clients = worker_connections * worker_processes + # max clients is also limited by the number of socket connections available on the system (~64k) + worker_connections 4000; + + # optimized to serve many clients with each thread, essential for linux -- for testing environment + use epoll; + + # accept as many connections as possible, may flood worker connections if set too low -- for testing environment + multi_accept on; +} + +http { + # Temporary directories for kubernetes "readonlyfilesystem" + client_body_temp_path /tmp/nginx-client-body; + proxy_temp_path /tmp/nginx-proxy; + fastcgi_temp_path /tmp/nginx-fastcgi; + uwsgi_temp_path /tmp/nginx-uwsgi; + scgi_temp_path /tmp/nginx-scgi; + # cache informations about FDs, frequently accessed files + # can boost performance, but you need to test those values + open_file_cache max=200000 inactive=20s; + open_file_cache_valid 30s; + open_file_cache_min_uses 2; + open_file_cache_errors on; + + # to boost I/O on HDD we can disable access logs + access_log off; + + # copies data between one FD and other from within the kernel + # faster than read() + write() + sendfile on; + + # send headers in one piece, it is better than sending them one by one + tcp_nopush on; + + # don't buffer data sent, good for small data bursts in real time + tcp_nodelay on; + + # reduce the data that needs to be sent over network -- for testing environment + gzip on; + # gzip_static on; + gzip_min_length 10240; + gzip_comp_level 1; + gzip_vary on; + gzip_disable msie6; + gzip_proxied expired no-cache no-store private auth; + gzip_types + # text/html is always compressed by HttpGzipModule + text/css + text/javascript + text/xml + text/plain + text/x-component + application/javascript + application/x-javascript + application/json + application/xml + application/rss+xml + application/atom+xml + font/truetype + font/opentype + application/vnd.ms-fontobject + image/svg+xml; + + # allow the server to close connection on non responding client, this will free up memory + reset_timedout_connection on; + + # request timed out -- default 60 + client_body_timeout 10; + + # if client stop responding, free up memory -- default 60 + send_timeout 2; + + # server will close connection after this time -- default 75 + keepalive_timeout 30; + + # number of requests client can make over keep-alive -- for testing environment + keepalive_requests 100000; + + include /etc/nginx/mime.types; + + server { + listen 80 default_server; + root /usr/share/nginx/html; + index index.html index.htm; + server_name _; + location / { + aio threads; + try_files $uri /index.html; + } + } + +} diff --git a/werf.yaml b/werf.yaml new file mode 100644 index 000000000..61b96c944 --- /dev/null +++ b/werf.yaml @@ -0,0 +1,36 @@ +configVersion: 1 +project: "web-client" +--- +image: builder # Название собираемого образа. +from: node:14-alpine3.11 # Базовый образ. +git: # Секция с директивами для добавления исходных файлов из git-репозитория. + - add: / # Исходный путь в репозитории. + to: /app # Путь назначения в образе. + stageDependencies: # Настройка перевыполнения сборочных инструкций при изменениях определённых файлов в репозитории. + install: # Для стадии Install. + - package.json + - yarn.lock + setup: # Для стадии Setup. + - "**/*" +shell: # Shell сборочные инструкции. + install: # Для стадии Install. + - cd /app + #- yarn autoclean --init + #- yarn autoclean --force + - apk --no-cache --update --virtual build-dependencies add python make g++ + - yarn install + setup: # Для стадии Setup. + - cd /app + - yarn build + +--- +image: web +from: nginx:alpine +git: + - add: /nginx.conf + to: /etc/nginx/nginx.conf +import: + - image: builder + add: /app/dist + to: /usr/share/nginx/html + after: setup From 73c4478a63d56f79c101e5b0c25c546bdbf3c2f7 Mon Sep 17 00:00:00 2001 From: xxxvik-xakerxxx Date: Mon, 27 Mar 2023 19:34:32 +0000 Subject: [PATCH 3/7] :bug: start build --- .github/workflows/{build.yml => main.yml} | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) rename .github/workflows/{build.yml => main.yml} (88%) diff --git a/.github/workflows/build.yml b/.github/workflows/main.yml similarity index 88% rename from .github/workflows/build.yml rename to .github/workflows/main.yml index 68c39d2a1..f2c5498f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/main.yml @@ -2,8 +2,6 @@ on: push: branches: - '*' - tags: - - '*.*.*' jobs: converge: @@ -29,11 +27,10 @@ jobs: docker version echo $GITHUB_REPOSITORY echo $GITHUB_SHA - - name: Run Build run: | - . $(werf ci-env github --as-file) + . $(werf ci-env github --as-file) werf build --save-build-report=true --build-report-path=images-report.json docker pull $(cat images-report.json | jq -r .Images.web.DockerImageName) docker tag $(cat images-report.json | jq -r .Images.web.DockerImageName) ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA - docker push ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA + docker push ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA \ No newline at end of file From cde8ca0f51d05c4ab15a91dc3e5fcb2f75cf1466 Mon Sep 17 00:00:00 2001 From: xxxvik-xakerxxx Date: Mon, 27 Mar 2023 19:39:48 +0000 Subject: [PATCH 4/7] :bug: delete ci --- .github/workflows/main.yml | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index f2c5498f1..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,36 +0,0 @@ -on: - push: - branches: - - '*' - -jobs: - converge: - name: Converge - runs-on: ubuntu-latest - steps: - - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install werf - uses: werf/actions/install@v1.2 - - - name: Log in to registry - # This is where you will update the personal access token to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - - name: Run echo - run: | - werf version - docker version - echo $GITHUB_REPOSITORY - echo $GITHUB_SHA - - name: Run Build - run: | - . $(werf ci-env github --as-file) - werf build --save-build-report=true --build-report-path=images-report.json - docker pull $(cat images-report.json | jq -r .Images.web.DockerImageName) - docker tag $(cat images-report.json | jq -r .Images.web.DockerImageName) ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA - docker push ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA \ No newline at end of file From 75068ae3ef5e33e8705b84d74bcf13dcf3dafb8f Mon Sep 17 00:00:00 2001 From: xxxvik-xakerxxx Date: Mon, 27 Mar 2023 22:40:27 +0300 Subject: [PATCH 5/7] Create main.yml --- .github/workflows/main.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..6d09e64ac --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,36 @@ +on: + push: + branches: + - '*' + +jobs: + converge: + name: Converge + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install werf + uses: werf/actions/install@v1.2 + + - name: Log in to registry + # This is where you will update the personal access token to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Run echo + run: | + werf version + docker version + echo $GITHUB_REPOSITORY + echo $GITHUB_SHA + - name: Run Build + run: | + . $(werf ci-env github --as-file) + werf build --save-build-report=true --build-report-path=images-report.json + docker pull $(cat images-report.json | jq -r .Images.web.DockerImageName) + docker tag $(cat images-report.json | jq -r .Images.web.DockerImageName) ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA + docker push ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA From 12d41854bc8a5fbd4279a966d31614a1132be21c Mon Sep 17 00:00:00 2001 From: xxxvik-xakerxxx Date: Mon, 27 Mar 2023 22:49:27 +0300 Subject: [PATCH 6/7] :bug: test ci --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6d09e64ac..c55b890af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,7 @@ on: branches: - '*' + jobs: converge: name: Converge From c41feca4d28c7ea97a91325f9bc3790a4c2ff8b4 Mon Sep 17 00:00:00 2001 From: xxxvik-xakerxxx Date: Mon, 27 Mar 2023 22:49:59 +0300 Subject: [PATCH 7/7] :bug: new branch ci --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c55b890af..6d09e64ac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,6 @@ on: branches: - '*' - jobs: converge: name: Converge