diff options
Diffstat (limited to 'main/docker')
-rwxr-xr-x | main/docker/README.md | 35 | ||||
-rwxr-xr-x | main/docker/nginx/Dockerfile | 2 | ||||
-rwxr-xr-x | main/docker/nginx/default.conf | 28 | ||||
-rwxr-xr-x | main/docker/node/Dockerfile | 4 | ||||
-rwxr-xr-x | main/docker/php/Dockerfile | 11 |
5 files changed, 80 insertions, 0 deletions
diff --git a/main/docker/README.md b/main/docker/README.md new file mode 100755 index 0000000..a2da2e5 --- /dev/null +++ b/main/docker/README.md @@ -0,0 +1,35 @@ +# Docker Development Environment + +First, install [Docker Compose](https://docs.docker.com/compose/install/). + +Second, initialize a new UserFrosting project: + +1. Copy `app/sprinkles/sprinkles.example.json` to `app/sprinkles/sprinkles.json` +2. Run `chmod 777 app/{logs,cache,sessions}` to fix file permissions for web server. (NOTE: File + permissions should be properly secured in a production environment!) +2. Run `docker-compose run composer install` to install all composer modules. +3. Run `docker-compose run node npm install` to install all npm modules. + +Now you can start up the entire Nginx + PHP + MySQL stack using docker with: + + $ docker-compose up + +On the first run you need to init the database (your container name may be different depending on the name of your root directory): + + $ docker exec -it -u www-data userfrosting_php_1 bash -c 'php bakery migrate' + +You also need to setup the first admin user (again, your container name may be different depending on the name of your root directory): + + $ docker exec -it -u www-data userfrosting_php_1 bash -c 'php bakery create-admin' + +Now visit http://localhost:8570/ to see your UserFrosting homepage! + +**This is not (yet) meant for production!!** + +You may be tempted to run with this in production but this setup has not been security-hardened. For example: + +- Database is exposed on port 8571 so you can access MySQL using your favorite client at localhost:8571. However, + the way Docker exposes this actually bypasses common firewalls like `ufw` so this should not be exposed in production. +- Database credentials are hard-coded so obviously not secure. +- File permissions may be more open than necessary. +- It just hasn't been thoroughly tested in the capacity of being a production system. diff --git a/main/docker/nginx/Dockerfile b/main/docker/nginx/Dockerfile new file mode 100755 index 0000000..7d2fbc3 --- /dev/null +++ b/main/docker/nginx/Dockerfile @@ -0,0 +1,2 @@ +FROM nginx:alpine +COPY default.conf /etc/nginx/conf.d/default.conf diff --git a/main/docker/nginx/default.conf b/main/docker/nginx/default.conf new file mode 100755 index 0000000..8ae7bb8 --- /dev/null +++ b/main/docker/nginx/default.conf @@ -0,0 +1,28 @@ +server { + listen 80; + root /app/public; + server_name ""; + + access_log /app/app/logs/nginx-access.log; + + add_header X-Frame-Options SAMEORIGIN; + add_header X-Content-Type-Options nosniff; + + location = /index.php { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_keep_conn on; + fastcgi_pass php:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + location ~* \.(png|gif|jpg|jpeg|ico|css|js|woff|ttf|otf|woff2|eot)$ { + include /etc/nginx/mime.types; + expires max; + try_files $uri /index.php?$query_string; + } + location / { + index index.php; + try_files $uri /index.php?$query_string; + } +} diff --git a/main/docker/node/Dockerfile b/main/docker/node/Dockerfile new file mode 100755 index 0000000..a985509 --- /dev/null +++ b/main/docker/node/Dockerfile @@ -0,0 +1,4 @@ +FROM node:alpine + +RUN apk --update add --no-cache git +RUN echo '{ "allow_root": true }' > /root/.bowerrc
\ No newline at end of file diff --git a/main/docker/php/Dockerfile b/main/docker/php/Dockerfile new file mode 100755 index 0000000..165cf4f --- /dev/null +++ b/main/docker/php/Dockerfile @@ -0,0 +1,11 @@ +FROM php:7.0-fpm +RUN apt-get update && apt-get install -y \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libpng12-dev \ + && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ + && docker-php-ext-install -j$(nproc) gd \ + && docker-php-ext-install -j$(nproc) pdo pdo_mysql +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +WORKDIR /app |