Skip to content
Open
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
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
branches: [master]
tags: ['*']
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Build Docker image
run: docker compose build

- name: Install dependencies
run: docker compose run --rm --user $(id -u) php-sniffs-cli composer install --no-interaction

- name: Validate Composer configuration
run: docker compose run --rm --user $(id -u) php-sniffs-cli composer validate --no-interaction

deploy:
needs: test
if: github.ref_type == 'tag'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Deploy to Gemfury
env:
GEMFURY_USER: ${{ secrets.GEMFURY_USER }}
GEMFURY_PASSWORD: ${{ secrets.GEMFURY_PASSWORD }}
GEMFURY_REPO_SLUG: ${{ secrets.GEMFURY_REPO_SLUG }}
run: bash scripts/deploy.sh
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
*.local.php
*.local.ini
*.env
composer.lock

# packages
vendor/
node_modules/

26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

103 changes: 103 additions & 0 deletions composer.lock

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

48 changes: 2 additions & 46 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,8 @@
version: '3.4'

services:
php-sniff-php-fpm:
container_name: php-sniff-php-fpm
php-sniffs-cli:
container_name: php-sniffs-cli
build:
context: ./
dockerfile: ./docker/php/Dockerfile
target: debugging
ports:
- "30112:80"
volumes:
- ./:/var/www/project
environment:
IN_DOCKER: 1

PHP_INI_UPLOAD_MAX_FILESIZE: 100M
PHP_INI_POST_MAX_SIZE: 108M
PHP_INI_MAX_FILE_UPLOADS: 200
INI_EXPOSE_PHP: 0

INI_MAX_EXECUTION_TIME: 0
INI_MEMORY_LIMIT: 2G

INI_ERROR_LOG: .debug/php-errors.log
INI_LOG_ERRORS: 1
INI_DISPLAY_ERRORS: "E_ALL & ~E_DEPRECATED & ~E_NOTICE"
INI_DISPLAY_STARTUP_ERRORS: 1
INI_ERROR_REPORTING: 1
INI_HTML_ERRORS: 0

# https://xdebug.org/docs/all_settings#mode
# INI_XDEBUG_MODE=off,debug,profile,trace - EG - Enables step debugger, profiling and tracing
INI_XDEBUG_MODE: "debug"
INI_XDEBUG_HOST: host.docker.internal
INI_XDEBUG_PORT: 9000
INI_IDEKEY: PHPSTORM
INI_XDEBUG_OUTPUT_DIR: "/var/www/project/.debug"
INI_XDEBUG_DISCOVER_CLIENT_HOST: 1
INI_XDEBUG_CLI_COLOR: 1
INI_XDEBUG_START_WITH_REQUEST: 1

INI_XDEBUG_LOG: "/var/www/project/.debug/remote.log"
INI_XDEBUG_LOG_LEVEL: 7

INI_XDEBUG_TRACE_FORMAT: 0
INI_XDEBUG_TRACE_OUTPUT_NAME: "trace.%t-%s"

INI_XDEBUG_PROFILER_APPEND: 0
INI_XDEBUG_PROFILER_OUTPUT_NAME: "cachegrind.out.%t-%s"

PHP_IDE_CONFIG: "serverName=php-sniff-php-fpm"
72 changes: 22 additions & 50 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,69 +1,41 @@
# For why we separate so many docker layers by performing multiple RUN and COPY, please see
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
# https://www.ginkgobioworks.com/2020/05/18/optimizing-your-dockerfile/
FROM php:8.2.31-cli-alpine3.23 AS base

FROM base-php-fpm:php82 as base
RUN apk add --no-cache \
bash \
curl \
git \
libzip-dev \
oniguruma-dev \
unzip

COPY ./docker/php/www.conf /usr/local/etc/php-fpm.d/www.conf
RUN chmod 644 /usr/local/etc/php-fpm.d/www.conf
RUN docker-php-ext-install mbstring zip

FROM base as composer-install
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

COPY --chown=www-data:www-data ./composer.json /var/www/project/composer.json
COPY --chown=www-data:www-data ./composer.lock /var/www/project/composer.lock
WORKDIR /var/www/project

USER www-data
RUN COMPOSER_MEMORY_LIMIT=-1 composer install
USER root

FROM base as copy-volume

COPY --chown=www-data:www-data ./ /var/www/project


FROM base as env-file

RUN mkdir -p shop-env-config
RUN touch shop-env-config/.env

RUN chown www-data:www-data /var/www/project/shop-env-config/.env


# ---------------- Debug ----------------- #
FROM base AS composer-install

FROM base as debugging
COPY --chown=www-data:www-data ./composer.json composer.json
COPY --chown=www-data:www-data ./composer.lock composer.lock

RUN install-php-extensions xdebug
RUN mkdir -p vendor && chown www-data:www-data vendor

# debug settings
RUN mkdir -m 777 -p .debug
RUN chown www-data:www-data .debug

# Travis should have the same ini setup as live prod
COPY ./docker/php/php-fpm-ini.ini /usr/local/etc/php/conf.d/999-overrides.ini

COPY --from=composer-install /var/www/project .
COPY --from=env-file /var/www/project .
COPY --from=copy-volume /var/www/project .

# Bind mount location
VOLUME ["/var/www/project"]
USER www-data
RUN COMPOSER_MEMORY_LIMIT=-1 composer install --no-interaction
USER root

CMD php-fpm
FROM base AS copy-volume

COPY --chown=www-data:www-data ./ /var/www/project

# ---------------- CI ----------------- #

FROM base as image-ci-testing
FROM base AS image-ci-testing

# Travis should have the same ini setup as live prod
COPY ./docker/php/php-fpm-ini.ini /usr/local/etc/php/conf.d/999-overrides.ini
COPY ./docker/php/php-ini.ini /usr/local/etc/php/conf.d/999-overrides.ini

COPY --from=composer-install /var/www/project .
COPY --from=env-file /var/www/project .
COPY --from=copy-volume /var/www/project .

# Bind mount location
VOLUME ["/var/www/project"]

CMD php-fpm
23 changes: 0 additions & 23 deletions docker/php/php-fpm-ini.ini

This file was deleted.

1 change: 1 addition & 0 deletions docker/php/php-ini.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
memory_limit = -1
13 changes: 0 additions & 13 deletions docker/php/www.conf

This file was deleted.

27 changes: 21 additions & 6 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
#!/bin/bash
if [ -n $TRAVIS_TAG ]
then
printf "machine git.fury.io\nlogin $GEMFURY_USER\npassword $GEMFURY_PASSWORD" > ~/.netrc
git remote add fury "https://git.fury.io/$TRAVIS_REPO_SLUG.git"
git push --tags fury HEAD:master
fi

if [[ "$GITHUB_REF_TYPE" != "tag" ]]; then
echo "Not a tag build, skipping deploy"
exit 0
fi

if [ -z "$GEMFURY_USER" ] || [ -z "$GEMFURY_PASSWORD" ] || [ -z "$GEMFURY_REPO_SLUG" ]; then
echo "Missing Gemfury credentials, cannot deploy"
exit 1
fi

echo "Deploying tag ${GITHUB_REF_NAME}..."

printf "machine git.fury.io\nlogin $GEMFURY_USER\npassword $GEMFURY_PASSWORD" > ~/.netrc
chmod 600 ~/.netrc

git remote add fury "https://git.fury.io/$GEMFURY_REPO_SLUG.git"
git fetch fury
git push fury "refs/tags/${GITHUB_REF_NAME}"
sleep 5
git push fury HEAD:master
Loading