Browse Source

add nginx

pull/3/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
fb8491e4f8
  1. 23
      Dockerfile
  2. 27
      docker-compose.yml
  3. 25
      docker/nginx/conf.d/default.conf

23
Dockerfile

@ -1,9 +1,7 @@
FROM php:7.4-fpm-alpine
RUN apk add --update libzip-dev curl-dev &&\
docker-php-ext-install curl && \
apk del gcc g++ &&\
rm -rf /var/cache/apk/*
apk del gcc g++
RUN apk add --no-cache \
zlib-dev \
@ -12,6 +10,8 @@ RUN apk add --no-cache \
oniguruma-dev \
libpq-dev
RUN rm -rf /var/cache/apk/*
RUN docker-php-ext-install \
curl \
mbstring \
@ -23,20 +23,19 @@ RUN docker-php-ext-install \
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN rm -rf /var/cache/apk/*
WORKDIR /var/www
COPY composer.json composer.lock ./
WORKDIR /var/www/html
COPY . .
RUN chmod +x artisan
RUN composer install
RUN composer dump-autoload --optimize
EXPOSE 80
RUN chown -R www-data:www-data .
WORKDIR /home/www-data
USER www-data
EXPOSE 9000
CMD php -S 0.0.0.0:80
CMD php-fpm

27
docker-compose.yml

@ -1,15 +1,34 @@
version: '3.8'
services:
lumen:
nginx:
image: nginx:alpine
restart: unless-stopped
tty: true
ports:
- '80:80'
- '443:443'
volumes:
- ./:/var/www/html
- ./docker/nginx/conf.d/:/etc/nginx/conf.d/
links:
- app
networks:
- ospro
depends_on:
- app
command: [nginx-debug, '-g', 'daemon off;']
app:
build:
context: .
dockerfile: Dockerfile
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
working_dir: /var/www/html
volumes:
- .:/var/www
- .:/var/www/html
restart: unless-stopped
ports:
- "9000:9000"
networks:
- ospro
healthcheck:

25
docker/nginx/conf.d/default.conf

@ -0,0 +1,25 @@
server {
listen 80;
index index.php index.html;
error_log "/var/log/nginx/error.log" debug;
access_log /var/log/nginx/access.log;
root /var/www/html;
location ~ ^/.+\.php(/|$) {
fastcgi_pass app:9000;
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
Loading…
Cancel
Save