Skip to content

Instantly share code, notes, and snippets.

@blue7wings
Last active May 11, 2021 07:44
Show Gist options
  • Save blue7wings/5bfcf304e6b4735320cc1b068028533c to your computer and use it in GitHub Desktop.
Save blue7wings/5bfcf304e6b4735320cc1b068028533c to your computer and use it in GitHub Desktop.
The Simplest Laravel Docker Environment

how to use

put three files in same folder and modify your_laravel_project_path, then use command docker-compose up -d to start.

server {
listen 80;
server_name center.u1ss.com;
underscores_in_headers on;
index index.php;
charset utf-8;
root /app/public/;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass php_fpm:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
version: "2"
services:
nginx:
image: "nginx:alpine"
container_name: "nginx"
ports:
- "80:80"
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf
- your_laravel_project_path:/app
links:
- php_fpm
php_fpm:
container_name: "php_fpm"
build:
context: .
dockerfile: ./php.dockerfile
tty: true
image: "env_php_fpm"
volumes:
- your_laravel_project_path:/app
working_dir: /app
FROM php:7.4-fpm-alpine
# if you not in China, please delete this line
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
# Install dev dependencies
RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
curl-dev \
imagemagick-dev \
libtool \
libxml2-dev \
postgresql-dev \
sqlite-dev
# Install production dependencies
RUN apk add --no-cache \
bash \
curl \
freetype-dev \
g++ \
gcc \
git \
icu-dev \
icu-libs \
imagemagick \
libc-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
make \
mysql-client \
openssh-client \
postgresql-libs \
rsync \
zlib-dev \
oniguruma-dev
# Install PECL and PEAR extensions
RUN pecl install \
redis \
imagick
# Enable PECL and PEAR extensions
RUN docker-php-ext-enable \
redis \
imagick
# Configure php extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
# Install php extensions
RUN docker-php-ext-install \
bcmath \
calendar \
curl \
exif \
gd \
iconv \
intl \
mbstring \
pdo \
pdo_mysql \
pdo_pgsql \
pdo_sqlite \
pcntl \
tokenizer \
xml \
zip
# install iconv extension
RUN apk add --upgrade gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so
# Cleanup dev dependencies
RUN apk del -f .build-deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment