-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor(docker): initial refactor of Docker setup
- Loading branch information
Showing
6 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ARG PHP_VERSION | ||
FROM php:${PHP_VERSION}-fpm-alpine | ||
|
||
COPY --from=composer:latest --link /usr/bin/composer /usr/local/bin/composer | ||
COPY --from=phario/phive:0.15.2 --link /usr/local/bin/phive /usr/local/bin/phive | ||
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ | ||
|
||
# Install PHP extensions | ||
RUN RUN set -eux; \ | ||
install-php-extensions \ | ||
apcu \ | ||
memcache \ | ||
pdo \ | ||
pdo_mysql \ | ||
zip \ | ||
; | ||
|
||
COPY --link php-config/*.ini /usr/local/etc/php/conf.d/ | ||
|
||
RUN RUN set -eux; \ | ||
apk add file --no-cache; | ||
|
||
# Configure Composer folders | ||
RUN RUN set -eux; \ | ||
mkdir - /var/composer; \ | ||
chmod a+rwX /var/composer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
display_error = On | ||
error_reporting = E_ALL | ||
memory_limit = 512M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
dockerCompose := "docker compose" | ||
dockerExec := dockerCompose + " exec php" | ||
defaultPhp := "7.4" | ||
|
||
default: | ||
@just --list --justfile {{ justfile() }} | ||
|
||
# Build the docker image with the given PHP version | ||
build version=defaultPhp *options="": | ||
{{ dockerCompose }} build --build-arg=PHP_VERSION={{ version }} {{ options }} | ||
|
||
# Build the docker image (and pull new images) with the given PHP version | ||
build-pull version=defaultPhp: (build version "--pull") | ||
|
||
# Build the docker image (and pull new images, with no docker cache) with the given PHP version | ||
rebuild version=defaultPhp: (build version "--pull" "--no-cache") | ||
|
||
# Start the docker containers in detached mode (no logs) and waits for the dependencies to be up and running. | ||
up: | ||
{{ dockerCompose }} up --detach --wait | ||
|
||
# Start the docker containers and keep the daemon attached | ||
up-foreground: | ||
{{ dockerCompose }} up | ||
|
||
# Stop the running containers | ||
down: | ||
{{ dockerCompose }} down --remove-orphans | ||
|
||
# Display and follow the containers logs | ||
logs: | ||
{{ dockerCompose }} logs --follow | ||
|
||
# Get a terminal within the running PHP container | ||
shell: | ||
{{ dockerExec }} ash | ||
|
||
cs-check: (run-cs-fix "--dry-run") | ||
cs-fix: run-cs-fix | ||
[private] | ||
run-cs-fix *options: | ||
{{ dockerExec }} tools/php-cs-fixer.phar fix --verbose {{ options }} | ||
|
||
# Run the legacy Symfony1 tests on the currently running docker instance | ||
tests-legacy: | ||
{{ dockerExec }} php data/bin/symfony symfony:test --trace | ||
|
||
# Setup and initialize the project (docker image must be running) | ||
setup: | ||
git submodule update --checkout --recursive --force | ||
{{ dockerExec }} composer update --optimize-autoloader | ||
|
||
# Cleanup the local code from vendor and composer.lock file | ||
cleanup: | ||
rm -fr vendor/ | ||
rm -fr composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
php: | ||
# Use the following user withing the image, this should help with file permissions | ||
user: 1000:1000 | ||
volumes: | ||
# Mount additional volumes from the host system to share Composer cache and authentication | ||
- "${COMPOSER_CACHE_DIR:-${HOME}/.cache/composer}:/var/composer/cache:z" | ||
- "${COMPOSER_HOME:-${HOME}/.composer}/auth.json:/var/composer/auth.json:ro,z" | ||
- "${COMPOSER_HOME:-${HOME}/.composer}/config.json:/var/composer/config.json:ro,z" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
services: | ||
|
||
php: | ||
environment: | ||
COMPOSER_HOME: "/var/composer" | ||
COMPOSER_CACHE_DIR: "/var/composer/cache" | ||
build: | ||
context: .docker/ | ||
volumes: | ||
- ".:/var/www/html:rw,z" | ||
|
||
# memcached: | ||
# image: memcached:1.6.13-alpine3.15 |