Skip to content

Commit

Permalink
Added build an image from a docker-compose file
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitriy Derepko <xepozz@list.ru>
  • Loading branch information
s1lver and xepozz committed Jun 20, 2023
1 parent 86121e4 commit 0e91c9e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Expand Up @@ -29,9 +29,12 @@
/.phpunit-watcher.yml export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/docker-compose.yml export-ignore
/infection.json.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml export-ignore
/Makefile export-ignore
/rector.php export-ignore
/tests export-ignore
/docs export-ignore

Expand Down
19 changes: 19 additions & 0 deletions Makefile
@@ -0,0 +1,19 @@
help: ## Display help information
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

build: ## Build an image from a docker-compose file. Params: {{ v=8.1 }}. Default latest PHP 8.1
PHP_VERSION=$(filter-out $@,$(v)) docker-compose up -d --build

down: ## Stop and remove containers, networks
docker-compose down

start: ## Start services
docker-compose up -d

sh: ## Enter the container with the application
docker exec -it yii-runner-roadrunner sh

test: ## Run tests. Params: {{ v=8.1 }}. Default latest PHP 8.1
PHP_VERSION=$(filter-out $@,$(v)) docker-compose build --pull yii-runner-roadrunner
PHP_VERSION=$(filter-out $@,$(v)) docker-compose run yii-runner-roadrunner vendor/bin/phpunit --colors=always -v --debug
make down
13 changes: 13 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,13 @@
version: '3.8'

services:
yii-runner-roadrunner:
container_name: yii-runner-roadrunner
hostname: yii-runner-roadrunner
build:
context: .
dockerfile: tests/Docker/Dockerfile
args:
PHP_VERSION: ${PHP_VERSION:-8.1}
volumes:
- .:/app
29 changes: 29 additions & 0 deletions tests/Docker/Dockerfile
@@ -0,0 +1,29 @@
# Important! Do not use this image in production!

ARG PHP_VERSION
FROM --platform=linux/amd64 php:${PHP_VERSION}-cli-alpine

# Install main package
RUN apk add git libzip-dev autoconf g++ make linux-headers

# Install PHP extensions
RUN docker-php-ext-install zip sockets

# Install PHP extensions from PECL
RUN pecl install xdebug pcov \
&& docker-php-ext-enable xdebug pcov

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
ENV COMPOSER_ALLOW_SUPERUSER 1

# Install RoadRunner
COPY --from=spiralscout/roadrunner:2023.1.4 /usr/bin/rr /usr/local/bin/rr

# Set up work directory
ADD . /app
WORKDIR /app

RUN composer install --prefer-dist --no-interaction

CMD ["sleep", "infinity"]

0 comments on commit 0e91c9e

Please sign in to comment.