diff --git a/.docker/docker-symfony-entrypoint.sh b/.docker/docker-symfony-entrypoint.sh
new file mode 100644
index 0000000..b6b91f9
--- /dev/null
+++ b/.docker/docker-symfony-entrypoint.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+set -e
+
+# first arg is `-f` or `--some-option`
+if [ "${1#-}" != "$1" ]; then
+ set -- php-fpm "$@"
+fi
+
+if [ "$1" = 'php-fpm' ] || [ "$1" = 'bin/console' ]; then
+ if [ ! -d composer.json ]; then
+ # copy the created symfony project to the working directory
+ cp -a "${SYMFONY_BUILD_PROJECT}/${SYMFONY_PROJECT_DIRECTORY_NAME}/." .
+ fi
+
+ if [ "$APP_ENV" != 'prod' ]; then
+ composer install --prefer-dist --no-progress --no-interaction
+ fi
+
+ #setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var
+ #setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var
+
+ # start symfony server
+ if [ "$SG_SERVER_ENABLED" = true ]; then
+ symfony server:ca:install
+ symfony server:start
+ fi
+fi
+
+exec docker-php-entrypoint "$@"
diff --git a/.docker/docker-symfony-golden.ini b/.docker/docker-symfony.ini
similarity index 100%
rename from .docker/docker-symfony-golden.ini
rename to .docker/docker-symfony.ini
diff --git a/.docker/new-symfony.sh b/.docker/new-symfony.sh
index f1fc844..fc72c1d 100644
--- a/.docker/new-symfony.sh
+++ b/.docker/new-symfony.sh
@@ -2,8 +2,13 @@
set -eu -o pipefail
+# todo: use env var instead of $1
directory="$1"
+if [ ! -d "$directory" ]; then
+ mkdir -p "$directory"
+fi
+
# Delete existing symfony project
rm -rf "$directory/symfony"
cd "$directory"
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 62ffe7d..5a9d4dc 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -18,15 +18,31 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: ['8.3']
+ php: ['8.4']
composer: ['2.5']
- symfony: ['5.4', '6.1', '6.2', '6.3', '6.4']
+ symfony: ['6.4', '7.0', '7.1']
latest: [false]
include:
- - php: 8.3
- symfony: '7.0'
+ - php: 8.4
+ symfony: '7.2'
composer: 2.5
latest: true
+ - php: 8.3
+ symfony: '7.2'
+ composer: 2.5
+ latest: false
+ - php: 8.2
+ symfony: '7.2'
+ composer: 2.5
+ latest: false
+ - php: 8.3
+ symfony: '7.1'
+ composer: 2.5
+ latest: false
+ - php: 8.2
+ symfony: '7.1'
+ composer: 2.5
+ latest: false
name: "[Package] SF v${{ matrix.symfony }} PHP ${{ matrix.php }}"
runs-on: ubuntu-latest
@@ -75,9 +91,9 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: ['8.3']
+ php: ['8.3', '8.4']
composer: ['2.5']
- symfony: ['5.4', '6.1', '6.2', '6.3', '6.4', '7.0']
+ symfony: ['6.4', '7.0', '7.1', '7.2']
needs: packaging
runs-on: ubuntu-latest
name: "[Run] SF v${{ matrix.symfony }} PHP ${{ matrix.php }}"
diff --git a/.gitignore b/.gitignore
index 485dee6..fd543c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
.idea
+symfony
+compose.yaml
diff --git a/Dockerfile b/Dockerfile
index e41def0..d859114 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,28 +1,41 @@
-ARG PHP_VERSION=8.2
+ARG PHP_VERSION=8.4
ARG COMPOSER_VERSION=2.5
FROM composer:${COMPOSER_VERSION} as composer
FROM php:${PHP_VERSION}-fpm-alpine
-ENV PHP_VERSION $PHP_VERSION
-ENV COMPOSER_VERSION $COMPOSER_VERSION
-ARG SYMFONY_VERSION=6.4
-ENV SYMFONY_VERSION $SYMFONY_VERSION
+ARG SG_SERVER_ENABLED=true
+ENV SG_SERVER_ENABLED=$SG_SERVER_ENABLED
+
+ENV PHP_VERSION=$PHP_VERSION
+ENV COMPOSER_VERSION=$COMPOSER_VERSION
+ARG SYMFONY_VERSION=7.2
+ENV SYMFONY_VERSION=$SYMFONY_VERSION
+ARG SFUSER=symfony
+ENV SFUSER=$SFUSER
+ARG SYMFONY_BUILD_PROJECT=/home/$SFUSER/build
+ENV SYMFONY_BUILD_PROJECT=$SYMFONY_BUILD_PROJECT
+ARG SYMFONY_PROJECT_DIRECTORY_NAME=symfony
+ENV SYMFONY_PROJECT_DIRECTORY_NAME=$SYMFONY_PROJECT_DIRECTORY_NAME
+ARG DOCKER_WORKING_DIRECTORY=/var/www
+ENV DOCKER_WORKING_DIRECTORY=$DOCKER_WORKING_DIRECTORY
COPY --from=composer /usr/bin/composer /usr/bin/composer
### SYMFONY REQUIREMENT
-RUN apk add --no-cache icu-dev \
+RUN apk add --no-cache icu-dev acl \
&& docker-php-ext-install intl \
&& docker-php-ext-enable intl \
&& docker-php-ext-install opcache \
&& docker-php-ext-enable opcache
-COPY .docker/docker-symfony-golden.ini /usr/local/etc/php/conf.d/
+COPY .docker/docker-symfony.ini /usr/local/etc/php/conf.d/
### END SYMFONY REQUIREMENT
COPY ./.docker/new-symfony.sh /usr/local/bin/new-symfony
RUN chmod +x /usr/local/bin/new-symfony
+COPY ./.docker/docker-symfony-entrypoint.sh /usr/local/bin/docker-symfony-entrypoint
+RUN chmod +x /usr/local/bin/docker-symfony-entrypoint
## SYMFONY CLI INSTALL
RUN apk add --no-cache bash git
@@ -34,13 +47,28 @@ RUN apk add symfony-cli
HEALTHCHECK --interval=5s --timeout=3s --retries=3 CMD symfony check:req || exit 1
# END HEALTHCHECK
-RUN new-symfony "/var/www"
+EXPOSE 8000
-WORKDIR /var/www/symfony
+## Create container user
+ARG UID=1001
+ENV UID $UID
+ARG GID=1001
+ENV GID $GID
-EXPOSE 8000
+RUN apk add --no-cache sudo
+RUN addgroup --system --gid $GID $SFUSER
+RUN echo "$SFUSER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$SFUSER
+RUN chmod 0440 /etc/sudoers.d/$SFUSER
+RUN adduser --system --uid $UID --ingroup $SFUSER $SFUSER
+
+USER $SFUSER
+
+RUN new-symfony $SYMFONY_BUILD_PROJECT
+
+WORKDIR $DOCKER_WORKING_DIRECTORY/$SYMFONY_PROJECT_DIRECTORY_NAME
-CMD ["symfony", "server:start"]
+ENTRYPOINT ["docker-symfony-entrypoint"]
+CMD ["php-fpm", "-F"]
ARG BUILD_DATE
ARG VCS_REF
@@ -74,4 +102,4 @@ LABEL org.label-schema.version=$BUILD_VERSION
LABEL org.label-schema.docker.cmd="docker run --rm -ti -v PROJECT_DIR:/var/www/symfony $IMAGE_TAG sh"
## ClEAN
-RUN rm -rf /tmp/* /var/cache/apk/* /var/tmp/*
+RUN sudo rm -rf /tmp/* /var/cache/apk/* /var/tmp/*
diff --git a/README.md b/README.md
index 8eb917b..2d8a092 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,10 @@
## About
This repository is a docker image based on official php, composer and alpine docker images.
This image contains symfony framework installed with all its required extensions.
+It's useful to easily set symfony project up
+
+## Image details
+### Available versions
Below is the list of all the available images by Symfony and PHP versions:
7.0 | +7.2 | +8.4 | +
+ ghcr.io/devgine/symfony-golden:latest
+ ghcr.io/devgine/symfony-golden:v7.2-php8.4-alpine
+ |
+
8.3 | +
+ ghcr.io/devgine/symfony-golden:v7.2-php8.3-alpine
+ |
+ ||
8.2 | +
+ ghcr.io/devgine/symfony-golden:v7.2-php8.2-alpine
+ |
+ ||
7.1 | +8.4 | +
+ ghcr.io/devgine/symfony-golden:v7.1-php8.4-alpine
+ |
+ |
8.3 | +
+ ghcr.io/devgine/symfony-golden:v7.1-php8.3-alpine
+ |
+ ||
8.2 | +
+ ghcr.io/devgine/symfony-golden:v7.1-php8.2-alpine
+ |
+ ||
7.0 | +8.4 | +
+ ghcr.io/devgine/symfony-golden:v7.0-php8.4-alpine
+ |
+ |
8.3 |
- ghcr.io/devgine/symfony-golden:latest ghcr.io/devgine/symfony-golden:v7.0-php8.3-alpine
|
||
6.4 | +6.4 | +8.4 | +
+ ghcr.io/devgine/symfony-golden:v6.4-php8.4-alpine
+ |
+
8.3 |
ghcr.io/devgine/symfony-golden:v6.4-php8.3-alpine
@@ -126,10 +180,13 @@ Below is the list of all the available images by Symfony and PHP versions:
|