Skip to content

Commit

Permalink
Docker config (#179)
Browse files Browse the repository at this point in the history
* [ENHANCEMENT] Add `.phpunit.result.cache` to ignore

(cherry picked from commit d250471)

* [ENHANCEMENT] add docker-compose for easy jump in development

(cherry picked from commit d03b46d)

* Makefile + Documentation

---------

Co-authored-by: Maxim Ageev <maxim.ageev@paxful.com>
  • Loading branch information
Legion112 and Maxim Ageev authored Jun 14, 2023
1 parent 2546d10 commit 9d2d766
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .docker/Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM php:8.1-cli-alpine
ENV XDG_CACHE_HOME=/tmp/.cache
ENV COMPOSER_CACHE_DIR=${XDG_CACHE_HOME}/composer
# posible could install cache directory here
RUN --mount=type=bind,from=mlocati/php-extension-installer:1.5,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \
install-php-extensions zip xdebug-stable
RUN addgroup -S app && adduser -S app -G app
RUN mkdir -p /app && chown -R app /app && mkdir -p /tmp && chown -R app /tmp
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
USER app
WORKDIR /app
4 changes: 4 additions & 0 deletions .docker/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[xdebug]
zend_extension="xdebug.so"
xdebug.client_host=host.docker.internal
xdebug.mode=debug
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
/.github export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.docker export-ignore
/docker-compose.yaml export-ignore
/Makefile export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ composer.phar
*.iml
.idea/
coverage.xml
.phpunit.result.cache
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
init:
docker compose run cli composer i
test:
docker compose run cli vendor/bin/phpunit
shell:
docker compose run cli sh
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,20 @@ See [Guzzle Cache](https://www.drupal.org/project/guzzle_cache) module.
# Links that talk about the project
- [Speeding Up APIs/Apps/Smart Toasters with HTTP Response Caching](https://apisyouwonthate.com/blog/speeding-up-apis-apps-smart-toasters-with-http-response-caching)
- [Caching HTTP-Requests with Guzzle 6 and PSR-6](http://a.kabachnik.info/caching-http-requests-with-guzzle-6-and-psr-6.html)

# Development

## Docker quick start

### Initialization
```bash
make init
```
### Running test
```bash
make test
```
### Entering container shell
```bash
make shell
```
11 changes: 11 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.9"
services:
cli:
build:
dockerfile: .docker/Dockerfile.local
context: .
working_dir: /app
volumes:
- ./:/app
- ~/.composer/cache/:/tmp/cache/
- ./.docker/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini:ro

0 comments on commit 9d2d766

Please sign in to comment.