Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .dev/docker-compose.tests.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
version: "3.9"

services:
leantime-dev:
volumes:
- "../:/var/www/html"
- "./xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
- "./error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini"
- ${PWD}/test.env:/var/www/html/config/.env
- "${PWD}:/var/www/html"
- "${PWD}/.dev/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
- "${PWD}/.dev/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini"
- "${PWD}/.dev/test.env:/var/www/html/config/.env"

db:
environment:
MYSQL_DATABASE: leantime_test
Expand Down
50 changes: 50 additions & 0 deletions .dev/docker-compose.tools.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
x-tool-service: &tool-service
profiles: ["tools"]
working_dir: "/app"
volumes:
- "${PWD}:/app"

services:
composer:
<<: *tool-service
image: composer
container_name: leantime-composer
environment:
COMPOSER_IGNORE_PLATFORM_REQS: 1

php:
profiles: ["tools"]
build: .
container_name: leantime-php
working_dir: "/var/www/html"
volumes:
- "${PWD}:/var/www/html"
- "./xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
- "./error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini"

npm:
<<: *tool-service
container_name: leantime-npm
image: node:lts-alpine
entrypoint: ["npm"]

npx:
<<: *tool-service
container_name: leantime-npx
image: node:lts-alpine
entrypoint: ["npx"]

selenium:
<<: *tool-service
container_name: leantime-selenium
image: selenium/standalone-firefox:latest
ports:
- "4444:4444"
- "7900:7900"

codeception:
<<: *tool-service
container_name: leantime-codeception
depends_on:
- selenium
image: codeception/codeception:latest
25 changes: 17 additions & 8 deletions .dev/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
version: "3.9"
networks:
leantime:
external: false
driver: bridge
external: false
driver: bridge

volumes:
mysql:
s3ninja-data:

services:
leantime-dev:
container_name: leantime-dev
privileged: true
build: .
ports:
- "8090:8080"
- "127.0.0.1:8090:8080"
volumes:
- "../:/var/www/html"
- "./xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
- "./error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini"
- ".env:/var/www/html/config/.env"
- "${PWD}:/var/www/html"
- "${PWD}/.dev/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
- "${PWD}/.dev/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini"
- "${PWD}/.dev/.env:/var/www/html/config/.env"
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
db:
condition: service_healthy
networks:
- leantime

db:
image: mysql:8.0
container_name: db
ports:
- 3306:3306
environment:
Expand All @@ -43,26 +46,32 @@ services:
interval: 5s
timeout: 5s
retries: 20

maildev:
image: maildev/maildev
container_name: maildev
environment:
- MAILDEV_SMTP_PORT=465
- MAILDEV_WEB_PORT=8081
ports:
- 8081:8081
networks:
- leantime

phpmyadmin:
image: phpmyadmin
container_name: phpmyadmin
ports:
- 8082:80
environment:
- PMA_HOST=db
- PMA_PORT=3306
networks:
- leantime

s3ninja:
image: scireum/s3-ninja
container_name: s3ninja
ports:
- 8083:9000
networks:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ There are two ways to install a development setup of LeanTime. The first (but mo

#### Development Installation via Docker ####

For development, we use a dockerized development environment. You will need to have ``docker``, ``docker compose``, ``make``, ``composer``, ``git`` and ``npm`` installed.
For development, we use a dockerized development environment. You will need to have ``docker``, ``docker compose``, and ``make`` installed.

* Notes for Windows Environments:
- Run all commands within the git bash terminal in order to utilize unix specific commands
Expand Down
110 changes: 75 additions & 35 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
export COMPOSE_PROJECT_NAME=leantime-make

VERSION := $(shell grep "appVersion" ./app/Core/AppSettings.php |awk -F' = ' '{print substr($$2,2,length($$2)-3)}')
TARGET_DIR:= ./target/leantime
DOCS_DIR:= ./builddocs
DOCS_REPO:= git@github.com:Leantime/docs.git
RUNNING_DOCKER_CONTAINERS:= $(shell docker ps -a -q)
RUNNING_DOCKER_VOLUMES:= $(shell docker volume ls -q)
TARGET_DIR := ./target/leantime
DOCS_DIR := ./builddocs
DOCS_REPO := git@github.com:Leantime/docs.git
RUNNING_DOCKER_CONTAINERS := $(shell docker compose ps -a -q)
RUNNING_DOCKER_VOLUMES := $(shell docker volume ls -q)
UID := $(shell id -u)
GID := $(shell id -g)

# Base compose file
COMPOSE_FILES := -f .dev/docker-compose.yaml

# If local docker-compose file exists, add it to the command
ifneq ("$(wildcard .dev/docker-compose.local.yaml)","")
COMPOSE_FILES += " -f .dev/docker-compose.local.yaml"
endif

# Compose files for tests
COMPOSE_FILES_TEST := $(COMPOSE_FILES) -f .dev/docker-compose.tests.yaml

# Command aliases for running tools in docker
run-tool := docker compose -f .dev/docker-compose.tools.yaml run --rm --user "$(UID):$(GID)"
run-composer := $(run-tool) composer
run-npx := $(run-tool) npx
run-npm := $(run-tool) npm
run-php := $(run-tool) php
run-codeception := $(run-tool) codeception

# Alias for running SQL against the test database
run-sql-test := docker compose $(COMPOSE_FILES_TEST) exec -T db mysql -hlocalhost -P3307 -uroot -pleantime -e

install-deps-dev:
npm install --only=dev
composer install --optimize-autoloader
$(run-npm) install --only=dev
$(run-composer) install --optimize-autoloader

install-deps:
npm install
composer install --no-dev --optimize-autoloader
$(run-npm) install
$(run-composer) install --no-dev --optimize-autoloader

build: install-deps
npx mix --production
$(run-npx) mix --production

build-dev: install-deps-dev
npx mix --production
$(run-npx) mix --production

package: clean build
mkdir -p $(TARGET_DIR)
Expand Down Expand Up @@ -84,7 +110,7 @@ gendocs: # Requires github CLI (brew install gh)

# Generate the docs
phpDocumentor
php vendor/bin/leantime-documentor parse app --format=markdown --template=templates/markdown.php --output=builddocs/technical/hooks.md --memory-limit=-1
$(run-php) vendor/bin/leantime-documentor parse app --format=markdown --template=templates/markdown.php --output=builddocs/technical/hooks.md --memory-limit=-1

# create pull request
cd $(DOCS_DIR) && git switch -c "release/$(VERSION)"
Expand All @@ -96,38 +122,52 @@ gendocs: # Requires github CLI (brew install gh)
# Delete the temporary docs directory
rm -rf $(DOCS_DIR)


clean:
rm -rf $(TARGET_DIR)

run-dev: build-dev
cd .dev && docker-compose up --build --remove-orphans
docker-clean:
docker compose $(COMPOSE_FILES) down -v

acceptance-test: build-dev
php vendor/bin/codecept run Acceptance --steps
docker-clean-test:
docker compose $(COMPOSE_FILES_TEST) down -v

acceptance-test-ci: build-dev
php vendor/bin/codecept build
ifeq ($(strip $(RUNNING_DOCKER_CONTAINERS)),)
@echo "No running docker containers found"
else
docker rm -f $(RUNNING_DOCKER_CONTAINERS)
endif
ifeq ($(strip $(RUNNING_DOCKER_VOLUMES)),)
@echo "No running docker volumes found"
else
docker volume rm $(RUNNING_DOCKER_VOLUMES)
endif
php vendor/bin/codecept run Acceptance --steps
run-dev: build-dev docker-clean
docker compose $(COMPOSE_FILES) up -d --build --remove-orphans
make set-folder-permissions

stop-dev:
make docker-clean

run-test: build-dev docker-clean-test
docker compose $(COMPOSE_FILES_TEST) up -d --build --remove-orphans
make set-folder-permissions

stop-test:
make docker-clean-test

acceptance-test: run-test create-test-database
$(run-php) ./vendor/bin/codecept run Acceptance --steps
make stop-test

acceptance-test-ci: run-test create-test-database
$(run-codeception) build
$(run-codeception) run Acceptance --steps
make stop-test

codesniffer:
./vendor/squizlabs/php_codesniffer/bin/phpcs app
$(run-php) ./vendor/squizlabs/php_codesniffer/bin/phpcs app

codesniffer-fix:
./vendor/squizlabs/php_codesniffer/bin/phpcbf app
$(run-php) ./vendor/squizlabs/php_codesniffer/bin/phpcbf app

get-version:
@echo $(VERSION)
create-test-database: run-test
$(run-sql-test) "DROP DATABASE IF EXISTS leantime_test;"
$(run-sql-test) "CREATE DATABASE IF NOT EXISTS leantime_test; GRANT ALL PRIVILEGES ON leantime_test.* TO 'leantime'@'%'; FLUSH PRIVILEGES;"

.PHONY: install-deps build package clean run-dev
set-folder-permissions:
docker compose exec -T leantime-dev chown -R www-data:www-data /var/www/html/cache/

get-version:
@echo $(VERSION)

.PHONY: install-deps build package clean run-dev run-test
Loading