Skip to content
Snippets Groups Projects
Commit f6f19884 authored by Dillenn Terumalai's avatar Dillenn Terumalai :speech_balloon:
Browse files

// WIP

parent 57059b55
No related branches found
No related tags found
No related merge requests found
.DS_Store
.vscode/
.idea/
vendor/
composer.lock
\ No newline at end of file
MIT License
Copyright (c) 2017 Shipping Docker
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.
\ No newline at end of file
# lumendock
# Lumendock
Minimalistic Lumen (PHP framework) development environment for Docker.
\ No newline at end of file
Minimalistic Lumen (PHP framework) development environment for Docker. This package is a fork of: https://github.com/shipping-docker/vessel for Lumen use.
## Install
Lumendock is just a small set of files that sets up a local Docker-based dev environment per project. There is nothing to install globally, except Docker itself!
This is all there is to using it:
```bash
composer require shipping-docker/vessel
cp -R vendor/shipping-docker/vessel/docker-files/{vessel,docker-compose.yml,docker} .
# Run this once to initialize project
# Must run with "bash" until initialized
bash vessel init
./lumendock start
```
Head to `http://localhost` in your browser and see your Laravel site!
## Common Commands
Here's a list of built-in helpers you can use. Any command not defined in the `vessel` script will default to being passed to the `docker-compose` command. If not command is used, it will run `docker-compose ps` to list the running containers for this environment.
### Show Lumendock Version or Help
```bash
# shows vessel current version
$ vessel --version # or [ -v | version ]
# shows vessel help
$ vessel --help # or [ -H | help ]
```
### Starting and Stopping Lumendock
```bash
# Start the environment
./lumendock start
## This is equivalent to
./lumendock up -d
# Stop the environment
./lumendock stop
## This is equivalent to
./lumendock down
```
### Development
```bash
# Use composer
./lumendock composer <cmd>
./lumendock comp <cmd> # "comp" is a shortcut to "composer"
# Use artisan
./lumendock artisan <cmd>
./lumendock art <cmd> # "art" is a shortcut to "artisan"
## What's included?
The aim of this project is simplicity. It includes:
* PHP 7.4-alpine
* MySQL 5.7
* NodeJS 6-alpine
## How does this work?
If you're unfamiliar with Docker, try out this [Docker in Development](https://serversforhackers.com/s/docker-in-development) course, which explains important topics in how this is put together.
If you want to see how this workflow was developed, check out [Shipping Docker](https://serversforhackers.com/shipping-docker) and signup for the free course module which explains building this Docker workflow.
## Supported Systems
Lumendock requires Docker, and currently only works on Windows, Mac and Linux.
> Windows requires running Hyper-V. Using Git Bash (MINGW64) and WSL are supported. Native
Windows is still under development.
| Mac | Linux | Windows |
| ------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------: |
| Install Docker on [Mac](https://docs.docker.com/docker-for-mac/install/) | Install Docker on [Debian](https://docs.docker.com/engine/installation/linux/docker-ce/debian/) | Install Docker on [Windows](https://docs.docker.com/docker-for-windows/install/) |
| | Install Docker on [Ubuntu](https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/) | |
| | Install Docker on [CentOS](https://docs.docker.com/engine/installation/linux/docker-ce/centos/) | |
\ No newline at end of file
{
"name": "dterumal/lumendock",
"description": "Minimalistic Lumen development environment for Docker",
"license": "MIT",
"authors": [
{
"name": "Dillenn Terumalai",
"email": "dillenn.terumalai@sib.swiss"
}
],
"autoload": {
"psr-4": {
"Lumendock\\": "src/"
}
},
"require": {},
"extra": {
"laravel": {
"providers": [
"Lumendock\\LumendockServiceProvider"
]
}
}
}
\ No newline at end of file
version: '2'
services:
# nginx:
# image: nginx:1.18-alpine
# ports:
# - "${APP_PORT}:80"
# volumes:
# - ./public:/var/www
# - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
# networks:
# - lumendock
php:
image: lorisleiva/laravel-docker:7.4
volumes:
- .:/var/www
ports:
- "${APP_PORT}:9000"
networks:
- lumendock
mail:
image: lorisleiva/laravel-docker:1.1.0
volumes:
- .:/var/www
ports:
- "${APP_PORT}:9000"
networks:
- lumendock
mysql:
image: mysql:5.7
ports:
- "${MYSQL_PORT}:3306"
environment:
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
MYSQL_DATABASE: "${DB_DATABASE}"
MYSQL_USER: "${DB_USERNAME}"
MYSQL_PASSWORD: "${DB_PASSWORD}"
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- lumendockmysql:/var/lib/mysql
networks:
- lumendock
networks:
lumendock:
driver: "bridge"
volumes:
lumendockmysql:
driver: "local"
\ No newline at end of file
server {
listen 80;
index index.php index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
#!/usr/bin/env bash
VERSION="1.0" # bumped to support lumendock --help, lumendock --version
# define colors that are used in the help screen
ESC_SEQ="\x1b["
COL_RESET=${ESC_SEQ}"39;49;00m"
COL_LYELLOW=${ESC_SEQ}"33;01m"
COL_LGREEN=${ESC_SEQ}"32;01m"
COL_CYAN=${ESC_SEQ}"0;36m"
COL_GREEN=${ESC_SEQ}"0;32m"
COL_MAGENTA=${ESC_SEQ}"0;35m"
CONTAINER_NGINX="nginx"
CONTAINER_PHP="php"
CONTAINER_MYSQL="mysql"
UNAMEOUT="$(uname -s)"
case "${UNAMEOUT}" in
Linux*) MACHINE=linux;;
Darwin*) MACHINE=mac;;
MINGW64_NT-10.0*) MACHINE=mingw64;;
*) MACHINE="UNKNOWN"
esac
if [ "$MACHINE" == "UNKNOWN" ]; then
echo "Unsupported system type"
echo "System must be a Macintosh, Linux or Windows"
echo ""
echo "System detection determined via uname command"
echo "If the following is empty, could not find uname command: $(which uname)"
echo "Your reported uname is: $(uname -s)"
fi
# Set environment variables for dev
if [ "$MACHINE" == "linux" ]; then
SEDCMD="sed -i"
elif [ "$MACHINE" == "mac" ]; then
SEDCMD="sed -i .bak"
elif [ "$MACHINE" == "mingw64" ]; then # Git Bash
SEDCMD="sed -i"
fi
export APP_PORT=${APP_PORT:-80}
export MAIL_PORT=${MAIL_PORT:-1080}
export MYSQL_PORT=${MYSQL_PORT:-3306}
export WWWUSER=${WWWUSER:-$UID}
showVersion() {
intro="\n🐳 ${COL_GREEN}Lumendock for Docker${COL_RESET}\n"
intro="$intro ${COL_CYAN}Version ${VERSION}\n${COL_RESET}"
printf "$intro"
}
showHelp() {
showVersion
usage="${COL_LYELLOW}Usage:\n${COL_RESET}"
usage="$usage ./lumendock <cmd> <options>"
commands="${COL_LYELLOW}Commands:\n${COL_RESET}"
commands="$commands art | artisan <cmd> Run Laravel Artisan CLI in ${COL_MAGENTA}${CONTAINER_APP}${COL_RESET} container\n"
commands="$commands composer <cmds> Run Composer in ${COL_MAGENTA}${CONTAINER_APP}${COL_RESET} container\n"
commands="$commands mysql Run MySQL CLI in ${COL_MAGENTA}${CONTAINER_MYSQL}${COL_RESET} container\n"
commands="$commands help Shows Help screen\n"
commands="$commands ps Display list of all running containers in current directory\n"
commands="$commands start < -l > Starts all containers defined in ${COL_LGREEN}docker-compose.yml${COL_RESET} file\n"
commands="$commands stop Stops all containers defined in ${COL_LGREEN}docker-compose.yml${COL_RESET} file\n"
options="${COL_LYELLOW}Options:\n${COL_RESET}"
options="$options --help, -h Shows Help (this screen)\n"
# options="$options --logs, -l Run containers in detached mode (with logging)\n"
options="$options --version, -V, version Show Version\n"
examples="${COL_LYELLOW}Examples:\n${COL_RESET}"
examples="$examples ${COL_CYAN}$ ./lumendock start${COL_RESET}\n"
examples="$examples ${COL_CYAN}$ ./lumendock stop${COL_RESET}\n"
examples="$examples ${COL_CYAN}$ ./lumendock composer require <vendor/package>${COL_RESET}\n"
examples="$examples ${COL_CYAN}$ ./lumendock mysql${COL_RESET}\n"
examples="$examples ${COL_CYAN}$ ./lumendock artisan migrate --seed${COL_RESET}\n"
examples="$examples ${COL_CYAN}$ ./lumendock art db:seed${COL_RESET}\n"
printf "\n"
printf "$usage\n\n"
printf "$commands\n"
printf "$options\n"
printf "$examples\n"
}
# Is the environment running
PSRESULT="$(docker-compose ps -q)"
if [ ! -z "$PSRESULT" ]; then
EXEC="yes"
else
EXEC="no"
fi
# Create base docker-compose command to run
COMPOSE="docker-compose"
# If we pass any arguments...
if [ $# -gt 0 ]; then
# Source .env, which can over-ride env vars
# such as APP_PORT, MYSQL_PORT, and WWWUSER
if [ -f .env ]; then
source .env
fi
if [ "$1" == "--version" ] || [ "$1" == "-v" ] || [ "$1" == "version" ]; then
showVersion
exit 1
fi
if [ "$1" == "--help" ] || [ "$1" == "-H" ] || [ "$1" == "help" ]; then
showHelp
exit 1
fi
# Edit .env file to set correct hostnames for mysql/redis
if [ "$1" == "init" ]; then
echo "LUMENDOCK: Initializing Lumendock..."
COMPOSER=$(which composer)
if [ ! -f .env ]; then
echo "No .env file found within current working directory $(pwd)"
echo "Create a .env file before re-initializing"
exit 0
fi
echo "LUMENDOCK: Setting .env Variables"
cp .env .env.bak.lumendock
if [ ! -z "$(grep "DB_HOST" .env)" ]; then
$SEDCMD "s/DB_HOST=.*/DB_HOST=mysql/" .env
else
echo "DB_HOST=mysql" >> .env
fi
if [ -f .env.bak ]; then
rm .env.bak
fi
if [ ! -f lumendock ]; then
echo "No lumendock file found within current working directory $(pwd)"
echo "Have you run the artisan vendor:publish command yet?"
exit 0
fi
echo "LUMENDOCK: Making lumendock command available"
chmod +x lumendock
echo ""
echo "LUMENDOCK: Complete!"
echo "LUMENDOCK: You can now use Lumendock"
echo "LUMENDOCK: Try starting it:"
echo "./lumendock start"
# Start up containers
elif [ "$1" == "start" ]; then
$COMPOSE up -d
# Stop the containers
elif [ "$1" == "stop" ]; then
$COMPOSE down
# If "art" is used, pass-thru to "artisan"
# inside a new container
elif [ "$1" == "artisan" ] || [ "$1" == "art" ]; then
shift 1
if [ "$EXEC" == "yes" ]; then
$COMPOSE exec \
-u lumendock \
app \
php artisan "$@"
else
$COMPOSE run --rm \
app \
php artisan "$@"
fi
# If "composer" is used, pass-thru to "composer"
# inside a new container
elif [ "$1" == "composer" ] || [ "$1" == "comp" ]; then
shift 1
if [ "$EXEC" == "yes" ]; then
$COMPOSE exec \
-u lumendock \
app \
composer "$@"
else
$COMPOSE run --rm \
app \
composer "$@"
fi
# If "mysql" is used, run mysql
# from our mysql container
elif [ "$1" == "mysql" ]; then
shift 1
if [ "$EXEC" == "yes" ]; then
$COMPOSE exec \
mysql \
bash -c 'MYSQL_PWD=$MYSQL_ROOT_PASSWORD mysql -u root $MYSQL_DATABASE'
else
echo "Error: This command can only be run while a MySQL container is running mysqld (mysql server)."
echo "This command cannot run the server and the mysql client at the same time."
fi
# Else, pass-thru args to docker-compose
else
$COMPOSE "$@"
fi
else
# Use the docker-compose ps command if nothing else passed through
$COMPOSE ps
fi
<?php
namespace Lumendock;
use Illuminate\Support\ServiceProvider;
class LumendockServiceProvider extends ServiceProvider {
public function boot()
{
$this->publishes([
LUMENDOCK_PATH.'/docker-files/docker' => base_path('docker'),
LUMENDOCK_PATH.'/docker-files/docker-compose.yml' => base_path('docker-compose.yml'),
LUMENDOCK_PATH.'/docker-files/lumendock' => base_path('lumendock'),
]);
}
public function register()
{
if (! defined('LUMENDOCK_PATH')) {
define('LUMENDOCK_PATH', realpath(__DIR__.'/../'));
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment