尊龙凯时人生就是搏

Docker×°ÖÃSymfony£ºÒ»Õ¾Ê½¿ª·¢ÇéÐÎÉèÖÃ

Docker×°ÖÃSymfony£ºÒ»Õ¾Ê½¿ª·¢ÇéÐÎÉèÖÃ

СÐò£º

ÔÚ¿ª·¢WebÓ¦ÓóÌÐòʱ £¬×¼È·µÄÇéÐÎÉèÖÃÊÇÖÁ¹ØÖ÷ÒªµÄ¡£SymfonyÊÇÒ»¸öÊ¢ÐеÄPHP¿ò¼Ü £¬¿ÉÒÔ×ÊÖú¿ª·¢Õß¹¹½¨¸ßЧ¡¢ÎÞаºÍ¿ÉÀ©Õ¹µÄÓ¦ÓóÌÐò¡£È»¶ø £¬SymfonyµÄ×°ÖúÍÉèÖÿÉÄÜ»á½ÏÁ¿ÖØ´ó¡£Ê¹ÓÃDocker¿ÉÒÔ¼ò»¯ÕâÒ»Àú³Ì £¬²¢ÌṩһվʽµÄ¿ª·¢ÇéÐÎÉèÖᣱ¾ÎĽ«ÏòÄúÏÈÈÝÔõÑùʹÓÃDocker×°ÖúÍÉèÖÃSymfony £¬Í¬Ê±ÌṩÏêϸµÄ´úÂëʾÀý¡£

µÚÒ»²¿·Ö£ºDocker»ù´¡ÖªÊ¶

ÔÚ×îÏÈ֮ǰ £¬ÎÒÃÇÐèÒªÏàʶһЩDockerµÄ»ù´¡ÖªÊ¶¡£DockerÊÇÒ»¸ö¿ªÔ´µÄÈÝÆ÷»¯Æ½Ì¨ £¬¿ÉÒÔ×ÊÖú¿ª·¢Õß½¨Éè¡¢°²ÅźÍÔËÐÐÓ¦ÓóÌÐò¡£ÈÝÆ÷ÊÇÒ»ÖÖÇáÁ¿¼¶µÄÐéÄ⻯ÊÖÒÕ £¬Ëü½«Ó¦ÓóÌÐò¼°ÆäÒÀÀµÏî´ò°üµ½Ò»¸ö¿ÉÒÆÖ²µÄÈÝÆ÷ÖÐ £¬ÒÔÈ·±£Ó¦ÓóÌÐòÔÚ²î±ðµÄÇéÐÎÖÐÄܹ»Ò»ÖÂÔËÐС£

ÔÚDockerÖÐʹÓõĽ¹µã¿´·¨°üÀ¨¾µÏñ£¨Image£©¡¢ÈÝÆ÷£¨Container£©ºÍ¿ÍÕ»£¨Repository£©¡£¾µÏñÊÇÒ»¸öÖ»¶ÁµÄÎļþ £¬ÆäÖаüÀ¨ÁËÓ¦ÓóÌÐòµÄËùÓÐÒÀÀµÏîºÍÉèÖÃÐÅÏ¢¡£ÈÝÆ÷ÔòÊÇ»ùÓÚ¾µÏñ½¨ÉèµÄ¿ÉÖ´ÐÐʵÀý £¬¿ÉÒÔÔÚÆäÖÐÔËÐÐÓ¦ÓóÌÐò¡£¿ÍÕ»ÔòÊÇÓÃÓÚ´æ´¢ºÍ·ÖÏí¾µÏñµÄµØ·½¡£

µÚ¶þ²¿·Ö£º×°ÖÃDocker

ÔÚ×îÏÈ×°ÖÃSymfony֮ǰ £¬ÎÒÃÇÊ×ÏÈÐèҪװÖÃDocker¡£DockerÌṩÁËÊÊÓÃÓÚ²î±ð²Ù×÷ϵͳµÄ×°ÖóÌÐò £¬Äú¿ÉÒÔƾ֤×Ô¼ºµÄ²Ù×÷ϵͳѡÔñºÏÊʵÄ×°ÖóÌÐò¾ÙÐÐ×°Öá£

×°ÖÃÍê³Éºó £¬Äú¿ÉÒÔͨ¹ýÔËÐÐÒÔÏÂÏÂÁîÀ´ÑéÖ¤DockerÊÇ·ñ׼ȷװÖãº

docker --version

µÇ¼ºó¸´ÖÆ

ÈôÊÇÄܹ»×¼È·ÏÔʾDockerµÄ°æ±¾ÐÅÏ¢ £¬ÔòÌåÏÖDockerÒÑÀÖ³É×°Öá£

µÚÈý²¿·Ö£º½¨ÉèSymfonyÏîÄ¿

ʹÓÃDocker×°ÖúÍÉèÖÃSymfonyµÄµÚÒ»²½Êǽ¨ÉèÒ»¸öSymfonyÏîÄ¿¡£Äú¿ÉÒÔʹÓÃSymfonyµÄÏÂÁîÐй¤¾ßÀ´½¨ÉèÏîÄ¿¡£Ê×ÏÈ £¬·­¿ªÖն˻òÏÂÁîÐд°¿Ú £¬²¢µ¼º½µ½ÄúÏ£Íû½¨ÉèÏîÄ¿µÄĿ¼¡£È»ºóÔËÐÐÒÔÏÂÏÂÁ

docker run --rm -v $(pwd):/app composer create-project symfony/website-skeleton myproject

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁÔÚÄ¿½ñĿ¼Ï½¨ÉèÒ»¸öÃûΪ”myproject”µÄSymfonyÏîÄ¿¡£

µÚËIJ¿·Ö£ºÉèÖÃDocker¾µÏñ

ÔÚ¼ÌÐø֮ǰ £¬ÎÒÃÇÐèҪΪSymfonyÏîÄ¿ÉèÖÃÒ»¸öDocker¾µÏñ¡£Ê×ÏÈ £¬ÄúÐèÒª½¨ÉèÒ»¸öÃûΪ”Dockerfile”µÄÎļþ £¬²¢½«ÒÔÏÂÄÚÈݸ´ÖƵ½ÎļþÖУº

FROM php:7.4-cli

RUN apt-get update && apt-get install -y 
    git 
    unzip 
    libpq-dev

RUN docker-php-ext-install pdo_pgsql

WORKDIR /app

CMD php -S 0.0.0.0:8000 -t public

µÇ¼ºó¸´ÖÆ

ÉÏÊöDockerfileÖÐÖ¸¶¨ÁËʹÓÃPHP 7.4µÄCLI°æ±¾×÷Ϊ»ù´¡¾µÏñ¡£È»ºó £¬ÎÒÃÇͨ¹ýapt-getÏÂÁî×°ÖÃÁËһЩÐëÒªµÄÒÀÀµÏî £¬°üÀ¨git¡¢unzipºÍlibpq-dev¡£½ÓÏÂÀ´ £¬Í¨¹ýdocker-php-ext-installÏÂÁî×°ÖÃÁËpdo_pgsqlÀ©Õ¹¡£

×îºó £¬ÎÒÃÇͨ¹ýWORKDIRÖ¸ÁĿ½ñÊÂÇéĿ¼ÉèÖÃΪ”/app” £¬²¢Ê¹ÓÃCMDÖ¸ÁîÔËÐÐSymfonyµÄ¿ª·¢Ð§ÀÍÆ÷¡£

µÚÎ岿·Ö£º¹¹½¨Docker¾µÏñ

Íê³ÉDockerfileµÄÉèÖúó £¬ÎÒÃÇÐèҪʹÓøÃÎļþÀ´¹¹½¨Docker¾µÏñ¡£ÔÚÖն˻òÏÂÁîÐд°¿ÚÖÐ £¬µ¼º½µ½SymfonyÏîÄ¿µÄ¸ùĿ¼ £¬²¢ÔËÐÐÒÔÏÂÏÂÁ

docker build -t myproject .

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁʹÓÃÄ¿½ñĿ¼ÏµÄDockerfile½¨ÉèÃûΪ”myproject”µÄDocker¾µÏñ¡£

µÚÁù²¿·Ö£ºÔËÐÐSymfonyÓ¦ÓóÌÐò

Æô¶¯Docker¾µÏñºó £¬ÎÒÃÇ¿ÉÒÔÔËÐÐSymfonyÓ¦ÓóÌÐò¡£ÔÚÖն˻òÏÂÁîÐд°¿ÚÖÐÔËÐÐÒÔÏÂÏÂÁ

docker run -p 8000:8000 -v $(pwd):/app myproject

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁÔÚÍâµØµÄ8000¶Ë¿ÚÉÏÔËÐÐSymfonyÓ¦ÓóÌÐò £¬²¢½«Ä¿½ñĿ¼¹ÒÔص½ÈÝÆ÷ÖеĔ/app”Ŀ¼¡£

ÏÖÔÚ £¬Äú¿ÉÒÔͨ¹ý»á¼ûhttp://localhost:8000À´»á¼ûSymfonyÓ¦ÓóÌÐòÁË¡£

½áÂÛ£º

ʹÓÃDocker×°ÖúÍÉèÖÃSymfony¿ÉÒÔ¼ò»¯¿ª·¢ÇéÐεÄÉèÖÃÀú³Ì¡£Í¨¹ýÈÝÆ÷»¯ÊÖÒÕ £¬ÎÒÃÇ¿ÉÒÔÇáËɽ¨Éè¡¢°²ÅźÍÔËÐÐSymfonyÓ¦ÓóÌÐò £¬Í¬Ê±¼á³ÖÇéÐεÄÒ»ÖÂÐÔ¡£Í¨¹ý±¾ÎÄÌṩµÄÏêϸ´úÂëʾÀý £¬Äú¿ÉÒÔ¿ìËÙÉÏÊÖ²¢×îÏÈʹÓÃSymfony¾ÙÐпª·¢¡£×£ÄúÔÚSymfonyµÄ¿ª·¢ÂóÌÖÐÈ¡µÃÀֳɣ¡

ÒÔÉϾÍÊÇDocker×°ÖÃSymfony£ºÒ»Õ¾Ê½¿ª·¢ÇéÐÎÉèÖõÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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