Larvel + Vue 项目使用 Docker 作者: Chuwen 时间: 2021-12-28 分类: Docker 评论 先给出配置文件,有空了再慢慢说道 ### Dockerfile: ```dockerfile FROM node:12-alpine as frontend WORKDIR /app ADD web-vue/package.json /app/ ADD web-vue/package-lock.json /app/ RUN npm install --registry=https://registry.npm.taobao.org ADD web-vue /app RUN npm run build # 第 1 个阶段,构建 composer 所需要的依赖包 FROM composer as composer COPY database/ /app/database/ COPY composer.json /app/ RUN set -x ; cd /app \ && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \ && composer install \ --ignore-platform-reqs \ --no-interaction \ --no-plugins \ --no-scripts \ --prefer-dist # 第 2 个阶段 FROM shine09/php-fpm:73 as laravel ENV TZ="Asia/Shanghai" LANG="C.UTF-8" ARG LARAVEL_PATH=/app/laravel COPY --from=composer /app/vendor/ ${LARAVEL_PATH}/vendor/ COPY . ${LARAVEL_PATH} RUN set -x ; cd ${LARAVEL_PATH} \ && mv .env.docker .env \ && mkdir -p storage \ && mkdir -p storage/framework/cache \ && mkdir -p storage/framework/sessions \ && mkdir -p storage/framework/testing \ && mkdir -p storage/framework/views \ && mkdir -p storage/logs \ && chmod -R 777 storage \ && chmod -R 777 bootstrap/cache/ \ && php artisan package:discover # 第 3 个阶段 FROM nginx:alpine as nginx ENV TZ="Asia/Shanghai" LANG="C.UTF-8" ARG LARAVEL_PATH=/app/laravel COPY laravel.conf /etc/nginx/conf.d/ COPY --from=laravel ${LARAVEL_PATH}/public ${LARAVEL_PATH}/public COPY --from=frontend /app/net /app/frontend ``` ### docker-compose.yaml: ```yaml version: "3.7" services: php: build: context: . dockerfile: Dockerfile target: laravel container_name: project_app_server restart: always networks: - project_app nginx: build: context: . dockerfile: Dockerfile target: nginx container_name: project_app depends_on: - php ports: - "8092:80" networks: - project_app volumes: - ./logs/:/app/logs/ networks: project_app: driver: bridge name: project_app ``` ### laravel.conf: ```conf server { listen 80; server_name app.nowtime.cc; root /app/laravel/public; index index.php index.html; access_log /app/logs/$host.log; error_log /app/logs/$host.error.log; location / { try_files $uri $uri/ /index.php?$query_string; } location ^~ /app { alias /app/frontend; index index.html; try_files $uri $uri/ /app/index.html; } location ~ .*\.php(\/.*)*$ { fastcgi_pass project_app_server:9000; include fastcgi.conf; fastcgi_connect_timeout 10; fastcgi_send_timeout 10; fastcgi_read_timeout 10; } } ```
docker-compose build 报错 failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: write 作者: Chuwen 时间: 2021-12-27 分类: Docker 评论 报错信息:failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: write /var/lib/docker/buildkit/content/ingest/9e291301cada8545e8af2716ad4b51d25c1c394c7d56537588545a27b1af6caa/total: no space left on device ```shell ➜ project git:(docker) ✗ docker-compose build [+] Building 131.6s (6/7) [+] Building 136.5s (7/7) FINISHED => [project_nginx internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 1.31kB 0.0s => [project_php internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 1.31kB 0.0s => [project_nginx internal] load .dockerignore 0.0s => => transferring context: 193B 0.0s => [project_php internal] load .dockerignore 0.0s => => transferring context: 193B 0.0s => [project_nginx internal] load metadata for docker.io/shine09/php-fpm:73 1.4s => CANCELED [project_nginx internal] load metadata for docker.io/library/composer:latest 133.3s => ERROR [project_nginx internal] load metadata for docker.io/library/nginx:alpine 1.9s ------ > [project_nginx internal] load metadata for docker.io/library/nginx:alpine: ------ failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: write /var/lib/docker/buildkit/content/ingest/9e291301cada8545e8af2716ad4b51d25c1c394c7d56537588545a27b1af6caa/total: no space left on device ``` 造成这个问题的原因是,空间不足了 尝试过清理遗留的容器、镜像,但是空间大小仍然没有改变 原来需要使用 `docker builder prune` 去清理 > Docker 18.09 引入了 BuildKit ,提升了构建过程的性能、安全、存储管理等能力。 > > 用以是删除 build cache。 运行结果: ```shell ➜ roject git:(docker) ✗ docker builder prune WARNING! This will remove all dangling build cache. Are you sure you want to continue? [y/N] y Deleted build cache objects: 060s6iobx2shjaur2mxdud5uk loa6pcyqmg11ym2sx51uo5mp1 ykgerexwlp929jappel9z6xbw btwou3o6i0irgz416802igzmr z35xnktojiru2ek6k6jx1fixi zvtbk67q6efiteclfhqxpwwn4 ql0t8d9ey0t31lys5nrdl5ki6 ncrhcutzyt24ug4ppeb2odxks ejrrwsegogolzr54exkj6j0y3 z6ma19hnezpbnmhomdv73pvnp n0z6lqel7uogkns227vepz080 kv0wjg3sg239d12b0s73chcws 7xignroaqqcqsz8i3hdyub7c8 ijytq7jyunw3m2w7b8awpad6s rdfb818hs23cb7l4fxd3mxes6 k9hwj0nn8bqt7o610n8w3sd6z qanccc59jlimvhns3ic9c1pk6 xyn0xlzgx5lbold0fwe88i473 le0bhembbcwtvzhroyf92bx9i poga60u5n1xl9gjxzk1rgp9lz kctx61rkwuglfac4trup453cm vuphn2d9cqskavhul6ydgeuqz bu2wr9kq2sw3reftlahoh9phe 6dtt297kn1in1dooprwtmby41 ww3mcb8wr0mxeo2uhdop4glqp icosuea3s1de78t8yx31aa0da j4fsvxwwa8fdc34w5uv991hzr j3k3r9h1p5eosjfpvhxynpzzx 1c0vo3skwezjlpnvl42hnco1u bb9vb28l9tn54ag2ljo2naefy kzzaw7m93ut1buj25qjozqv7a kjrnlbs9g79qnd6n4i38o9s4j g67e155v4wxeazfnmc6rq6dk3 b5yuon9rxo6syloq9dwqhcf7j oqati1aj4uof1a6d576qsip6o thwdqppga6i6j83liem4sgkhq bv8mleimb82wnoga7ynudrlay 3yaxulepeia74fua7l5qodsg6 ebjvv9c4gc3207m6jaskblhdx xe19sev0kllyueg0sljdh7sro 2655yecp46266g2e4r1078xwp 9mfmn9hn4iois86o784baw7eb ya4voiv79edyfgy25i2cz9rn6 xkyaincdmwcnuctukty3wzy2c to1wbodnkrcrvt137sprfwl87 gxbmdx9tv3zmuyiodfrj2wpu6 0in53gnwih744wiy7m0c0fp7v iah58nlbbxidi3p6f89ekvvpb eaet1zsbdmvc6gp7f3cjghd8n 4wva5bqyv6xvp8fqjao8vwyzv cmo0gaad2guwpqr1scyjbw68a xinmrl0m7asw8umb9sp14pbgr m9gvvbuozgfwx07i2gx7pm733 iger8gj8r6mh5deywqycqzp0y x1bgxl4vvofqcu05ddjwhaps3 zkyi2k6v9stlnq3edv4rsfni9 zbayx6yb6jo0bq12viig50hfl yq8f7bq6l9r42vu06xbzx7zck 9bagz8pt8gi07xn17ev0ibrlk sx36yf96z8mcorw05cfxzyb5y oivdne6d7n9y727gd1ygrgz61 7yo2s648ou7k9ukxa5lzg3drj tmaiy4wcix9ozby5n17ckxhkq wx8xj4obo38xieuk8ij65pc8b 0lkfs4by1chxdrfcdqojrtqfk 4bwup6q8mpr5nybq6ykkueuxx thn4ntkx71m135e7dq5lxl47f nudgk7acvd3txrhx9a3mkqcp7 ug0i27yka96at7pbl999g2mpn 9bhvgkajhwl49hvx649ldh0nv syci6cpr8yxh14myibd8jnj1j slgfmgr8gix7scda1ah7m69s3 o0e7w3c47a7jnjwz0xtd9hba6 la598f701zjjje7v3fajqttou ipsajnw8s6f0bnn8zj3t8lhl1 7zpoxctmlu1s0ag4vnt9dv7tp gvbpryxerb50b3ypgakghs04k g6whd57o2dvx4zfpfghagreh4 crlfatxx3qygnc1kh2sgofaz5 kzhx9qq9tlgfnnb7mixruuc1t khcwtjoovt654w9hms1u7qrux 61t5ylrq9abx7mretz0ychnt5 jeor27taqeql0dtpnhhyj0jdf j8ob85u00seposa9x2sftcel7 9n51q2l1b9tfx5egqb6jhdrs9 hwbs1e3d89w9zs8ynt9bmhk3c 7petri052vigslcacydlu0dye 6btuxpf4hlicdt15srcumle3r vwsb5wlfy6muv40iw0g7t0sj3 rm84nqpnhberfz22t4soxwzzg maq02kqqq4qljq3g38e0yhcmc el7khby49sazdgb5ye9biw7di y879m9qh4p01thm9vw24p5k23 shf7twld7fqrrnmoyg7ot2htg ztgnpbw3yhwzkjrsc0egi2n9g 2o97ep47lux0hr6a6ey5q319m iiinckra4ufnp3e5j6vttx1gv z0wa3npzfjbrx2ct5g28g9k19 jw4s5xxhczay547ybw04gemve khp4tlij3mjriujk2oto55w1t qkxdeliyqg8jizqcvwdgatkhz 9wo5drszq2alqn4i7v12tdv9a d94ypppyuuh5wb4ab4y81p8cg izc5xrv7smmx598zwcbf94mrs v06yztvgr63zrvmuclddhl60r 02opuxw6sw1nktnemvg3tdbfn ehe60fc9zm3kvu7k63di4u72r 0d520f54vvmtjq3ifnon1oxte v6xmogq5qvmmysg8a8i6zojrb h9t2vx8z177o3gfe1j8zhj8sy qo56gtd2pgk8j2rmeoa3q2z6x 4lr3jz7oy304ifvkfymx68uq6 l3qjj0rlzb9it64dqstasxzqo zjwzbdoulk3syrefhojtvjnye huk8zv42tbejdmbw9vf8yebm6 us4zg6el0mlr1wpbteeoby77m c4wjprfiiiojk9hyqhtcwe20v 0cu7b1sijs07jzbk0jue3g84e 93dg4l5q8twmty4w09cpaj2c3 x1hsak9a8jkgz24a0191ylfrh v5sjttfws18bzmc85elchbz8c knqjbh2d89u35canp5tud1onb mui3faeth4hjocy3g23hn03q0 kef6dtg73sivql1yb33p2f2bc x59oqktfqrvxppzdi5idxawid 5mgjgorlv06qb7u3nyickehyf mwgssq8qcmrvtzsuzwyrhnlon expgls0lg5spy7zm36pbjgbtq pd2p1owc094mh3cepjfhx61wp 40dw6txh2y0m1qz0x7ljnuda1 n9ttqu1b10gar6skbtbcdmkz6 d0bhpu1i47u5v1hrtnv6xtmto t42k89ahijz7kt88n312dp7ie m2fnh6b4rvligmy534k3b5i4g 3sz7ifqqmqb8u7h4dzfb3p0pt 7oy23bxctl6udzops0cgan9f5 q4t1oacd7kkqmolg9amzi6c06 r14d7mv8kk04lw4inehjr30co 1yw32u510v9ia9q82e24zdzec k2d5y17vc797q55te0s93ng2d u98ihfbrovpu4gtz0o3ocvmdu wrmkh9r63pxu6zqom3jmm684h vdlq4td01wb0v0dlv5e645msr c01eigahfjl25it8mr4jgmyfe qi2dfoa10k1q3w908ff99y07i kc6l4dm5cjalce2nm8afg349u jhlrvpibkfwf5hl9w9tdfb7qz ex3mpt19ldl898di6hmueb5it tbc40vjsw7tcayngonr1j60ju pzendv6s4i4ajuuvr8xkpyug0 ubzt145l9oqu1yoh68d5720fz ukljll2u7sdxqdehli9556liz scn48e0posg6ebai2e1ohraul fsowwv2hmura2xjei48mk19lr uey1ddckh3eas3kr17gfzszdy v2cxja0qfp659gkps8rycfi1w kb3nw6rkn80yh5nanxxs3vtoj s5nl7t61uhz9udozu2n2ybglt qgj2kqetk75uxdy25jemgn4pn lp7nq01xn1yt436g0xrmqtpwn f1kar6e70mu2hltix40hi3bz9 mulq11grm4jc3cycm9yfoji8f jh8yjfmdtoddl8ul5os6yfjkh cm64vyh57q48w1hegejdn7h5t i1kf4jgvb7fhrrwi39eauw41r 8vdtew68la07uwyw75dtstohx 02wz1kvr1i64v8eqe99dp0v6m xi3euq2sqyrp2qwayyptle59q wbofdgiikgafx3t03u6qcgsqy 8rz0wz6qlgo3qbq4dyrtelzv2 bwhyya3my59whrt06vo0tybmq ofgs5q1aytq65mnkpxhkvpvz8 o051qqlmixkbydp32at9ywjbw xojddj4qbj1kkqj4m89mf52jk 8omgo4zj1faipn7dwrjh73i86 kl1rm7ko5wrn0xax1xfde12a6 zeqbzkiuh3gx690whqh9tg8hx n409wb8voerzplv6a1e71swc5 i5h1545b7hbbxzc0x9a9tirfq 5jf54s9cgr3q6uesowrh33uhf 17q2ni2fqgoxvok5xy686qb56 xvgniaph43znc9s7ellhjouvh 99mls6hwpjxk82516dkkxfgbv affvc8fl2lwb95cn0v7wopvtg w0f55bx3fz36lt7wliy8a5dpj 162wf8qykmh5qyi5szmn1n72t 8k6ytmk9bw4rg41j7jwlejyce w86qjxpkvgijz2pq81i2snbuw zka85ldhfv8ibidpbm566a0nv 2kh4vnmaszknztw1ewfofhdlw gezx9k593ltk0uwhdksiiga1e 4yiyfrmxxdvmmto45ayfk4a79 79rxqbdun5vojf46tyrttauto lc0lsk2pc8yg2gfws3d3xwvhi kylmvhy0fgsqhm7gcoirtft9q 0glows7a14lq8xufi2yq78lxh j5b0toxyufowzxu2efj2l5zjd vw7dsy8ywwy6mcue3vtaaajg8 35nfrgzxn00zhfr3swxerbmn6 k3ux3auubx4vrvy3xa30axb73 uxsshp1p572czc291qz6gwyjk iokjegfv1zry15y9skkhcropf p14c8enho5zarrkxzilwajxtq l96bwj3dvch2xsbpxkssprhc7 uqsiazay6ytazb6v7n7dnacgs 92enlx6nyigh9mcxloel45g8h 73xiq05fhplchr5053lwno7ul 8kggdgen3fe5m3ougm340lxtm y60oao32vmv3tkrv36q6yy6lx omggb7adx9zs5l8guricsti71 0yj4a33ypjkxe693hanpe8d13 h9w3qvmq0ue8q6azl905nuod1 ib91ovlhzcjiz91akx2lrvsl6 r6dwipr8elffmpo59ui0q3el7 Total reclaimed space: 7.761GB ```