Skip to content

Commit

Permalink
Merge pull request #6 from MauBoy/php-8.1-update
Browse files Browse the repository at this point in the history
PHP Upgrade, docker- and makefile
  • Loading branch information
adlenton authored Jan 13, 2023
2 parents 095fc99 + b58d851 commit 4520c8d
Show file tree
Hide file tree
Showing 14 changed files with 663 additions and 563 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ vendor/
composer.phar
.idea/
build.properties
.phpunit.result.cache
dump.rdb
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Forked version to add namespacing

### 5.0.0 ##
* Add Docker- and Makefile to run the application
* Add return types for functions to avoid warnings in PHP 8.1

### 4.0.0 ##
* Introduced strict types where possible
* Added support for PHP 8
Expand Down
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM redis:7.0.7-bullseye

ARG DEBIAN_FRONTEND=noninteractive

# Set work directory
WORKDIR /app

# Add sury php
RUN apt update
RUN apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2 curl
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/sury-php.list
RUN curl -fsSL https://packages.sury.org/php/apt.gpg| gpg --dearmor -o /etc/apt/trusted.gpg.d/sury-keyring.gpg

# Install php
RUN apt update
RUN apt install php8.1 php8.1-dom php8.1-mbstring php8.1-curl -y

# Install tools
RUN apt install zip unzip php-zip -y

# Install composer and dependencies
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
67 changes: 67 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Variables and flags
MAKEFLAGS += --silent
DOCKER_COMPOSE = docker-compose --file docker-compose.yml
WORK_DIRECTORY = app

# Right and OS management
UID := $(shell id -u)
GID := $(shell id -g)
OS := $(shell uname)

# Do not remove - it filters empty arguments from command line
%:
@:

# Help
help:
@echo "Usage:"
@echo " make <COMMAND>"
@echo ""

@echo " Docker commands:"
@echo " ----------------------------------------------------------------------------------------"

@echo " start Start all docker container"
@echo " stop Stop all docker container"
@echo " restart Restart all docker container"
@echo " down Destroy all docker container"
@echo " exec Connect directly to docker container"

@echo " ----------------------------------------------------------------------------------------"
@echo ""

@echo " Test commands:"
@echo " ----------------------------------------------------------------------------------------"
@echo " phpunit, pu Run php unit tests"
@echo " ----------------------------------------------------------------------------------------"
@echo ""

# Docker
start:
@echo "--- Starting docker container ---"
rm -rf dump.rdb
${DOCKER_COMPOSE} up --build -d
${DOCKER_COMPOSE} exec app bash -c "composer install"
@echo "--- Started docker container ---"

stop:
@echo "--- Stopping docker container ---"
${DOCKER_COMPOSE} stop -t1
@echo "--- Stopped docker container ---"

restart: stop start

down:
@echo "--- Destroying docker container ---"
${DOCKER_COMPOSE} down -v
@echo "--- Finished destroying docker container ---"

exec:
@echo "--- Connecting to ${WORK_DIRECTORY} container ---"
${DOCKER_COMPOSE} exec ${WORK_DIRECTORY} bash

# Tests
phpunit pu:
@echo "--- Running php unit tests ---"
${DOCKER_COMPOSE} exec app ./vendor/bin/phpunit
@echo "--- Finished running php unit tests ---"
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ Add `innogames/php-resque` to your application's composer.json.

## Requirements

* PHP 7.3+ (incl. PHP 8)
* PHP 8+
* A Redis client library (for instance, [Predis](https://github.com/nrk/predis) or [Credis](https://github.com/colinmollenhour/credis))
* The PHP pcntl extension for proper forking is recommended (not available under Windows) but it still runs without it

## Docker Setup
To use the docker setup it's recommended to have `docker-compose` installed.\
Also `make` when you want to use makefile with short and useful commands.

Disclaimer: This setup is has only limited support. It was tested under Ubuntu 22.04.1 LTS.

## Jobs

### Queueing Jobs
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"resque"
],
"require": {
"php": "^7.3 || ^8.0",
"php": ">=8.0 <8.2",
"psr/log": "^1.1",
"symfony/console": "^5.0",
"ext-pcntl": "*",
Expand Down
Loading

0 comments on commit 4520c8d

Please sign in to comment.