From d077133e10b22b648d5338ecbbffc625ee012196 Mon Sep 17 00:00:00 2001 From: Oleksandr Varchenko <88536216+alexvarko@users.noreply.github.com> Date: Wed, 1 Nov 2023 17:17:08 +0200 Subject: [PATCH] Added ci (#8) * Added files for ci * Update actions.yaml * Modify files for ci * Update actions.yaml --- .github/workflows/actions.yaml | 46 +++++++++++++ .github/workflows/tag.yaml | 49 ++++++++++++++ nginx.conf | 115 +++++++++++++++++++++++++++++++++ werf.yaml | 36 +++++++++++ 4 files changed, 246 insertions(+) create mode 100644 .github/workflows/actions.yaml create mode 100644 .github/workflows/tag.yaml create mode 100644 nginx.conf create mode 100644 werf.yaml diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml new file mode 100644 index 0000000..c193631 --- /dev/null +++ b/.github/workflows/actions.yaml @@ -0,0 +1,46 @@ +on: + push: + branches: + - 'dev' + +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 export web --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA + + # stage-deploy: + # name: Deploy on stage + # needs: converge + # runs-on: ubuntu-latest + # steps: + # - name: ConfigCreate + # run: | + # mkdir ~/.kube/ + # echo "${{ secrets.KUBECONFIG }}" > config + # mv config ~/.kube/ + # ls ~/.kube/ + # kubectl set image deployment/ -n stage diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml new file mode 100644 index 0000000..5578b2e --- /dev/null +++ b/.github/workflows/tag.yaml @@ -0,0 +1,49 @@ +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + +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_REF_NAME + - name: Run Build + run: | + . $(werf ci-env github --as-file) + werf export web --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME --dev + # prod-deploy: + # name: Deploy on prod + # needs: converge + # runs-on: ubuntu-latest + # steps: + # - name: Run echo + # run: | + # echo "Tag was created - deploying on prod" + # echo tag = $GITHUB_REF_NAME + # - name: ConfigCreate + # run: | + # mkdir ~/.kube/ + # echo "${{ secrets.KUBECONFIG }}" > config + # mv config ~/.kube/ + # ls ~/.kube/ + # kubectl set image deployment/ -n prod \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..c604413 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,115 @@ +# 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; + } + location /env.js { + aio threads; + add_header Cache-Control "no-cache"; + } + location /static/env.js { + aio threads; + add_header Cache-Control "no-cache"; + } + } + +} diff --git a/werf.yaml b/werf.yaml new file mode 100644 index 0000000..93ef2fb --- /dev/null +++ b/werf.yaml @@ -0,0 +1,36 @@ +configVersion: 1 +project: "web-client" +--- +image: builder +from: node:16-alpine +git: + - add: / + to: /app + stageDependencies: + install: + - package.json + - package-lock.json + setup: + - "**/*" +shell: + install: + - cd /app + #- yarn autoclean --init + #- yarn autoclean --force + - npm install + setup: # Для стадии Setup. + - cd /app + - npm run build + +--- +image: web +from: nginx:alpine +git: + - add: /nginx.conf + to: /etc/nginx/nginx.conf +import: + - image: builder + add: /app/build + to: /usr/share/nginx/html + after: setup +