Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Docker #35

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM php:7.2-fpm as base

# Install PHP extensions
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-install zip \
&& rm -rf /var/www/html

WORKDIR /var/www

# Build
# ==============================================================================
FROM base as build

# Composer setup
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_NO_INTERACTION 1

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY composer.* ./

# Install composer packages
RUN composer install --no-dev --no-scripts --no-autoloader

COPY . .

RUN composer dump-autoload --optimize

# Production
# ==============================================================================
FROM base as production

# Set Laravel to log to error log
ENV APP_LOG errorlog

COPY . .
COPY --from=build /var/www/vendor ./vendor
15 changes: 15 additions & 0 deletions .docker/cron/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:latest

RUN apk add --no-cache \
bash \
curl

COPY ./periodic /etc/periodic

ENTRYPOINT ["crond"]

HEALTHCHECK --interval=5s --timeout=2s \
CMD ps | grep '[c]rond' || exit 1

# Start cron in foreground with logging to stderr
CMD ["-f", "-d8"]
3 changes: 3 additions & 0 deletions .docker/cron/periodic/daily/build-private
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

curl -sS -H "X-Requested-With: XMLHttpRequest" -X POST http://$WEB_HOST/control-panel/build-public > /dev/stdout 2>/dev/stderr
3 changes: 3 additions & 0 deletions .docker/cron/periodic/daily/build-public
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

curl -sS -H "X-Requested-With: XMLHttpRequest" -X POST http://$WEB_HOST/control-panel/build-private > /dev/stdout 2>/dev/stderr
3 changes: 3 additions & 0 deletions .docker/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx:1.15

COPY vhost.conf /etc/nginx/conf.d/default.conf
22 changes: 22 additions & 0 deletions .docker/web/vhost.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
server {
listen 80;
index index.php index.html;
root /var/www/public;

location / {
try_files $uri /index.php?$args;
}

location /control-panel/ {
try_files $uri /control-panel/index.php?$args;
}

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass satis-control-panel-app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
bootstrap/cache/**
node_modules
storage/framework/cache/**
storage/framework/sessions/**
storage/framework/views/**
vendor
4 changes: 3 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function boot()
*/
public function register()
{
//
if ($this->app->environment() !== 'production') {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
}
}
13 changes: 4 additions & 9 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
|
*/

'url' => 'http://localhost',
'url' => env('APP_URL', 'http://localhost'),

/*
|--------------------------------------------------------------------------
Expand All @@ -39,7 +39,7 @@
|
*/

'timezone' => 'UTC',
'timezone' => env('APP_TIMEZONE', 'UTC'),

/*
|--------------------------------------------------------------------------
Expand All @@ -52,7 +52,7 @@
|
*/

'locale' => 'en',
'locale' => env('APP_LOCALE', 'en'),

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -95,7 +95,7 @@
|
*/

'log' => 'single',
'log' => env('APP_LOG', 'single'),

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -144,11 +144,6 @@
App\Providers\RouteServiceProvider::class,
App\Providers\SatisServiceProvider::class,

/*
* Project providers
*/
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
#Barryvdh\Debugbar\ServiceProvider::class
],

/*
Expand Down
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3'

services:
satis-control-panel-app:
container_name: satis-control-panel-app
build:
context: .
dockerfile: .docker/app/Dockerfile
environment:
APP_KEY: ${APP_KEY:-null}
volumes:
- app-public:/var/www/public

satis-control-panel-web:
container_name: satis-control-panel-web
build:
context: .docker/web
volumes:
- app-public:/var/www/public:ro
depends_on:
- satis-control-panel-app

satis-control-panel-cron:
container_name: satis-control-panel-cron
build:
context: .docker/cron
environment:
WEB_HOST: satis-control-panel-web
depends_on:
- satis-control-panel-web

volumes:
app-public: