Dev/Backend

[Backend] yaml ํŒŒ์ผ ์ž‘์„ฑ๋ฒ•

sebinChu 2024. 1. 11. 09:26

๐Ÿ˜ฎ‍๐Ÿ’จ

์ƒˆ๋กœ CI๊ฐ€ ํ•„์š”ํ•œ ํ”„๋กœ์ ํŠธ๊ฐ€ ์žˆ์–ด์„œ Cloud Build๋ฅผ ๊ตฌ์ถ•ํ•˜๋Š” ๋„์ถฉ ๊ณ„์† ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋–ด๋‹ค.

 

"failed unmarshalling build config cloudbuild.yaml: yaml: line 3: did not find expected key"

 

yaml ํŒŒ์ผ ๋ฌธ๋ฒ• ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒƒ

yaml์€ ํŒŒ์ด์ฌ์—์„œ tab์œผ๋กœ ๊ตฌ๋ถ„ํ•˜๋“ฏ์ด ๋„์–ด์“ฐ๊ธฐ๊ฐ€ ์ค‘์š”ํ•˜๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ์ด๋Ÿฌํ•œ ๋„์–ด์“ฐ๊ธฐ ์ ์šฉ์ด ํˆด๋งˆ๋‹ค ๋‹ฌ๋ผ์„œ,,,,

 

์•„๋‹ˆ ๋ถ„๋ช… intelliJ๋กœ ๋นŒ๋“œํ•  ๋• ๋๋Š”๋ฐ

์™ธ์•Š๋˜์ง€?๋งŒ ์™ธ์น˜๊ณ  ์žˆ๋‹ค๊ฐ€

๊ตฌ๊ธ€๋ง์„ ํ†ตํ•ด ๊ฟ€์ •๋ณด ์ฐพ์Œ

 

 

๊ฟ€์ •๋ณด๋Š” ์•„๋ž˜ ์‚ฌ์ดํŠธ์ธ๋ฐ,

yaml -> json ๋ณ€ํ™˜ ์‚ฌ์ดํŠธ๋กœ yaml ๋ฌธ๋ฒ•์ด ์ž˜๋ชป๋˜๋ฉด ์žก์•„์ค€๋‹ค.

 

https://www.json2yaml.com/convert-yaml-to-json

 

https://www.json2yaml.com/convert-yaml-to-json

YAML x

www.json2yaml.com

 

 

yaml์„ ์“ธ ๋•Œ ์ฃผ์˜ํ•  ์ ์€ tab์€ ์‚ฌ์šฉํ•˜๋ฉด ์•ˆ๋˜๊ณ  ๋„์–ด์“ฐ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.

 

 


Cloud Build์™€ yaml 

 

cloud build ์„ค์ •์„ ์œ„ํ•ด yaml์„ ์“ธ ๋•Œ 'gcr.io/cloud-builder/...' ์ด๋Ÿฐ์‹์œผ๋กœ ์ž‘์„ฑํ•˜๊ฒŒ ๋œ๋‹ค. 

*๊ณต์‹์ ์œผ๋กœ ์•Œ๋ ค์ง„ ๋นŒ๋” ์ด๋ฏธ์ง€๋Š” ์—ฌ๊ธฐ์„œ ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค.

 

 

 

GitHub - GoogleCloudPlatform/cloud-builders: Builder images and examples commonly used for Google Cloud Build

Builder images and examples commonly used for Google Cloud Build - GitHub - GoogleCloudPlatform/cloud-builders: Builder images and examples commonly used for Google Cloud Build

github.com

 

 

์—ฌ๊ธฐ์„œ ์ฃผ์˜ํ•  ์ 

๋…ธ๋“œ ํ”„๋กœ์ ํŠธ๊ฐ™์€ ๊ฒฝ์šฐ๋Š” 

 

(1)

- name: 'gcr.io/cloud-builders/npm'
+ name: 'node'
+ entrypoint: 'npm'

 

(2) 

steps:
- name: 'node'
  entrypoint: 'npm'
  args: ['install']

 

 

2๋ฒˆ ๋ฐฉ์‹์œผ๋กœ ์ž‘์„ฑํ•ด์•ผํ•œ๋‹ค. npm์˜ ์ตœ์‹  ๊ธฐ๋Šฅ/๋ฒ„์ „์€ ์ง€์›ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ.

์—ฌ๊ธฐ ๊ฐ€๋ฉด ์ž์„ธํ•œ ์ •๋ณด๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

GCP๋Š” ์›ฌ๋งŒํ•˜๋ฉด ๊ณต์‹๋ฌธ์„œ๊ฐ€ ์ž˜ ๋ผ์žˆ๊ธดํ•œ๋ฐ ๋„ˆ๋ฌด ์˜ค๋ž˜๋œ ๋ฌธ์„œ๋„ ๋งŽ๊ณ 

์• ์ดˆ์— ์„ธํŒ… ์ž์ฒด๊ฐ€ ๋ณต์žก + ๋ ˆํผ๋Ÿฐ์Šค๊ฐ€ ๋น„๊ต์  ์ ์Œ..

 

ใ…‹ใ…‹์“ฐ๊ณ ๋ณด๋‹ˆ๊นŒ ๋ญ ๋„๊ตฌํƒ“๋งŒ์€ ์•„๋‹ˆ๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ๋„ ๋“ ๋‹ค.

์•”ํŠผ yaml ๋„์–ด์“ฐ๊ธฐ์— ํ•œ๋ฒˆ ๋‹นํ–ˆ์œผ๋‹ˆ ์•ž์œผ๋กœ๋Š” ์‹ค์ˆ˜ํ•˜์ง€ ๋ง์ž