尊龙凯时人生就是搏

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ЧÀÍÆ÷Çå¾²£ºÔõÑù±£»¤ÈÝÆ÷ÇéÐÎÖеÄÃô¸ÐÐÅÏ¢£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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