Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile, Docker and Xdebug fixes #4680

Merged
merged 1 commit into from
Dec 14, 2023
Merged
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ dist/*

# Garden
.garden

# Test Coverage
coverage
.phpunit.result.cache
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
FROM ushahidi/php-fpm-nginx:php-7.3
LABEL org.opencontainers.image.source="https://github.com/ushahidi/platform"

COPY docker-php-ext-enable /usr/local/bin/
RUN apt-get update
RUN apt-get install -y php-pear php7.3-dev
RUN pecl channel-update pecl.php.net
RUN pecl install xdebug-3.1.6
ENV PHP_INI_DIR=/etc/php/7.3/fpm
RUN docker-php-ext-enable xdebug
ENV PHP_INI_DIR=/etc/php/7.3/cli
RUN docker-php-ext-enable xdebug
COPY docker-php-ext-xdebug.ini /etc/php/7.3/fpm/conf.d

WORKDIR /var/www
COPY composer.json ./
COPY composer.lock ./
Expand Down
44 changes: 27 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,56 +1,66 @@
ifneq ($(shell docker compose version 2>/dev/null),)
DOCKER_COMPOSE=docker compose
else
DOCKER_COMPOSE=docker-compose
endif

## All these make targets (commands) are only useful for a Docker environment!

# Master command to build and start everything
start: build up apply

debug: export XDEBUG_MODE=debug,develop
debug: build up apply

# Builds containers (init .env while at it)
build:
[ ! -f ./.env ] && cp -p -v ./.env.dockerinit ./.env || true
docker-compose build
$(DOCKER_COMPOSE) build

down:
docker-compose down
$(DOCKER_COMPOSE) down

# Starts containers in the background
up:
docker-compose up -d
$(DOCKER_COMPOSE) up -d

# Applies changes (dependencies, migrations) to running containers
apply: composer-install migrate

# Runs composer install (updates dependencies)
composer-install:
docker-compose exec platform util wait_bootstrap
docker-compose exec platform util run_composer_install
docker-compose exec platform_tasks util wait_bootstrap
docker-compose exec platform_tasks util run_composer_install
$(DOCKER_COMPOSE) exec platform util wait_bootstrap
$(DOCKER_COMPOSE) exec platform util run_composer_install
$(DOCKER_COMPOSE) exec platform_tasks util wait_bootstrap
$(DOCKER_COMPOSE) exec platform_tasks util run_composer_install

# Runs database migrations
migrate:
docker-compose exec platform util wait_bootstrap
docker-compose exec platform util run_migrations
$(DOCKER_COMPOSE) exec platform util wait_bootstrap
$(DOCKER_COMPOSE) exec platform util run_migrations

# Tails logs on the screen
logs:
docker-compose logs -f
$(DOCKER_COMPOSE) logs -f

enter:
docker-compose exec platform bash
$(DOCKER_COMPOSE) exec platform bash

pre-test:
docker-compose exec platform composer run pre-test
$(DOCKER_COMPOSE) exec platform composer run pre-test

test: export XDEBUG_MODE=coverage
test:
docker-compose exec platform composer run test-dev
$(DOCKER_COMPOSE) exec platform composer run test-dev

pre-push-test:
docker-compose exec platform composer run pre-push-test
$(DOCKER_COMPOSE) exec platform composer run pre-push-test

test-ci:
docker-compose exec platform composer run test
$(DOCKER_COMPOSE) exec platform composer run test

cleanup:
docker-compose exec platform composer run fixlint
$(DOCKER_COMPOSE) exec platform composer run fixlint

stop:
docker-compose stop
$(DOCKER_COMPOSE) stop
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"laravel/framework": "^8.0",
"laravel/passport": "^10.0",
"laravel/tinker": "^2.5",
"laravel/ui": "^3.4",
"league/csv": "~7.1@dev",
"league/flysystem": "~1.0",
"league/flysystem-aws-s3-v3": "~1.0",
Expand Down
88 changes: 75 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ services:
REDIS_HOST: redis
CACHE_DRIVER: redis
QUEUE_DRIVER: redis
XDEBUG_MODE: ${XDEBUG_MODE:-off}
command: start
ports:
- "8080:8080"
volumes:
- storage-app-public:/var/www/storage/app/public
- .:/var/www
extra_hosts:
- "host.docker.internal:host-gateway"
platform_tasks:
build: .
environment:
Expand Down Expand Up @@ -70,3 +73,7 @@ services:
volumes:
# share storage/app/public between platform containers
storage-app-public:

networks:
internal:
driver: bridge
Loading
Loading