Docker 배치 Laravel 응용-기초 응용
php:7.3-apache
laravel:5.8.*
# mix , js、css、img , mix
npm install
npm run production
# composer.lock
composer install --ignore-platform-reqs --optimize-autoloader --no-dev
2.아파 치 설정 파일 준비 하기
docker/000-default.conf
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/html/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
3.Dockerfile 파일 준비
FROM php:7.3-apache
LABEL maintainer="[email protected]"
#
ARG TZ=Asia/Shanghai
ENV TZ ${TZ}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#
ARG DEBIAN_URL=mirrors.ustc.edu.cn
ENV DEBIAN_URL ${DEBIAN_URL}
RUN sed -i "s/deb.debian.org/$DEBIAN_URL/g" /etc/apt/sources.list
ARG DEBIAN_SECURITY_URL=mirrors.ustc.edu.cn/debian-security
ENV DEBIAN_SECURITY_URL ${DEBIAN_SECURITY_URL}
RUN sed -i "s|security.debian.org/debian-security|$DEBIAN_SECURITY_URL|g" /etc/apt/sources.list
# cron
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends cron \
&& apt-get autoremove \
&& apt-get autoclean \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#
ENV PHP_EXTENSION \
pdo_mysql \
bcmath
ENV PECL_EXTENSION \
redis
RUN docker-php-ext-install $PHP_EXTENSION \
&& pecl install $PECL_EXTENSION \
&& docker-php-ext-enable $PECL_EXTENSION \
opcache \
&& a2enmod rewrite
#
EXPOSE 80
ARG APP_ENV=development
ENV APP_ENV ${APP_ENV}
COPY --chown=www-data:www-data . /var/www/html
COPY docker/000-default.conf /etc/apache2/sites-available/000-default.conf
WORKDIR /var/www/html
4.Dockerignore 파일 준비:
.dockerignore
(필요 하지 않 음)/node_modules
/.dockerignore
/Dockerfile
5.미 러 입구 파일 준비:
docker-entrypoint.sh
(필요 하지 않 음)이 파일 은 실행 권한 이 필요 합 니 다.그러나 이 입구 파일 은 필요 한 것 이 아 닙 니 다.실행 하기 전에 캐 시 명령 을 실행 하기 위해 서 입 니 다.구체 적 으로 여 기 를 클릭 하여 문 서 를 확인 할 수 있 습 니 다.
#!/usr/bin/env bash
php artisan cache:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
apache2-foreground
6.미 러 실행
docker run -p 80:80 .
관련 읽 기
wkhtmltopdf
내 보 내기 PDF이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Swarm의 도커 비밀이 게시물에서는 Redis를 사용한 실제 시나리오 예제를 제공하여 사용 방법을 보여주고자 합니다. Docker 기술에 대한 기본 지식 Docker Swarm 오케스트레이터에 대한 기본 지식 "Docker Swarm ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.