-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rafael Grigorian
committed
Aug 3, 2018
0 parents
commit 1227fe3
Showing
33 changed files
with
7,611 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docs/*.png filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
/.docker-sync/ | ||
/public_html/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The MIT License (MIT) | ||
Copyright 2018-present JetRails® | ||
|
||
* * * | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Docker Magento Alpine | ||
> Docker development environment for staging Magento 2 on Alpine 3.6 | ||
![](https://img.shields.io/badge/Version-1.0.0-lightgray.svg?style=for-the-badge) | ||
![](https://img.shields.io/badge/License-MIT-lightgray.svg?style=for-the-badge) | ||
![](https://img.shields.io/badge/Magento-2-lightgray.svg?style=for-the-badge) | ||
|
||
<img src="docs/images/preview.png" width="400px" /> | ||
|
||
## Disclaimer | ||
|
||
The docker containers within this repository were build for development purposes only and should **NOT** be used in production. This product is licensed under the [MIT LICENSE](LICENSE.md) and comes with no warranty, use at your own risk. | ||
|
||
## Getting Started | ||
|
||
Using shared volumes on MacOS with Docker is painfully slow. That is why we use **docker-sync** for sharing volumes with and between docker containers. While this solution has a slightly longer up time, it makes up for it when the containers are started. We also use **docker-compose** to build/run our docker containers because of it's simplicity. Sample _docker-compose.yml_ and _docker-sync.yml_ files can be found in the [dist](dist) directory. Assuming that your Magento 2 installation lives in _public_html_ of your project folder, you can start docker-sync and run the docker containers using the following sequence of commands: | ||
|
||
```shell | ||
docker-sync start | ||
docker-compose up -d | ||
``` | ||
|
||
Shutting them down is just as easy: | ||
|
||
```shell | ||
docker-compose down | ||
docker-sync stop | ||
docker-sync clean | ||
``` | ||
|
||
## Environmental Variables | ||
|
||
All docker containers, except for _php-cli-7.1_, have the ability to tail their container's relevant logs if the `VERBOSE=true` flag is passed as an environmental variable. Passing it to the container is optional since by default `VERBOSE=false`. It is explicitly stated within the sample _docker-compose.yml_ file for documentation purposes only. Please also note that you will only be able to see the verbose output of these containers if you run docker-compose without the _detach_ flag, i.e. `docker-compose up`. | ||
|
||
### mysql | ||
Below are the possible environment variable that can be passed to the _mysql_ docker container with some sample values. If non are passed, then only the _root_ user will exist with the default password of _mysql_. | ||
- `MYSQL_ROOT_PASSWORD=mysql` | ||
- `MYSQL_USER_NAME=magento_db_user` | ||
- `MYSQL_USER_PASSWORD=password123` | ||
- `MYSQL_DATABASE=magento` | ||
|
||
## Build Process | ||
|
||
Building our docker containers is easy since we use docker-compose to do it for us. Simply run `docker-compose -f build.yml build` to build the docker containers from source. Once built, and with permissions, feel free to push them to docker using `docker push jetrails/magento-alpine:<tag>`. | ||
|
||
## Issues / Feature Requests | ||
|
||
If any issues come up or any feature are requested, please feel free to open up an issue through Github. For all other inquiries, feel free to email us at development@jetrails.com. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: "2" | ||
|
||
services: | ||
php-fpm: | ||
image: jetrails/magento-alpine:php-fpm-7.1 | ||
build: src/php-fpm-7.1 | ||
php-cli: | ||
image: jetrails/magento-alpine:php-cli-7.1 | ||
build: src/php-cli-7.1 | ||
php-cron: | ||
image: jetrails/magento-alpine:php-cron-7.1 | ||
build: src/php-cron-7.1 | ||
nginx: | ||
image: jetrails/magento-alpine:nginx | ||
build: src/nginx | ||
mysql: | ||
image: jetrails/magento-alpine:mysql | ||
build: src/mysql | ||
varnish: | ||
image: jetrails/magento-alpine:varnish | ||
build: src/varnish | ||
redis: | ||
image: jetrails/magento-alpine:redis | ||
build: src/redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
version: "2" | ||
|
||
volumes: | ||
database: | ||
app-sync: | ||
external: true | ||
networks: | ||
default: | ||
driver: bridge | ||
ipam: | ||
config: | ||
- subnet: "192.168.7.0/28" | ||
services: | ||
php-fpm: | ||
image: jetrails/magento-alpine:php-fpm-7.1 | ||
restart: unless-stopped | ||
volumes: | ||
- app-sync:/var/www/html:rw | ||
networks: | ||
default: | ||
aliases: | ||
- php-fpm.docker.internal | ||
environment: | ||
- VERBOSE=false | ||
links: | ||
- mysql | ||
- redis | ||
php-cli: | ||
image: jetrails/magento-alpine:php-cli-7.1 | ||
volumes: | ||
- app-sync:/var/www/html:rw | ||
networks: | ||
default: | ||
aliases: | ||
- php-cli.docker.internal | ||
links: | ||
- mysql | ||
- redis | ||
php-cron: | ||
image: jetrails/magento-alpine:php-cron-7.1 | ||
restart: unless-stopped | ||
volumes: | ||
- app-sync:/var/www/html:rw | ||
networks: | ||
default: | ||
aliases: | ||
- php-cron.docker.internal | ||
environment: | ||
- VERBOSE=false | ||
links: | ||
- mysql | ||
- redis | ||
nginx: | ||
image: jetrails/magento-alpine:nginx | ||
restart: unless-stopped | ||
volumes: | ||
- app-sync:/var/www/html:rw | ||
networks: | ||
default: | ||
aliases: | ||
- nginx.docker.internal | ||
environment: | ||
- VERBOSE=false | ||
links: | ||
- php-fpm | ||
ports: | ||
- "443:443" | ||
mysql: | ||
image: jetrails/magento-alpine:mysql | ||
restart: unless-stopped | ||
volumes: | ||
- database:/var/lib/mysql | ||
networks: | ||
default: | ||
aliases: | ||
- localhost | ||
- mysql.docker.internal | ||
environment: | ||
- VERBOSE=false | ||
- MYSQL_ROOT_PASSWORD=magento | ||
- MYSQL_USER_NAME=magento | ||
- MYSQL_USER_PASSWORD=magento | ||
- MYSQL_DATABASE=magento | ||
varnish: | ||
image: jetrails/magento-alpine:varnish | ||
restart: unless-stopped | ||
environment: | ||
- VERBOSE=false | ||
networks: | ||
default: | ||
aliases: | ||
- varnish.docker.internal | ||
links: | ||
- nginx | ||
ports: | ||
- "80:80" | ||
redis: | ||
image: jetrails/magento-alpine:redis | ||
restart: unless-stopped | ||
networks: | ||
default: | ||
aliases: | ||
- redis.docker.internal | ||
environment: | ||
- VERBOSE=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: "2" | ||
|
||
syncs: | ||
app-sync: | ||
src: "./public_html" | ||
sync_userid: 1000 | ||
sync_groupid: 1000 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM alpine:3.6 | ||
LABEL maintainer development@jetrails.com | ||
|
||
RUN apk --update --no-cache add \ | ||
shadow \ | ||
mysql \ | ||
mysql-client | ||
|
||
RUN mkdir -p /var/log/mysql && \ | ||
touch /var/log/mysql/mysql_error.log | ||
|
||
COPY ./bin/startup.sh /usr/local/bin/startup.sh | ||
COPY ./conf/my.cnf /etc/mysql/my.cnf | ||
|
||
EXPOSE 3306 | ||
WORKDIR var/lib/mysql | ||
CMD [ "sh", "/usr/local/bin/startup.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env sh | ||
|
||
if [ ! -f /var/lib/mysql/installed ]; then | ||
mysql_install_db --user=root > /dev/null && \ | ||
touch /var/lib/mysql/installed | ||
|
||
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-mysql} | ||
MYSQL_DATABASE=${MYSQL_DATABASE:-""} | ||
MYSQL_USER_NAME=${MYSQL_USER_NAME:-""} | ||
MYSQL_USER_PASSWORD=${MYSQL_USER_PASSWORD:-""} | ||
|
||
query=$(mktemp) | ||
|
||
echo -en \ | ||
"FLUSH PRIVILEGES;\n" \ | ||
"GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION;\n" \ | ||
"UPDATE mysql.user SET password=PASSWORD('') WHERE user='root' AND host='localhost';\n" \ | ||
> $query | ||
|
||
if [ -n "$MYSQL_DATABASE" ]; then | ||
echo -en \ | ||
"CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE;\n" \ | ||
>> $query | ||
fi | ||
|
||
if [ -n "$MYSQL_USER_NAME" ] && [ -n "$MYSQL_USER_PASSWORD" ]; then | ||
echo -en \ | ||
"GRANT ALL ON *.* TO '$MYSQL_USER_NAME'@'%' IDENTIFIED BY '$MYSQL_USER_PASSWORD';\n" \ | ||
>> $query | ||
fi | ||
|
||
mysqld --user=root --bootstrap < $query | ||
rm -f $query | ||
fi | ||
|
||
if [[ "$VERBOSE" == "true" ]]; then | ||
/var/log/mysql/*.log & | ||
fi | ||
|
||
exec mysqld --user=root --console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[client] | ||
port = 3306 | ||
socket = /run/mysqld.sock | ||
|
||
[mysqld] | ||
port = 3306 | ||
socket = /run/mysqld.sock | ||
skip-external-locking | ||
key_buffer_size = 16M | ||
max_allowed_packet = 1M | ||
table_open_cache = 64 | ||
sort_buffer_size = 512K | ||
net_buffer_length = 8K | ||
read_buffer_size = 256K | ||
read_rnd_buffer_size = 512K | ||
myisam_sort_buffer_size = 8M | ||
log-bin=mysql-bin | ||
binlog_format=mixed | ||
server-id = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM alpine:3.6 | ||
LABEL maintainer development@jetrails.com | ||
|
||
RUN apk --update --no-cache add \ | ||
shadow \ | ||
openssl \ | ||
nginx | ||
|
||
RUN usermod -u 1000 nginx && \ | ||
groupmod -g 1000 nginx | ||
|
||
RUN mkdir -p /var/www/ssl && \ | ||
openssl req \ | ||
-x509 \ | ||
-nodes \ | ||
-days 365 \ | ||
-newkey rsa:2048 \ | ||
-out /var/www/ssl/nginx.crt \ | ||
-keyout /var/www/ssl/nginx.key \ | ||
-subj "/C=US/ST=IL/L= /O= /OU= /CN= " | ||
|
||
COPY ./bin/startup.sh /usr/local/bin/startup.sh | ||
COPY ./conf/nginx.conf /etc/nginx/nginx.conf | ||
COPY ./conf/http.conf /etc/nginx/conf.d/http.conf | ||
COPY ./conf/https.conf /etc/nginx/conf.d/https.conf | ||
|
||
EXPOSE 8080 443 | ||
WORKDIR /var/www/html | ||
CMD [ "sh", "/usr/local/bin/startup.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env sh | ||
|
||
if [[ "$VERBOSE" == "true" ]]; then | ||
tail -f /var/log/nginx/*.log & | ||
fi | ||
|
||
chown -R nginx:nginx /var/www | ||
nginx -g 'daemon off;' |
Oops, something went wrong.