diff --git a/Dockerfile b/Dockerfile index 3984a02..8e36fff 100644 --- a/Dockerfile +++ b/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 diff --git a/docker-compose.yml b/docker-compose.yml index 7a0ec5d..c7837c9 100644 --- a/docker-compose.yml +++ b/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: diff --git a/docker/nginx/conf.d/default.conf b/docker/nginx/conf.d/default.conf new file mode 100644 index 0000000..e3e292a --- /dev/null +++ b/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; + } + +}