Skip to content

Commit

Permalink
✨ Implement basic structure ant services.
Browse files Browse the repository at this point in the history
  • Loading branch information
ABGEO committed Apr 2, 2021
1 parent 87f3e5c commit 9b091de
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file is part of the Drups.io Docker.
#
# (c) 2021 Drups.io <[email protected]>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# Written by Temuri Takalandze <[email protected]>, April 2021

### PROJECT SETTINGS

PROJECT_NAME=drups

### URLS

PROJECT_BASE_URL=${PROJECT_NAME}.localhost
RABBITMQ_URL=rabbitmq.${PROJECT_BASE_URL}
TRAEFIK_URL=${PROJECT_BASE_URL}:8080

### CREDENTIALS

RABBITMQ_USER=guest
RABBITMQ_PASS=guest

### SERVICE VERSION TAGS

REDIS_TAG=6.2
RABBITMQ_TAG=3.8-management
79 changes: 79 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# This file is part of the Drups.io Docker.
#
# (c) 2021 Drups.io <[email protected]>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# Written by Temuri Takalandze <[email protected]>, April 2021

include .env

default: help

## help : Print commands help.
.PHONY: help
help : Makefile
@sed -n 's/^##//p' $<

## up : Start up containers.
.PHONY: up
up:
@echo "Starting up containers for $(PROJECT_NAME)..."
docker-compose pull
docker-compose up -d --remove-orphans
@make info

## down : Stop containers.
.PHONY: down
down: stop

## start : Start containers without updating.
.PHONY: start
start:
@echo "Starting containers for $(PROJECT_NAME) from where you left off..."
@docker-compose start
@make info

## stop : Stop containers.
.PHONY: stop
stop:
@echo "Stopping containers for $(PROJECT_NAME)..."
@docker-compose stop

## prune : Remove containers and their volumes.
## You can optionally pass an argument with the service name to prune single container
## prune engine : Prune `engine` container and remove its volumes.
## prune engine application : Prune `engine` and `application` containers and remove their volumes.
.PHONY: prune
prune:
@echo "Removing containers for $(PROJECT_NAME)..."
@docker-compose down -v $(filter-out $@,$(MAKECMDGOALS))

## ps : List running containers.
.PHONY: ps
ps:
@docker ps --filter name='$(PROJECT_NAME)*'

## info : Print stack info.
.PHONY: info
info:
@./scripts/info.sh

## shell : Access `engine` container via shell.
## You can optionally pass an argument with a service name to open a shell on the specified container
.PHONY: shell
shell:
docker exec -ti -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) $(shell docker ps --filter name='$(PROJECT_NAME)_$(or $(filter-out $@,$(MAKECMDGOALS)), 'engine')' --format "{{ .ID }}") sh

## logs : View containers logs.
## You can optinally pass an argument with the service name to limit logs
## logs engine : View `engine` container logs.
## logs engine application : View `engine` and `application` containers logs.
.PHONY: logs
logs:
@docker-compose logs -f $(filter-out $@,$(MAKECMDGOALS))

# https://stackoverflow.com/a/6273809/1826109
%:
@:
2 changes: 2 additions & 0 deletions apps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
engine/
application/
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This file is part of the Drups.io Docker.
#
# (c) 2021 Drups.io <[email protected]>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# Written by Temuri Takalandze <[email protected]>, April 2021

version: "3.7"

services:
rabbitmq:
image: rabbitmq:$RABBITMQ_TAG
container_name: "${PROJECT_NAME}_rabbitmq"
environment:
RABBITMQ_DEFAULT_USER: $RABBITMQ_USER
RABBITMQ_DEFAULT_PASS: $RABBITMQ_PASS
labels:
- "traefik.http.services.${PROJECT_NAME}_rabbitmq_management_ui.loadbalancer.server.port=15672"
- "traefik.http.routers.${PROJECT_NAME}_rabbitmq_management_ui.rule=Host(`${RABBITMQ_URL}`)"

redis:
image: redis:$REDIS_TAG
container_name: "${PROJECT_NAME}_redis"

traefik:
image: traefik:v2.0
container_name: "${PROJECT_NAME}_traefik"
command: --api.insecure=true --providers.docker
ports:
- '80:80'
- '8080:8080'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
20 changes: 20 additions & 0 deletions docker-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is part of the Drups.io Docker.
#
# (c) 2021 Drups.io <[email protected]>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# Written by Temuri Takalandze <[email protected]>, April 2021

version: "2"

syncs:
docker-sync-engine:
src: './apps/engine'
sync_userid: '501'
sync_excludes: ['.gitignore', '.git/', '.idea/']
docker-sync-application:
src: './apps/application'
sync_userid: '501'
sync_excludes: ['.gitignore', '.git/', '.idea/']
27 changes: 27 additions & 0 deletions scripts/info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# This file is part of the Drups.io Docker.
#
# (c) 2021 Drups.io <[email protected]>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# Written by Temuri Takalandze <[email protected]>, April 2021


DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

source "${DIR}"/../.env
source "${DIR}"/styles.env

echo -e "\n\
${COLOR_BLUE}${PROJECT_NAME} is ready!${COLOR_NONE}\v\
${COLOR_GREEN}\n RabbitMQ UI${COLOR_NONE}\t - ${COLOR_GREEN}http://${RABBITMQ_URL}${COLOR_NONE}\
${COLOR_GREEN}\n Traefik${COLOR_NONE}\t - ${COLOR_GREEN}http://${TRAEFIK_URL}${COLOR_NONE}\
${COLOR_BLUE}\n\vCredentials${COLOR_NONE}\
${COLOR_BLUE}\nRabbitMQ${COLOR_NONE}\
${COLOR_GREEN}\n Username\t${COLOR_NONE} - ${COLOR_GREEN}${RABBITMQ_USER}${COLOR_NONE}\
${COLOR_GREEN}\n Password\t${COLOR_NONE} - ${COLOR_GREEN}${RABBITMQ_PASS}${COLOR_NONE}"
14 changes: 14 additions & 0 deletions scripts/styles.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is part of the Drups.io Docker.
#
# (c) 2021 Drups.io <[email protected]>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# Written by Temuri Takalandze <[email protected]>, April 2021

### COLORS

COLOR_NONE='\033[00m'
COLOR_GREEN='\033[01;32m'
COLOR_BLUE='\033[1;36m'
27 changes: 27 additions & 0 deletions traefik.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file is part of the Drups.io Docker.
#
# (c) 2021 Drups.io <[email protected]>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# Written by Temuri Takalandze <[email protected]>, April 2021

version: '3'

services:
traefik:
image: traefik:v2.0
command: --api.insecure=true --providers.docker
networks:
- drups
ports:
- '80:80'
- '8080:8080'
volumes:
- /var/run/docker.sock:/var/run/docker.sock

networks:
drups:
external:
name: project1-dir_default

0 comments on commit 9b091de

Please sign in to comment.