尊龙凯时人生就是搏

Docker¿ìËÙ×°ÖÃSymfony£ºÏêϸָÄÏÓë½Ì³Ì

Docker¿ìËÙ×°ÖÃSymfony£ºÏêϸָÄÏÓë½Ì³Ì

СÐò£º

SymfonyÊÇÒ»¸öÊ¢ÐеÄPHP WebÓ¦ÓóÌÐò¿ò¼Ü £¬ËüµÄÉè¼ÆÀíÄîÊǼòÆÓ¡¢ÎÞаºÍ¿ÉÀ©Õ¹µÄ¡£Ëæ×ÅSymfonyµÄÊ¢ÐжÈÒ»Ö±ÔöÌí £¬Ô½À´Ô½¶àµÄ¿ª·¢Ö°Ô±¹ØÓÚ¿ìËٴSymfonyÇéÐÎÌá³öÁËÐèÇó¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃDockerÀ´¿ìËÙ×°ÖÃSymfony £¬²¢ÌṩÏêϸָÄϺͽ̳Ì¡£

°ì·¨Ò»£º×°ÖÃDocker

Ê×ÏÈ £¬ÄúÐèÒªÔÚÄúµÄ»úеÉÏ×°ÖÃDocker¡£DockerÊÇÒ»¸ö¿ªÔ´µÄÈÝÆ÷»¯Æ½Ì¨ £¬Ëü¿ÉÒÔ×ÊÖúÎÒÃÇ¿ìËÙ¹¹½¨¡¢Ðû²¼ºÍÔËÐÐÓ¦ÓóÌÐò¡£Äú¿ÉÒÔÈ¥Docker¹Ù·½ÍøÕ¾ÏÂÔغÍ×°ÖÃDocker £¬Æ¾Ö¤ÄúµÄ²Ù×÷ϵͳѡÔñÊʺϵİ汾¡£

°ì·¨¶þ£º½¨ÉèSymfonyÏîÄ¿

ÔÚ×°ÖÃÁËDockerÖ®ºó £¬ÎÒÃÇ¿ÉÒÔ×îÏȽ¨ÉèSymfonyÏîÄ¿ÁË¡£ÔÚÏÂÁîÐÐÖÐ £¬Ê¹ÓÃÒÔÏÂÏÂÁÉèÒ»¸öеÄSymfonyÏîÄ¿£º

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

µÇ¼ºó¸´ÖÆ

Õâ¸öÏÂÁʹÓÃComposerÔÚÄ¿½ñĿ¼Ï½¨ÉèÒ»¸öÃûΪmy_project_nameµÄSymfonyÏîÄ¿¡£Äú¿ÉÒÔƾ֤ÐèÇóÐÞ¸ÄÏîÄ¿Ãû³Æ¡£

°ì·¨Èý£º½¨ÉèDockerfile

½ÓÏÂÀ´ £¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸öDockerfileÀ´½ç˵SymfonyÏîÄ¿µÄÈÝÆ÷»¯ÇéÐΡ£ÔÚÏîĿĿ¼Öн¨ÉèÒ»¸öÃûΪDockerfileµÄÎļþ £¬²¢½«ÒÔÏ´úÂ븴ÖƵ½ÎļþÖУº

FROM php:7.4-fpm

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

RUN docker-php-ext-install pdo pdo_pgsql zip

WORKDIR /app

COPY . /app

RUN curl -sS https://get.symfony.com/cli/installer | bash && mv /root/.symfony/bin/symfony /usr/local/bin/symfony

EXPOSE 8000

CMD ["symfony", "server:start", "--no-tls", "--allow-http", "0.0.0.0:8000"]

µÇ¼ºó¸´ÖÆ

¸ÃDockerfile½«»ùÓÚphp:7.4-fpm¾µÏñ½¨ÉèÒ»¸öеÄÈÝÆ÷ £¬²¢×°ÖÃÁËһЩÐëÒªµÄÈí¼þ°üºÍÀ©Õ¹À´Ö§³ÖSymfonyÏîÄ¿¡£Í¬Ê± £¬Ëü»¹Í¨¹ýComposer×°ÖÃSymfony CLI¹¤¾ß £¬²¢½«SymfonyÏîÄ¿µÄ´úÂ븴ÖƵ½ÈÝÆ÷ÖС£

°ì·¨ËÄ£º¹¹½¨Docker¾µÏñ

ÔÚÒѾ­½¨ÉèÁËDockerfileÖ®ºó £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÔÚÄ¿½ñĿ¼Ï¹¹½¨Docker¾µÏñ£º

$ docker build -t symfony-app .

µÇ¼ºó¸´ÖÆ

¸ÃÏÂÁƾ֤Dockerfile¹¹½¨Ò»¸öÃûΪsymfony-appµÄ¾µÏñ £¬²¢Ê¹ÓÃÄ¿½ñĿ¼×÷Ϊ¹¹½¨ÉÏÏÂÎÄ£¨¼´¸´ÖÆDockerfileËùÔÚµÄĿ¼£©¡£

°ì·¨Î壺Æô¶¯SymfonyÏîÄ¿

¹¹½¨Íê³É¾µÏñÖ®ºó £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÔÚDockerÈÝÆ÷ÖÐÆô¶¯SymfonyÏîÄ¿£º

$ docker run -it --rm -p 8000:8000 symfony-app

µÇ¼ºó¸´ÖÆ

¸ÃÏÂÁÔÚDockerÈÝÆ÷ÖÐÔËÐÐsymfony-app¾µÏñ £¬²¢½«ÈÝÆ÷µÄ8000¶Ë¿ÚÓ³Éäµ½Ö÷»úµÄ8000¶Ë¿Ú¡£Äú¿ÉÒÔƾ֤ÐèÒªÐ޸Ķ˿ÚÓ³Éä¡£

ÖÁ´Ë £¬ÎÒÃÇÒѾ­Àֳɽ«SymfonyÏîĿװÖõ½ÁËDockerÈÝÆ÷ÖÐ £¬²¢ÔÚÍâµØÆô¶¯ÁËSymfony¿ª·¢Ð§ÀÍÆ÷¡£Äú¿ÉÒÔͨ¹ý»á¼ûhttp://localhost:8000/ÔÚä¯ÀÀÆ÷ÖÐÉó²éÔËÐÐÖеÄSymfonyÓ¦ÓóÌÐò¡£

½áÂÛ£º

ͨ¹ýʹÓÃDocker £¬ÎÒÃÇ¿ÉÒÔ¿ìËٴSymfony¿ª·¢ÇéÐÎ £¬¶ø²»ÐèÒªÔÚÍâµØ»úеÉÏ×°ÖúÍÉèÖÃÖÖÖÖÈí¼þºÍÒÀÀµÏî¡£±¾ÎÄÖÐÌṩµÄÏêϸָÄϺͽ̳ÌÓ¦¸ÃÄܹ»×ÊÖúÄú¿ìËÙÉÏÊÖʹÓÃDockerÀ´×°ÖÃSymfony £¬²¢×ÊÖúÄú¸ü¸ßЧµØ¾ÙÐÐSymfonyÓ¦ÓóÌÐòµÄ¿ª·¢¡£×£ÄúÔÚSymfonyµÄÌìÏÂÖпª·¢Óä¿ì£¡

ÒÔÉϾÍÊÇDocker¿ìËÙ×°ÖÃSymfony£ºÏêϸָÄÏÓë½Ì³ÌµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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