Skip to content

Commit

Permalink
Merge pull request #9 from joglomedia/linux
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
joglomedia authored Jun 26, 2021
2 parents 5ee4cf9 + f27c453 commit 7ff22ec
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 81 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
composer.lock
vendor
src/docker-compose.yml~
src/Dockerfile~
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

![EasyDock for Linux](ed_275px.png)

A fork of EasyDock to work in Linux. Dockerize your PHP apps ;)
A fork of EasyDock for Linux. Docker LEMP stack easy integration.

Docker LEMP easy integration
Dockerize your PHP apps ;)

![GitHub stars](https://img.shields.io/github/stars/joglomedia/easydock-linux?style=social)
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/joglomedia/easydock-linux?label=version)
Expand All @@ -19,14 +19,13 @@ Easydock comes with:
- Redis
- ~~phpmyadmin~~ Adminer (Lightweight MySQL admin)
- MailHog
- ~~node.js~~
- ~~npm~~
- Node.js, NPM & Yarn
- Git
- Composer

## Requirements

Docker and Docker Compose on Linux Distro (Debian, Ubuntu)
Docker and Docker Compose installed on Linux Distro (Debian, Ubuntu)

## Installation

Expand All @@ -49,7 +48,7 @@ easydock init && easydock import
easydock build
```

- Config your app DB connection (default)
### Config your app DB connection (default)

```bash
user: root
Expand All @@ -58,58 +57,59 @@ db: dockerdb
host: mysql ( or redis for Redis )
```

- Config your app SMTP conn (default - no user or pass are required)
### Config your app SMTP conn (default - no user or pass are required)

```bash
host: mailhog
port: 1025
```

- Nginx config will expose your project `/public` folder
- The default Nginx config (app.conf) will expose your project `/public` folder.
- If your project is using different directory structure, you should adjust the configurations and update the file accordingly.

- To start your Docker istance:
### To start your Docker istance

```bash
easydock up
```

- To stop your Docker istance:
### To stop your Docker istance

```bash
easydock stop
```

- To restart your Docker istance:
### To restart your Docker istance

```bash
easydock restart
```

- To stop and delete your Docker istance:
### To stop and delete your Docker istance

```bash
easydock down
```

- To "SSH" into your Docker istance:
### To "SSH" into your Docker istance

```bash
easydock shell
```

- You can get application info using:
### You can get application info using

```bash
easydock info
```

- You can reset your Docker istance running:
### You can reset your Docker istance running

```bash
easydock reset
```

- Everytime you change PHP version into `.env.easydock` file you have to run:
### Everytime you change PHP version into `.env.easydock` file you have to run

```bash
easydock reset && easydock build
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "joglomedia/easydock-linux",
"type": "project",
"description": "A fork of EasyDock to work in Linux. Docker LEMP easy integration.",
"description": "A fork of EasyDock for Linux. Docker LEMP stack easy integration.",
"keywords": ["docker", "container", "lemp", "lnmp", "nginx", "php", "ubuntu", "debian"],
"license": "MIT",
"authors": [
Expand Down
5 changes: 1 addition & 4 deletions config/.env.easydock
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ APP_WORKER=1
APP_PORT=8008

# PHP VERSION
PHP_VERSION=8.0

# Nodejs Version
NODE_VERSION=12.18.4
PHP_VERSION=7.4

# MYSQL DB NAME
DB_NAME=easydockdb
Expand Down
4 changes: 4 additions & 0 deletions config/nginx/01-upstream.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
upstream php-fpm {
server webapp:9000;
#server unix:/var/run/php-fpm.sock;
}
16 changes: 9 additions & 7 deletions config/nginx/app.conf
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
server {
listen 80;
listen [::]:80;

server_name localhost;
server_name localhost localhost.localhost;

index index.html index.php;

error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

root /var/www/public;

client_max_body_size 256m;
index index.html index.php;

client_max_body_size 20M;
client_body_buffer_size 128k;
server_tokens off;

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_pass php-fpm; # passed to upstream server from 01-upstream.conf
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Expand Down
6 changes: 3 additions & 3 deletions config/php/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ display_errors = On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
date.timezone = UTC
max_execution_time = 360
memory_limit = 512M
post_max_size = 256M
upload_max_filesize = 256M
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 32M
36 changes: 36 additions & 0 deletions config/php/zz-docker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[global]
daemonize = no

; Redirect log to file.
;error_log = /var/log/php/php-fpm.log

[www]
;user = www-data
;group = www-data

; Listen via socket instead tcp port.
listen = 9000
;listen = /var/run/php-fpm.sock
;listen.owner = www
;listen.group = www
;listen.mode = 0666

; Custom PHP-FPM optimization here
; adjust to meet your needs.
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.process_idle_timeout = 30s
pm.max_requests = 500

; Redirect log to file.
;access.log = /var/log/php/php-fpm_access.log
;slowlog = /var/log/php/php-fpm_slow.log
;request_slowlog_timeout = 5s

; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
php_admin_flag[log_errors] = On
php_admin_value[error_log] = /var/log/php/php-fpm.log
18 changes: 11 additions & 7 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Dockerfile Args
ARG PHP_VERSION
ARG NODE_VERSION

# Use PHP image
FROM php:${PHP_VERSION}-fpm-alpine
Expand All @@ -12,7 +11,8 @@ LABEL maintainer Edi Septriyanto <[email protected]> architecture="amd64/x86_64"
WORKDIR /var/www

# Add PHP extension installer
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
/usr/local/bin/

# Install dependencies
RUN apk update && apk upgrade \
Expand Down Expand Up @@ -66,17 +66,21 @@ RUN apk update && apk upgrade \
# Install composer
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
# Install node & npm (not yet required for php application)
&& apk add --update nodejs=${NODE_VERSION} npm yarn \
&& apk add --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/main/ nodejs npm \
&& apk add --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/community/ yarn \
# Clean up install.
&& rm -rf /var/cache/apk/* \
# Add user
&& set -eux; \
addgroup -g 1000 -S www; \
adduser -u 1000 -h /var/www -s /bin/bash -D -S -G www www \
&& set -eux \
&& addgroup -g 1000 -S www \
&& adduser -u 1000 -h /var/www -s /bin/bash -D -S -G www www \
# User permissions
&& chown -R www:www /var/www
&& chown -R www:www /var/www

# Change current user to www
USER www

# Expose port 9000
EXPOSE 9000

CMD ["php-fpm"]
Loading

0 comments on commit 7ff22ec

Please sign in to comment.