Update laravel, close #465

1.2.0
Kang Huaishuai 2020-10-07 13:31:45 +08:00
parent 83929dd096
commit 68d85ac31e
No known key found for this signature in database
GPG Key ID: 5E515022F565DA09
3 changed files with 48 additions and 30 deletions

View File

@ -1,9 +1,14 @@
.idea/
.git/
vendor/
node_modules/
public/js/
public/css/
public/mix-manifest.json
yarn-error.log
bootstrap/cache/*

View File

@ -2,13 +2,15 @@ FROM node:alpine as frontend
COPY package.json /app/
RUN cd /app \
RUN set -x ; cd /app \
&& npm install --registry=https://registry.npm.taobao.org
COPY webpack.mix.js /app/
COPY resources/assets/ /app/resources/assets/
COPY resources/ /app/resources/
RUN cd /app \
RUN set -x ; cd /app \
&& touch artisan \
&& mkdir -p public \
&& npm run production
FROM composer as composer
@ -16,7 +18,7 @@ FROM composer as composer
COPY database/ /app/database/
COPY composer.json /app/
RUN cd /app \
RUN set -x ; cd /app \
&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
&& composer install \
--ignore-platform-reqs \
@ -25,7 +27,7 @@ RUN cd /app \
--no-scripts \
--prefer-dist
FROM php:7.2-fpm-alpine as laravel
FROM php:7.4-fpm-alpine as laravel
ARG LARAVEL_PATH=/app/laravel
@ -33,17 +35,17 @@ COPY --from=composer /app/vendor/ ${LARAVEL_PATH}/vendor/
COPY . ${LARAVEL_PATH}
COPY --from=frontend /app/public/js/ ${LARAVEL_PATH}/public/js/
COPY --from=frontend /app/public/css/ ${LARAVEL_PATH}/public/css/
COPY --from=frontend /app/mix-manifest.json ${LARAVEL_PATH}/mix-manifest.json
COPY --from=frontend /app/public/mix-manifest.json ${LARAVEL_PATH}/public/mix-manifest.json
RUN cd ${LARAVEL_PATH} \
&& php artisan package:discover \
RUN set -x ; cd ${LARAVEL_PATH} \
&& 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 storage \
&& php artisan package:discover
FROM nginx:alpine as nginx

View File

@ -1,6 +1,6 @@
# Laravel
> PHP
> PHP `Laravel` 8.x
##
@ -11,10 +11,15 @@
```bash
.idea/
.git/
vendor/
node_modules/
public/js/
public/css/
public/mix-manifest.json
yarn-error.log
bootstrap/cache/*
@ -55,13 +60,15 @@ FROM node:alpine as frontend
COPY package.json /app/
RUN cd /app \
RUN set -x ; cd /app \
&& npm install --registry=https://registry.npm.taobao.org
COPY webpack.mix.js /app/
COPY resources/assets/ /app/resources/assets/
COPY resources/ /app/resources/
RUN cd /app \
RUN set -x ; cd /app \
&& touch artisan \
&& mkdir -p public \
&& npm run production
```
@ -75,7 +82,7 @@ FROM composer as composer
COPY database/ /app/database/
COPY composer.json composer.lock /app/
RUN cd /app \
RUN set -x ; cd /app \
&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
&& composer install \
--ignore-platform-reqs \
@ -90,7 +97,7 @@ RUN cd /app \
```docker
FROM php:7.2-fpm-alpine as laravel
FROM php:7.4-fpm-alpine as laravel
ARG LARAVEL_PATH=/app/laravel
@ -98,17 +105,17 @@ COPY --from=composer /app/vendor/ ${LARAVEL_PATH}/vendor/
COPY . ${LARAVEL_PATH}
COPY --from=frontend /app/public/js/ ${LARAVEL_PATH}/public/js/
COPY --from=frontend /app/public/css/ ${LARAVEL_PATH}/public/css/
COPY --from=frontend /app/mix-manifest.json ${LARAVEL_PATH}/mix-manifest.json
COPY --from=frontend /app/public/mix-manifest.json ${LARAVEL_PATH}/public/mix-manifest.json
RUN cd ${LARAVEL_PATH} \
&& php artisan package:discover \
RUN set -x ; cd ${LARAVEL_PATH} \
&& 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 storage \
&& php artisan package:discover
```
## NGINX
@ -143,13 +150,13 @@ $ docker network create laravel
laravel `--name=laravel` `nginx` `fastcgi_pass laravel:9000;`
```bash
$ docker run -it --rm --name=laravel --network=laravel my/laravel
$ docker run -dit --rm --name=laravel --network=laravel my/laravel
```
nginx
```bash
$ docker run -it --rm --network=laravel -p 8080:80 my/nginx
$ docker run -dit --rm --network=laravel -p 8080:80 my/nginx
```
访 `127.0.0.1:8080` Laravel
@ -160,6 +167,8 @@ $ docker run -it --rm --network=laravel -p 8080:80 my/nginx
便使 **** `config` `secret` `Swarm mode` `Kubernetes`
https://github.com/khs1994-docker/laravel-demo 项目。
##
`Dockerfile`
@ -169,13 +178,15 @@ FROM node:alpine as frontend
COPY package.json /app/
RUN cd /app \
RUN set -x ; cd /app \
&& npm install --registry=https://registry.npm.taobao.org
COPY webpack.mix.js /app/
COPY resources/assets/ /app/resources/assets/
COPY resources/ /app/resources/
RUN cd /app \
RUN set -x ; cd /app \
&& touch artisan \
&& mkdir -p public \
&& npm run production
FROM composer as composer
@ -183,7 +194,7 @@ FROM composer as composer
COPY database/ /app/database/
COPY composer.json /app/
RUN cd /app \
RUN set -x ; cd /app \
&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
&& composer install \
--ignore-platform-reqs \
@ -192,7 +203,7 @@ RUN cd /app \
--no-scripts \
--prefer-dist
FROM php:7.2-fpm-alpine as laravel
FROM php:7.4-fpm-alpine as laravel
ARG LARAVEL_PATH=/app/laravel
@ -200,17 +211,17 @@ COPY --from=composer /app/vendor/ ${LARAVEL_PATH}/vendor/
COPY . ${LARAVEL_PATH}
COPY --from=frontend /app/public/js/ ${LARAVEL_PATH}/public/js/
COPY --from=frontend /app/public/css/ ${LARAVEL_PATH}/public/css/
COPY --from=frontend /app/mix-manifest.json ${LARAVEL_PATH}/mix-manifest.json
COPY --from=frontend /app/public/mix-manifest.json ${LARAVEL_PATH}/public/mix-manifest.json
RUN cd ${LARAVEL_PATH} \
&& php artisan package:discover \
RUN set -x ; cd ${LARAVEL_PATH} \
&& 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 storage \
&& php artisan package:discover
FROM nginx:alpine as nginx