├── .gitignore ├── docker-compose.yaml ├── php8-sf6 └── Dockerfile └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | /project -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | services: 3 | php8-sf6: 4 | container_name: php8-sf6 5 | build: php8-sf6 6 | ports: 7 | - "9000:8000" 8 | volumes: 9 | - ./project:/var/www/html 10 | 11 | mailer: 12 | image: schickling/mailcatcher 13 | ports: [1025, 1080] 14 | 15 | database: 16 | image: postgres:13-alpine 17 | environment: 18 | POSTGRES_DB: app 19 | POSTGRES_PASSWORD: ChangeMe 20 | POSTGRES_USER: symfony 21 | volumes: 22 | - db-data:/var/lib/postgresql/data:rw 23 | ports: 24 | - "5432" 25 | 26 | volumes: 27 | db-data: -------------------------------------------------------------------------------- /php8-sf6/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.0.13-cli 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y --no-install-recommends \ 5 | locales apt-utils git libicu-dev g++ libpng-dev libxml2-dev libzip-dev libonig-dev libxslt-dev unzip libpq-dev nodejs npm wget \ 6 | apt-transport-https lsb-release ca-certificates 7 | 8 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ 9 | && echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen \ 10 | && locale-gen 11 | 12 | RUN curl -sS https://getcomposer.org/installer | php -- \ 13 | && mv composer.phar /usr/local/bin/composer 14 | 15 | RUN curl -sS https://get.symfony.com/cli/installer | bash \ 16 | && mv /root/.symfony/bin/symfony /usr/local/bin 17 | 18 | RUN docker-php-ext-configure \ 19 | intl \ 20 | && docker-php-ext-install \ 21 | pdo pdo_mysql pdo_pgsql opcache intl zip calendar dom mbstring gd xsl 22 | 23 | RUN pecl install apcu && docker-php-ext-enable apcu 24 | 25 | RUN npm install --global yarn 26 | 27 | RUN git config --global user.email "you@example.com" \ 28 | && git config --global user.name "Your Name" 29 | 30 | CMD tail -f /dev/null 31 | 32 | WORKDIR /var/www/html/ -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Symfony 6 + PHP 8.0.13 with Docker 3 | 4 | **ONLY for DEV, not for production** 5 | 6 | A very simple Docker-compose to discover Symfony 6 with PHP 8.0.13 in 5 minutes 7 | ## Run Locally 8 | 9 | Clone the project 10 | 11 | ```bash 12 | git@github.com:yoanbernabeu/symfony6-php8-in-docker-compose.git 13 | ``` 14 | 15 | Run the docker-compose 16 | 17 | ```bash 18 | docker-compose build 19 | docker-compose up -d 20 | ``` 21 | 22 | Log into the PHP container 23 | 24 | ```bash 25 | docker exec -it php8-sf6 bash 26 | ``` 27 | 28 | Create your Symfony application and launch the internal server 29 | 30 | ```bash 31 | symfony new new-project --full 32 | cd new-project 33 | symfony serve -d 34 | ``` 35 | 36 | Create an account (identical to your local session) 37 | 38 | ```bash 39 | adduser username 40 | chown username:username -R . 41 | ``` 42 | 43 | *Your application is available at http://127.0.0.1:9000* 44 | 45 | If you need a database, modify the .env file like this example: 46 | 47 | ```yaml 48 | DATABASE_URL="postgresql://symfony:ChangeMe@database:5432/app?serverVersion=13&charset=utf8" 49 | ``` 50 | 51 | ## Ready to use with 52 | 53 | This docker-compose provides you : 54 | 55 | - PHP-8.0.13-cli (Debian) 56 | - Composer 57 | - Symfony CLI 58 | - and some other php extentions 59 | - nodejs, npm, yarn 60 | - postgres:13-alpine 61 | - mailcatcher 62 | 63 | 64 | ## Requirements 65 | 66 | Out of the box, this docker-compose is designed for a Linux operating system, provide adaptations for a Mac or Windows environment. 67 | 68 | - Linux (Ubuntu 20.04 or other) 69 | - Docker 70 | - Docker-compose 71 | ## Author 72 | 73 | - [@yoanbernabeu](https://github.com/yoanbernabeu) 74 | --------------------------------------------------------------------------------