Skip to content

Commit 6837e9f

Browse files
author
dmitriy
committed
docker-nginx-php-laravel environment done
0 parents  commit 6837e9f

File tree

115 files changed

+13848
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+13848
-0
lines changed

.circleci/config.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: 2
2+
jobs:
3+
build:
4+
working_directory: ~/html
5+
machine: true
6+
branches:
7+
ignore:
8+
- develop
9+
steps:
10+
- checkout
11+
12+
- run:
13+
name: Start container and verify it's working
14+
command: |
15+
make start-ci
16+
17+
- run:
18+
name: Wait for DB container is running and initialize DB
19+
command: |
20+
make wait-for-db
21+
make drop-migrate
22+
make seed
23+
24+
- run:
25+
name: Run unit/functional tests
26+
command: |
27+
make phpunit
28+
29+
- store_artifacts:
30+
path: reports
31+
32+
- store_test_results:
33+
path: reports

.dockerignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/.git*
2+
/.idea*
3+
#docker/
4+
storage/mysql-data
5+
vendor/
6+
bootstrap/cache
7+
!bootstrap/cache/.gitignore
8+
.dockerignore
9+
.editorconfig
10+
.phpstorm.meta.php
11+
Dockerfile
12+
_ide_helper.php
13+
docker-compose.yml
14+
docker-compose-ci.yml
15+
docker-compose-prod.yml
16+
Makefile

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.yml]
15+
indent_size = 2

.env.example

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
9+
DB_CONNECTION=mysql
10+
DB_HOST=127.0.0.1
11+
DB_PORT=3306
12+
DB_DATABASE=homestead
13+
DB_USERNAME=homestead
14+
DB_PASSWORD=secret
15+
16+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
QUEUE_CONNECTION=sync
19+
SESSION_DRIVER=file
20+
SESSION_LIFETIME=120
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
33+
PUSHER_APP_ID=
34+
PUSHER_APP_KEY=
35+
PUSHER_APP_SECRET=
36+
PUSHER_APP_CLUSTER=mt1
37+
38+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
39+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.env.local

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=base64:KgeWah2LwOk5HLjCYuIZjaQQwX59ASqUjCKZMD6H4Ew=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
9+
DB_CONNECTION=mysql
10+
DB_HOST=mysql
11+
DB_PORT=3306
12+
DB_DATABASE=laravel
13+
DB_USERNAME=root
14+
DB_PASSWORD=secret
15+
16+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
QUEUE_CONNECTION=sync
19+
SESSION_DRIVER=file
20+
SESSION_LIFETIME=120
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
33+
PUSHER_APP_ID=
34+
PUSHER_APP_KEY=
35+
PUSHER_APP_SECRET=
36+
PUSHER_APP_CLUSTER=mt1
37+
38+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
39+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.env.prod

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME=Laravel
2+
APP_ENV=production
3+
APP_KEY=
4+
APP_DEBUG=false
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
9+
DB_CONNECTION=mysql
10+
DB_HOST=mysql
11+
DB_PORT=3306
12+
DB_DATABASE=laravel
13+
DB_USERNAME=root
14+
DB_PASSWORD=secret
15+
16+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
QUEUE_CONNECTION=sync
19+
SESSION_DRIVER=file
20+
SESSION_LIFETIME=120
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
33+
PUSHER_APP_ID=
34+
PUSHER_APP_KEY=
35+
PUSHER_APP_SECRET=
36+
PUSHER_APP_CLUSTER=mt1
37+
38+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
39+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.env.testing

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME=Laravel
2+
APP_ENV=testing
3+
APP_KEY=base64:KgeWah2LwOk5HLjCYuIZjaQQwX59ASqUjCKZMD6H4Ew=
4+
APP_DEBUG=false
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
9+
DB_CONNECTION=mysql
10+
DB_HOST=mysql
11+
DB_PORT=3306
12+
DB_DATABASE=laravel_testing
13+
DB_USERNAME=root
14+
DB_PASSWORD=secret
15+
16+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
QUEUE_CONNECTION=sync
19+
SESSION_DRIVER=file
20+
SESSION_LIFETIME=120
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
33+
PUSHER_APP_ID=
34+
PUSHER_APP_KEY=
35+
PUSHER_APP_SECRET=
36+
PUSHER_APP_CLUSTER=mt1
37+
38+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
39+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/.idea
2+
/.vscode
3+
/.vagrant
4+
/node_modules
5+
/public/hot
6+
/public/storage
7+
/storage/*.key
8+
/storage/mysql-data/
9+
/vendor
10+
Homestead.yaml
11+
Homestead.json
12+
.env
13+
_ide_helper.php
14+
.phpstorm.meta.php
15+
_ide_helper_models.php
16+
reports/*
17+
!reports/.gitkeep
18+
npm-debug.log
19+
yarn-error.log
20+
.phpunit.result.cache

Dockerfile

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
FROM php:7.3-fpm
2+
3+
# set main params
4+
ARG BUILD_ARGUMENT_DEBUG_ENABLED=false
5+
ENV DEBUG_ENABLED=$BUILD_ARGUMENT_DEBUG_ENABLED
6+
ARG BUILD_ARGUMENT_APP_ENV=development
7+
ENV APP_ENV=$BUILD_ARGUMENT_APP_ENV
8+
ARG BUILD_ARGUMENT_ENV_FILE=.env.local
9+
ENV ENV_FILE=$BUILD_ARGUMENT_ENV_FILE
10+
ENV APP_HOME /var/www/html
11+
12+
# check environment
13+
RUN if [ "$BUILD_ARGUMENT_APP_ENV" = "default" ]; then echo "Set BUILD_ARGUMENT_APP_ENV in docker build-args like --build-arg BUILD_ARGUMENT_APP_ENV=development" && exit 2; \
14+
elif [ "$BUILD_ARGUMENT_APP_ENV" = "development" ]; then echo "Building development environment."; \
15+
elif [ "$BUILD_ARGUMENT_APP_ENV" = "production" ]; then echo "Building production environment."; \
16+
else echo "Set correct BUILD_ARGUMENT_APP_ENV in docker build-args like --build-arg BUILD_ARGUMENT_APP_ENV=development. Available choices are development,production." && exit 2; \
17+
fi
18+
19+
# install all the dependencies and enable PHP modules
20+
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
21+
procps \
22+
nano \
23+
git \
24+
unzip \
25+
libicu-dev \
26+
zlib1g-dev \
27+
libxml2 \
28+
libxml2-dev \
29+
libreadline-dev \
30+
supervisor \
31+
cron \
32+
libzip-dev \
33+
&& docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
34+
&& docker-php-ext-install \
35+
pdo_mysql \
36+
intl \
37+
zip && \
38+
rm -fr /tmp/* && \
39+
rm -rf /var/list/apt/* && \
40+
rm -r /var/lib/apt/lists/* && \
41+
apt-get clean
42+
43+
# create document root
44+
RUN mkdir -p $APP_HOME/public
45+
46+
# change owner
47+
RUN chown -R www-data:www-data $APP_HOME
48+
49+
# put php config for Laravel
50+
COPY ./docker/$BUILD_ARGUMENT_APP_ENV/www.conf /usr/local/etc/php-fpm.d/www.conf
51+
COPY ./docker/$BUILD_ARGUMENT_APP_ENV/php.ini /usr/local/etc/php/php.ini
52+
53+
# install Xdebug in case development environment
54+
COPY ./docker/other/do_we_need_xdebug.sh /tmp/
55+
COPY ./docker/development/xdebug.ini /tmp/
56+
RUN chmod u+x /tmp/do_we_need_xdebug.sh && /tmp/do_we_need_xdebug.sh $BUILD_ARGUMENT_APP_ENV
57+
58+
# install composer
59+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
60+
61+
# add supervisor
62+
RUN mkdir -p /var/log/supervisor
63+
COPY --chown=root:root ./docker/other/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
64+
COPY --chown=root:root ./docker/other/cron /var/spool/cron/crontabs/root
65+
RUN chmod 0600 /var/spool/cron/crontabs/root
66+
67+
# set working directory
68+
WORKDIR $APP_HOME
69+
70+
# create composer folder for user www-data
71+
RUN mkdir -p /var/www/.composer && chown -R www-data:www-data /var/www/.composer
72+
73+
USER www-data
74+
75+
# copy source files and config file
76+
COPY --chown=www-data:www-data . $APP_HOME/
77+
COPY --chown=www-data:www-data $ENV_FILE $APP_HOME/.env
78+
79+
# install all PHP dependencies
80+
RUN if [ "$BUILD_ARGUMENT_APP_ENV" = "development" ]; then composer install --no-interaction --no-progress; \
81+
else composer install --no-interaction --no-progress --no-dev; \
82+
fi
83+
84+
USER root

0 commit comments

Comments
 (0)