投稿時間:2022-04-13 07:18:18 RSSフィード2022-04-13 07:00 分まとめ(60件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
海外TECH DEV Community Managing Cloud Build Triggers with Terraform https://dev.to/bradasaurusrex1/managing-cloud-build-triggers-with-terraform-43mo Managing Cloud Build Triggers with TerraformOn a recent project I set up several services to run on GCP Cloud Run To make managing the infrastructure as painless as possible I set up a Terraform repo that managed it That way I could add new services by Linking the new service repo as a Cloud Source RepositoryAdding the build trigger in the terraform repoAdding the Cloud Run resources in the terraform repo Setting up the Build TriggerThis was made manageable by a few modules I set up First a serviceAgent module to wrap the IAM permissions needed by the infrastructure build resource google service account agent account id var id display name var display name SA setting this up needs access rightsresource google service account iam binding impersonator service account id google service account agent name role roles iam serviceAccountUser members concat serviceAccount var setup sa email var impersonators Then a more involved build module to encapsulate a Cloud Build trigger that outputs a docker image to an artifact registry This can be thought of in three parts First some permissions on the service agent running the build do git pullresource google sourcerepo repository iam binding builder project var project repository var build config repo name role roles source reader members serviceAccount var builder email read and write docker images to registryresource google artifact registry repository iam member writer provider google beta project var project location var location repository var docker config repo id role roles artifactregistry writer member serviceAccount var builder email Second a storage bucket to hold the build logs resource google storage bucket build logs name var project var bucket name location US force destroy true resource google storage bucket iam binding admin bucket google storage bucket build logs name role roles storage admin members serviceAccount var builder email And finally the trigger itself data google sourcerepo repository infrastructure name var build config repo name resource google cloudbuild trigger infra trigger name var build config trigger name description var build config trigger description service account projects var project serviceAccounts var builder email filename cloudbuild yaml trigger template branch name main repo name data google sourcerepo repository infrastructure name substitutions merge LOG BUCKET URL google storage bucket build logs url DEV IMAGE NAME var location docker pkg dev var project var docker config repo name var docker config image name var build variables Here I m setting the log bucket URL and image name as substitutions that the repo itself can reference in its cloudbuild yaml file This way the Cloud Run service can reference the same image name Putting this all together we can set up a new build with locals location us central repo name game scorer project api image scoring api resource google artifact registry repository primary provider google beta project var project location local location repository id local repo name format DOCKER module api builder source modules serviceAgent id scoring api builder display name Scoring API Builder setup sa email var builder module api build source modules build project var project location local location builder email module api builder email bucket name api build logs docker config repo id google artifact registry repository primary id repo name local repo name image name local api image build config repo name bitbucket brmatola scoring api trigger name scoring api trigger trigger description Scoring API Build Where var project and var builder reference the GCP project and service account running the infrastructure build respectively This configures a cloud build trigger on our API repo bitbucket brmatola scoring api The repo itself then must have a cloudbuild yaml file that publishes a docker image steps id Build Docker Image With SHA Hash name gcr io cloud builders docker entrypoint bash args c docker build f GameScoring Dockerfile t DEV IMAGE NAME COMMIT SHA id Tag Docker Image with dev tag name gcr io cloud builders docker args tag DEV IMAGE NAME COMMIT SHA DEV IMAGE NAME dev id Update dev tag with image to run name gcr io cloud builders docker args push DEV IMAGE NAME dev images DEV IMAGE NAME COMMIT SHA logsBucket LOG BUCKET URL options logging GCS ONLY Running the Service on Cloud RunOnce we have our build continuously deploying docker images we want to actually run the image in Cloud Run This process is documented here but boils down to running a cloud command after publishing the image To do so however we ll need a Cloud Run instance to deploy to We ll set up a service account to run the Cloud Run instance as well as some IAM permissions to let the build service account run the service module api runner source modules serviceAgent id scoring api runner display name Scoring API Runner setup sa email var builder impersonators serviceAccount module api builder email resource google cloud run service iam binding runner location local location service google cloud run service api name role roles run developer members serviceAccount module api builder email The key here is that both the service build and infrastructure build service accounts need the iam serviceAccountUser role on the Cloud Run service Additionally the service build account needs the run developer role in order to deploy the service Then if we want our service to be available to users we ll need to give the run invoker role to everyone resource google cloud run service iam binding builder location local location service google cloud run service api name role roles run invoker members allUsers Then we need to build the actual service resource google cloud run service api name scoring api service location local location template spec service account name module api runner email containers image local location docker pkg dev var project google artifact registry repository primary repository id local api image dev traffic percent latest revision true lifecycle ignore changes metadata annotations Finally in our service build we modify our Cloudbuild yaml file to actually deploy the service steps id Build Docker Image With SHA Hash name gcr io cloud builders docker entrypoint bash args c docker build f GameScoring Dockerfile t DEV IMAGE NAME COMMIT SHA id Tag Docker Image with dev tag name gcr io cloud builders docker args tag DEV IMAGE NAME COMMIT SHA DEV IMAGE NAME dev id Update dev tag with image to run name gcr io cloud builders docker args push DEV IMAGE NAME dev id Deploy dev tag to Cloud Run name gcr io cloud builders gcloud args run deploy CLOUD RUN NAME image DEV IMAGE NAME dev region us central images DEV IMAGE NAME COMMIT SHA logsBucket LOG BUCKET URL options logging GCS ONLYWhere we ve configured the cloud run name as a substitution in the infrastructure so the build can just reference it 2022-04-12 21:14:18
海外TECH DEV Community Tip to shrink you code using "Omit" to create interfaces! https://dev.to/gustavohst/type-tip-to-shrink-you-code-6c3 Tip to shrink you code using quot Omit quot to create interfaces Hey guys I want to share one tip to you Imagine that you have one interface called by Deposit to create using Id Name Value CreatedAt properties Usually we will create somethink like this interface Deposit id number name string value number createdAt string And if you need create another interface from Deposit For example create a new one without the Id called by DepositInput We can use the Omit sintaxe D type DepositInput Omit lt Deposit id gt instead interface DepositInput name string value number createdAt string You have oportunity to make short your codes Enjoy 2022-04-12 21:13:34
海外TECH DEV Community Colorized Photos with SVG Filter 1 https://dev.to/photostockedit1/colorized-photos-with-svg-filter-1-2n03 Colorized Photos with SVG Filter The feColorMatrix SVG filter element changes colors based on a transformation matrix First we take the color we want in rgb format and next we divide each value for feColorMatrix r red g green b blue multiplyer For Example for RED COLOR rgb r g b opacity And replace each value in Matrix This Matrix is used as value of feColorMatrix lt svg xmlns xlink class jsx background fade in style width height gt lt filter id red gt lt feColorMatrix type matrix values color interpolation filters sRGB gt lt feColorMatrix gt lt filter gt lt image width height filter url red xlink href gt lt image gt lt svg gt For Example for BLUE COLOR rgb r g b opacity And replace each value in Matrix This Matrix is used as value of feColorMatrix lt svg xmlns xlink class jsx background fade in style width height gt lt filter id blue gt lt feColorMatrix type matrix values color interpolation filters sRGB gt lt feColorMatrix gt lt filter gt lt image width height filter url blue xlink href gt lt image gt lt svg gt For this examples we use b amp w images for better visual result from blackwhite pictures Next time we will show you how to combine these colors to get duotone images 2022-04-12 21:13:04
海外TECH DEV Community Serving static files with Node.JS https://dev.to/apla/serving-static-files-with-nodejs-3jg4 Serving static files with Node JS Serving static files with Node JSNode js have an internal http https module to create a web server But almost nobody uses http Server as is the majority of users are using Express js either directly or indirectly as a part of a framework like Next js Express js with its long lived version is famous for its somewhat low performance Other projects like fastify or polka have benchmarks outperforming Express js I don t know why Express is slower maybe because of regex processing of routes If you re using parametric routes like users userid entity and have no regexp routes then replacing Express js with fastify or polka will add a performance boost to your app They are not direct replacements but you can convert code if you really need that boost In the article below benchmarks shows huge improvement but in reality your code will be a limiting factor to your app performance and you are unlikely notice any improvement While writing this article I tested many configurations node http node http nginx node http with unix socket nginx nginx keepalive for previous configuration Even with very short response protocol overhead not so big to give any performance benefits Along with dynamic content node js web servers can obviously serve static files Performance wise it is not the best way to serve static files Using a separate proxy server like nginx is much better for that purpose Linux systems have several technologies to optimize such tasks sendfile allows you to stream file contents to the socket using operating system routines and buffers mmap can be used to map file contents to the memory and speed up reading purposes In addition to the system calls above Nginx can use its own caching mechanisms As your project grows you may use AWS Azure Google Cloudflare whatever CDNs to distribute static files for users in different regions This way you re trading the cost of running your compute nodes for cheaper CDN bandwidth Serving static contentLet s get back to the coding While you re writing code for your server it s probably easier to include static file serving into web server code And probably this should not affect your server performance Let s try All code snippets and test scripts are available on my GitHub repo Servers with only dynamic routes higher bars and with added file serving routine lower Code for static file serving adopted from those pages Why web server performance suffers from file serving middleware Chaining middleware is a way to write asynchronous code the same way as old synchronous code was written decades ago Chained middlewares dissect request bit by bit and made those bits available before starting the main URL handler in the app But everything comes with a cost Mapping URLs to the file system checking session from cookie against a database parsing request body and storing uploaded files in the filesystem consume resources As an application developer you can choose proper way when you use middleware as a request processing atoms depending on URL Or Lazy way where most middlewares are just generic request parser validator something elseand used like app use middleware Such a lazy approach leads to running every application middleware before processing every request As you can see on the chart I ve added file serving middleware and they run before request To send file contents to the user the serving routine should make sure the file exists So for every request web server checks if there is file exists Filesystem callbackBut what do I really want when I add file serving middleware into my app I want my dynamic routes processed as usual but if none matches the server should check for the path in the filesystem Only as a fallback Express js doesn t have such a handler but it processes use middlewares as registered by use method polka calls all use middlewares at request start but have onNoMatch handler fastify server page mentions setNotFoundHandler with preValidation hook on lifecycle page But I could not find a way to use fastify static with preValidation hook Results File handlers push at the end of middleware list express or to special if none matches handler polka No solution for fastify As you can see proper middleware usage can benefit your app with faster response times and lower system load Maybe it s time to check other used middlewares and move form validation body parsing and other specific middlewares to the URLs where is needed Existing static middlewareWhile browsing source files I discovered some overengineered static handlers At least two of them use send packageserve static is default for Express and fastify static is default for fastify those packages are much slower than a real proxy They must be used only for testing and light load scenarios but with a light load you re not needed ETag Cache Control and Max Age headers and other engineering efforts to optimize file serving sirv package does even more It caches file stat in memory without revalidating when the file changes I described why those efforts it is not needed at the beginning of this article You can trust me or you check it out for yourself Express polka and Nginx comparison on K file RPS values differ from previous charts because benchmarks performed on slower Linux VPS I did it on purpose to limit all servers to using only one available CPU core Before writing this article I ve seen many questions it is good or not to use Node JS as http file server And I have no definitive answer on how much difference I will have I always used Nginx before node js to serve static in world facing services More bad examplesTake a look at Nest js web server When the file serving option is turned on it not only slows down your app because filesystem checks for every request but also using synchronous fs stat to check if the file exists ConclusionYou definitely should not have to use node js for static files in production And it is better to use that functionality only in development because on every unknown dynamic route your web server will check the filesystem But the main point of this article is that wrongly placed middleware can hurt the performance of your app P S Best performance at any costIf you want the best performance at any cost take a look at uWebSockers js This is very fast web server developed by Alex Hultman On my benchmark uWebSockets js can handle requests per second with single process while cluster of two polka nodes just Additional performance can be squeezed from node http but load balancing is a known linux problem File serving doesn t need any workarounds because of good routes handling Pattern matchingRoutes are matched in order of specificity not by the order you register them Highest priority static routes think hello this is static Middle priority parameter routes think candy kind where gt value of kind is retrieved by req getParameter Lowest priority wildcard routes think hello In other words the more specific a route is the earlier it will match This allows you to define wildcard routes that match a wide gt range of URLs and then carve out more specific behavior from that But static serving performance is not so good K file polka cluster RPSuwf fixed RPSI have not added this server to compare because the author has his reasons and way of doing things For example npm drama npm wouldn t allow developer to delete previous versions of his package that had bugs and security issues so he got angry and released an empty package with a patch version npm tagged latest latest non empty package because people complain after suddenly webserver stopper to work After that developer deprecated the package removed reddit post rockstudillo beware of uwebsockets js bccacfnodejs drama developer doesn t want to comply with existing nodejs interfaces with it s own nodejs package «What Node js does with their streams has no significance to this project If you see similarities good but that doesn t mean anything more than that there are similarities The entire premise the hypothesis of this project since day has always been and will continue to be Node js is doing things unreasonably inefficient In other words the difference between this project and Node js is no act of random »another npm drama Freedom truckers convoy icon on Github profile Does he support only AntiCovid hysteria or horn punishment for Ottawa citizens too To me this developer is in the good company of authors of leftpad event stream node ipc I don t trust uWebSockets js author and I will never use it in my projects 2022-04-12 21:11:32
ニュース @日本経済新聞 電子版 日銀の国債保有残高は526兆円と年初比6兆円増加。金利上昇を抑えるため連続指し値オペなどを実施しました。各国の主要中銀が金融正常化に動く中で日銀の緩和姿勢は際立ち、円安進行の懸念もあります。 https://t.co/cqB3ZMCfSB https://twitter.com/nikkei/statuses/1513992933564993544 日銀の国債保有残高は兆円と年初比兆円増加。 2022-04-12 21:30:18
ニュース BBC News - Home Boris Johnson and Rishi Sunak reject calls to resign over lockdown fines https://www.bbc.co.uk/news/uk-politics-61083402?at_medium=RSS&at_campaign=KARANGA apologise 2022-04-12 21:19:24
ニュース BBC News - Home Real Madrid 2-3 Chelsea (Agg: 5-4 aet): Blues suffer agonising Champions League exit https://www.bbc.co.uk/sport/football/61067661?at_medium=RSS&at_campaign=KARANGA Real Madrid Chelsea Agg aet Blues suffer agonising Champions League exitChelsea s reign as European champions comes to an agonising end despite beating Real Madrid on a night of high drama at the Bernabeu Stadium 2022-04-12 21:46:02
ニュース BBC News - Home Bayern Munich 1-1 Villarreal (1-2 agg): Spanish side stun Bayern with late Chukwueze winner https://www.bbc.co.uk/sport/football/61086842?at_medium=RSS&at_campaign=KARANGA Bayern Munich Villarreal agg Spanish side stun Bayern with late Chukwueze winnerVillarreal stun Bayern Munich to reach the Champions League semi finals for the first time in years with a aggregate win 2022-04-12 21:37:03
ニュース BBC News - Home Ukraine round-up: Putin defends 'necessary' invasion and Kyiv averts cyber-attack https://www.bbc.co.uk/news/world-europe-61088637?at_medium=RSS&at_campaign=KARANGA Ukraine round up Putin defends x necessary x invasion and Kyiv averts cyber attackTroops head to the Donbas in preparation for fresh battle and Ukraine averts a cyber attack on its energy grid 2022-04-12 21:09:40
ビジネス ダイヤモンド・オンライン - 新着記事 米空母打撃群が日本海に 北朝鮮けん制の動き - WSJ発 https://diamond.jp/articles/-/301558 空母打撃群 2022-04-13 06:15:00
北海道 北海道新聞 「米の過剰要求に今後も抵抗」 イラン最高指導者、核協議で https://www.hokkaido-np.co.jp/article/668836/ 最高指導者 2022-04-13 06:32:00
北海道 北海道新聞 米上半期の財政赤字60%減 コロナ禍から再開で税収増 https://www.hokkaido-np.co.jp/article/668832/ 会計年度 2022-04-13 06:17:03
北海道 北海道新聞 米南部州で中絶「重罪」に 禁止法成立、禁錮10年も https://www.hokkaido-np.co.jp/article/668835/ 重罪 2022-04-13 06:21:00
北海道 北海道新聞 ノキア、ロシア事業撤退へ フィンランドの通信機器大手 https://www.hokkaido-np.co.jp/article/668834/ 事業撤退 2022-04-13 06:21:00
北海道 北海道新聞 アプリストア規制法阻止を アップルCEOが批判 https://www.hokkaido-np.co.jp/article/668833/ 最高経営責任者 2022-04-13 06:11:00
北海道 北海道新聞 NY株続落、87ドル安 米利上げ加速を懸念 https://www.hokkaido-np.co.jp/article/668831/ 続落 2022-04-13 06:01:00
ビジネス 東洋経済オンライン 成城石井の上場計画がこれほどまで話題になる訳 単に「高級スーパー」と思っていたら本質を見誤る | 百貨店・量販店・総合スーパー | 東洋経済オンライン https://toyokeizai.net/articles/-/581544?utm_source=rss&utm_medium=http&utm_campaign=link_back 成城石井 2022-04-13 06:05:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)