Add docker

This commit is contained in:
philipp lang 2022-02-28 21:07:12 +01:00
parent 93cc01fb2d
commit 3c28e536fe
5 changed files with 120 additions and 5 deletions

49
.docker/nginx/nginx.conf Normal file
View File

@ -0,0 +1,49 @@
events {
worker_connections 768;
# multi_accept on;
}
http {
include mime.types;
include fastcgi.conf;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
server_tokens off;
client_max_body_size 10M;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server {
listen 80;
root /app/public;
charset utf-8;
index index.php;
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 ~ /\.ht {
deny all;
}
location ~ /\.(?!well-known).* {
deny all;
}
location ~ \.php$ {
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Client-Id,Client-Secret,Cache-Control,Content-Type,Pragma,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,App-Platform,App-Version,Idempotency-Key' always;
fastcgi_pass php:9000;
fastcgi_index index.php;
}
}
}

19
.docker/php.Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM php:8.1.3-fpm-buster
WORKDIR /app
RUN useradd -d /app -s /bin/bash runner
RUN sed -i 's/user = www-data/user = runner/' /usr/local/etc/php-fpm.d/www.conf
RUN sed -i 's/group = www-data/group = runner/' /usr/local/etc/php-fpm.d/www.conf
RUN apt-get clean && apt-get update && apt-get install -y apt-utils
RUN apt-get install -y libsodium-dev curl libpng-dev git zip
RUN docker-php-ext-install mysqli pdo pdo_mysql sodium bcmath exif gd pcntl
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer
RUN rm composer-setup.php

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
node_modules

View File

@ -66,11 +66,11 @@ return [
'mysqltest' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_TEST_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'host' => env('DB_TEST_HOST', env('DB_HOST', '127.0.0.1')),
'port' => env('DB_TEST_PORT', env('DB_PORT', '3306')),
'database' => env('DB_TEST_DATABASE', env('DB_DATABASE', 'forge')),
'username' => env('DB_TEST_USERNAME', env('DB_USERNAME', 'forge')),
'password' => env('DB_TEST_PASSWORD', env('DB_PASSWORD', '')),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',

46
docker-compose.yml Normal file
View File

@ -0,0 +1,46 @@
version: '1'
services:
webservice:
image: nginx:1.21.6-alpine
container_name: nginx
depends_on:
- php
ports:
- "8000:80"
volumes:
- ./:/app
- ./storage:/app/storage
- ./.docker/nginx/nginx.conf:/etc/nginx/nginx.conf
php:
build:
context: .
dockerfile: ./.docker/php.Dockerfile
container_name: php
depends_on:
- db
- dbtest
command: php-fpm -F -R
volumes:
- ./:/app
- ./storage:/app/storage
- ./.docker/nginx/nginx.conf:/etc/nginx/nginx.conf
db:
image: mariadb:10.6.5
container_name: db
environment:
MARIADB_ROOT_PASSWORD: local
MYSQL_PASSWORD: local
MYSQL_DATABASE: db
MYSQL_USER: db
volumes:
- /opt/mysql-docker/scoutrobot-db:/var/lib/mysql
dbtest:
image: mariadb:10.6.5
container_name: dbtest
environment:
MARIADB_ROOT_PASSWORD: local
MYSQL_PASSWORD: local
MYSQL_DATABASE: db
MYSQL_USER: db
volumes:
- /opt/mysql-docker/scoutrobot-dbtest:/var/lib/mysql