尊龙凯时人生就是博

LinuxЧÀÍÆ÷Çå¾²£ºÔõÑù±£»¤ÈÝÆ÷ÇéÐÎÖеÄÃô¸ÐÐÅÏ¢£¿

linuxЧÀÍÆ÷Çå¾²£ºÔõÑù±£»¤ÈÝÆ÷ÇéÐÎÖеÄÃô¸ÐÐÅÏ¢£¿

ÔÚµ±½ñ»¥ÁªÍøʱ´ú £¬Ð§ÀÍÆ÷Çå¾²ÎÊÌâ±äµÃÔ½À´Ô½Ö÷Òª¡£ÓÈÆäÊǹØÓÚʹÓÃÈÝÆ÷»¯ÊÖÒÕµÄЧÀÍÆ÷ÇéÐÎ £¬±£»¤Ãô¸ÐÐÅÏ¢±äµÃ¸ü¾ßÌôÕ½ÐÔ¡£±¾ÎĽ«ÏÈÈÝһЩÔÚLinuxЧÀÍÆ÷Éϱ£»¤ÈÝÆ÷ÇéÐÎÖеÄÃô¸ÐÐÅÏ¢µÄ×î¼Ñʵ¼ù £¬²¢ÌṩһЩ´úÂëʾÀý £¬ÒÔ×ÊÖú¶ÁÕ߸üºÃµØÃ÷È·¡£

ʹÓÃÃÜÔ¿ÖÎÀíÆ÷

ÔÚÈÝÆ÷ÇéÐÎÖÐ £¬ÎªÁ˱£»¤Ãô¸ÐÐÅÏ¢ £¬ÈçAPIÃÜÔ¿¡¢Êý¾Ý¿âÃÜÂëµÈ £¬¿ÉÒÔʹÓÃÃÜÔ¿ÖÎÀíÆ÷¡£ÃÜÔ¿ÖÎÀíÆ÷¿ÉÒÔ×ÊÖúÎÒÃÇÒÔÇå¾²µÄ·½·¨´æ´¢ºÍ»á¼ûÕâЩÃô¸ÐÐÅÏ¢¡£ÒÔÏÂÊÇÒ»¸öʹÓÃHashiCorpµÄVault×÷ΪÃÜÔ¿ÖÎÀíÆ÷µÄʾÀý´úÂ룺

# ×°ÖÃVault
wget https://releases.hashicorp.com/vault/1.6.3/vault_1.6.3_linux_amd64.zip
unzip vault_1.6.3_linux_amd64.zip
sudo mv vault /usr/local/bin/

# Æô¶¯VaultЧÀÍÆ÷
vault server -dev

# ½¨ÉèÒ»¸öVault secret
vault kv put secret/myapp/api-key value=abc123

# ÔÚÈÝÆ÷ÖÐʹÓÃVault»ñÈ¡ÃÜÔ¿
vault kv get secret/myapp/api-key

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöʾÀýÖÐ £¬ÎÒÃÇʹÓÃVaultÔÚЧÀÍÆ÷ÉϽ¨ÉèÒ»¸öÃûΪmyappµÄÉñÃØ¿Õ¼ä £¬²¢ÔÚÆäÖд洢ÁËÒ»¸öÃûΪapi-keyµÄÃô¸ÐÐÅÏ¢¡£ÎªÁËÔÚÈÝÆ÷ÖÐʹÓÃÕâ¸öÉñÃØÐÅÏ¢ £¬ÎÒÃÇÐèҪװÖÃVault £¬²¢Ê¹ÓÃAPIÇëÇóÀ´»ñÈ¡Ëü¡£

ʹÓÃÇéÐαäÁ¿

ÔÚÈÝÆ÷ÇéÐÎÖÐ £¬¿ÉÒÔʹÓÃÇéÐαäÁ¿À´´æ´¢Ãô¸ÐÐÅÏ¢ £¬²¢ÔÚÈÝÆ÷Æô¶¯Ê±½«Æä×¢Èëµ½ÈÝÆ÷ÖС£ÒÔÏÂÊÇÒ»¸öʹÓÃDockerµÄʾÀý´úÂ룺

# ½¨ÉèÒ»¸ö°üÀ¨Ãô¸ÐÐÅÏ¢µÄ.envÎļþ
echo "API_KEY=abc123" > /path/to/myapp/.env

# ÔÚDockerfileÖн«.envÎļþ¸´ÖƵ½ÈÝÆ÷ÖÐ
COPY .env /app

# ÔÚDockerfileÖнç˵һ¸öÇéÐαäÁ¿
ENV API_KEY $API_KEY

# ÔÚÈÝÆ÷ÖÐʹÓÃÇéÐαäÁ¿
echo $API_KEY

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöʾÀýÖÐ £¬ÎÒÃǽ«Ãô¸ÐÐÅÏ¢´æ´¢ÔÚÒ»¸öÃûΪ.envµÄÎļþÖÐ £¬²¢ÔÚDockerfileÖн«Æ临ÖƵ½ÈÝÆ÷ÖС£È»ºó £¬ÎÒÃÇʹÓÃENVÖ¸ÁîÔÚÈÝÆ÷Öнç˵һ¸öÃûΪAPI_KEYµÄÇéÐαäÁ¿ £¬²¢ÔÚÈÝÆ÷ÖÐʹÓøÃÇéÐαäÁ¿¡£

ÏÞÖÆÈÝÆ÷ȨÏÞ

ΪÁ˱£»¤ÈÝÆ÷ÇéÐÎÖеÄÃô¸ÐÐÅÏ¢ £¬ÎÒÃÇ»¹¿ÉÒÔÏÞÖÆÈÝÆ÷µÄȨÏÞ¡£ÒÔÏÂÊÇÒ»¸öʹÓÃDockerµÄʾÀý´úÂ룺

# ÔÚDockerfileÖÐÒÔ·ÇrootÓû§ÔËÐÐÈÝÆ÷
USER myuser

# ÔÚDockerfileÖÐÉèÖÃÈÝÆ÷µÄÖ´ÐÐȨÏÞ
RUN chmod 500 /app/run.sh

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöʾÀýÖÐ £¬ÎÒÃÇʹÓÃUSERÖ¸ÁîÔÚDockerfileÖÐÉèÖÃÈÝÆ÷ÒÔ·ÇrootÓû§ÔËÐС£Õâ¿ÉÒÔ×ÊÖúïÔ̭DZÔÚµÄÇ徲Σº¦¡£ÁíÍâ £¬ÎÒÃÇʹÓÃRUNÖ¸ÁîÉèÖÃÈÝÆ÷ÖÐij¸ö¾ç±¾ÎļþµÄÖ´ÐÐȨÏÞ £¬ÒÔÈ·±£Ö»ÓÐÌض¨µÄÓû§¿ÉÒÔÖ´ÐиÃÎļþ¡£

×ÛÉÏËùÊö £¬Ð§ÀÍÆ÷Çå¾²¹ØÓÚÈÝÆ÷ÇéÐÎÖеÄÃô¸ÐÐÅÏ¢ÖÁ¹ØÖ÷Òª¡£Í¨¹ýʹÓÃÃÜÔ¿ÖÎÀíÆ÷¡¢ÇéÐαäÁ¿ºÍÏÞÖÆÈÝÆ÷ȨÏÞµÈ×î¼Ñʵ¼ù £¬ÎÒÃÇ¿ÉÒÔ¸üºÃµØ±£»¤ÈÝÆ÷ÇéÐÎÖеÄÃô¸ÐÐÅÏ¢¡£Ï£Íû±¾ÎÄÌṩµÄ´úÂëʾÀýÄÜ×ÊÖú¶ÁÕ߸üºÃµØÃ÷È·ºÍÓ¦ÓÃÕâЩÇå¾²²½·¥ £¬´Ó¶øÈ·±£Ð§ÀÍÆ÷µÄÇå¾²ÐÔ¡£

ÒÔÉϾÍÊÇLinuxЧÀÍÆ÷Çå¾²£ºÔõÑù±£»¤ÈÝÆ÷ÇéÐÎÖеÄÃô¸ÐÐÅÏ¢£¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ