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 FROM php:7.4-fpm-alpine
RUN apk add --update libzip-dev curl-dev &&\ RUN apk add --update libzip-dev curl-dev &&\
docker-php-ext-install curl && \ apk del gcc g++
apk del gcc g++ &&\
rm -rf /var/cache/apk/*
RUN apk add --no-cache \ RUN apk add --no-cache \
zlib-dev \ zlib-dev \
@ -12,6 +10,8 @@ RUN apk add --no-cache \
oniguruma-dev \ oniguruma-dev \
libpq-dev libpq-dev
RUN rm -rf /var/cache/apk/*
RUN docker-php-ext-install \ RUN docker-php-ext-install \
curl \ curl \
mbstring \ 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 curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN rm -rf /var/cache/apk/* WORKDIR /var/www/html
WORKDIR /var/www
COPY composer.json composer.lock ./
COPY . . COPY . .
RUN chmod +x artisan RUN chmod +x artisan
RUN composer install RUN composer install
RUN composer dump-autoload --optimize 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' version: '3.8'
services: 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: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
extra_hosts: extra_hosts:
- 'host.docker.internal:host-gateway' - 'host.docker.internal:host-gateway'
ports: working_dir: /var/www/html
- '${APP_PORT:-80}:80'
volumes: volumes:
- .:/var/www - .:/var/www/html
restart: unless-stopped
ports:
- "9000:9000"
networks: networks:
- ospro - ospro
healthcheck: 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