Skip to content

Commit 7e35185

Browse files
committed
Refactor(docker): initial refactor of Docker setup
1 parent 146806f commit 7e35185

File tree

6 files changed

+109
-0
lines changed

6 files changed

+109
-0
lines changed

Diff for: .docker/Dockerfile

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ARG PHP_VERSION
2+
FROM php:${PHP_VERSION}-fpm-alpine
3+
4+
COPY --from=composer:latest --link /usr/bin/composer /usr/local/bin/composer
5+
COPY --from=phario/phive:0.15.2 --link /usr/local/bin/phive /usr/local/bin/phive
6+
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
7+
8+
# Install PHP extensions
9+
RUN RUN set -eux; \
10+
install-php-extensions \
11+
apcu \
12+
memcache \
13+
pdo \
14+
pdo_mysql \
15+
zip \
16+
;
17+
18+
COPY --link php-config/*.ini /usr/local/etc/php/conf.d/
19+
20+
RUN RUN set -eux; \
21+
apk add file --no-cache;
22+
23+
# Configure Composer folders
24+
RUN RUN set -eux; \
25+
mkdir - /var/composer; \
26+
chmod a+rwX /var/composer;

Diff for: .docker/php-config/10-symfony.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
display_error = On
2+
error_reporting = E_ALL
3+
memory_limit = 512M

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
compose.override.yaml
2+
13
/test/functional/fixtures/cache
24
/test/functional/fixtures/log
35
/lib/plugins/sfDoctrinePlugin/test/functional/fixtures/lib/*/doctrine/base/

Diff for: Justfile

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
dockerCompose := "docker compose"
2+
dockerExec := dockerCompose + " exec php"
3+
defaultPhp := "7.4"
4+
5+
default:
6+
@just --list --justfile {{ justfile() }}
7+
8+
# Build the docker image with the given PHP version
9+
build version=defaultPhp *options="":
10+
{{ dockerCompose }} build --build-arg=PHP_VERSION={{ version }} {{ options }}
11+
12+
# Build the docker image (and pull new images) with the given PHP version
13+
build-pull version=defaultPhp: (build version "--pull")
14+
15+
# Build the docker image (and pull new images, with no docker cache) with the given PHP version
16+
rebuild version=defaultPhp: (build version "--pull" "--no-cache")
17+
18+
# Start the docker containers in detached mode (no logs) and waits for the dependencies to be up and running.
19+
up:
20+
{{ dockerCompose }} up --detach --wait
21+
22+
# Start the docker containers and keep the daemon attached
23+
up-foreground:
24+
{{ dockerCompose }} up
25+
26+
# Stop the running containers
27+
down:
28+
{{ dockerCompose }} down --remove-orphans
29+
30+
# Display and follow the containers logs
31+
logs:
32+
{{ dockerCompose }} logs --follow
33+
34+
# Get a terminal within the running PHP container
35+
shell:
36+
{{ dockerExec }} ash
37+
38+
cs-check: (run-cs-fix "--dry-run")
39+
cs-fix: run-cs-fix
40+
[private]
41+
run-cs-fix *options:
42+
{{ dockerExec }} tools/php-cs-fixer.phar fix --verbose {{ options }}
43+
44+
# Run the legacy Symfony1 tests on the currently running docker instance
45+
tests-legacy:
46+
{{ dockerExec }} php data/bin/symfony symfony:test --trace
47+
48+
# Setup and initialize the project (docker image must be running)
49+
setup:
50+
git submodule update --checkout --recursive --force
51+
{{ dockerExec }} composer update --optimize-autoloader
52+
53+
# Cleanup the local code from vendor and composer.lock file
54+
cleanup:
55+
rm -fr vendor/
56+
rm -fr composer.lock

Diff for: compose.override.example.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
php:
3+
# Use the following user withing the image, this should help with file permissions
4+
user: 1000:1000
5+
volumes:
6+
# Mount additional volumes from the host system to share Composer cache and authentication
7+
- "${COMPOSER_CACHE_DIR:-${HOME}/.cache/composer}:/var/composer/cache:z"
8+
- "${COMPOSER_HOME:-${HOME}/.composer}/auth.json:/var/composer/auth.json:ro,z"
9+
- "${COMPOSER_HOME:-${HOME}/.composer}/config.json:/var/composer/config.json:ro,z"

Diff for: compose.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
3+
php:
4+
environment:
5+
COMPOSER_HOME: "/var/composer"
6+
COMPOSER_CACHE_DIR: "/var/composer/cache"
7+
build:
8+
context: .docker/
9+
volumes:
10+
- ".:/var/www/html:rw,z"
11+
12+
# memcached:
13+
# image: memcached:1.6.13-alpine3.15

0 commit comments

Comments
 (0)