Skip to content

Commit 5865ac9

Browse files
committed
🐳Dockerize.
1 parent 6a2fe8f commit 5865ac9

File tree

4 files changed

+78
-2
lines changed

4 files changed

+78
-2
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ APP_SECRET=2ca64f8d83b9e89f5f19d672841d6bb8
2525
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
2626
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
2727
#
28-
DATABASE_URL=sqlite:///%kernel.project_dir%/data/database.sqlite
29-
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8&charset=utf8mb4"
28+
#DATABASE_URL=sqlite:///%kernel.project_dir%/data/database.sqlite
29+
DATABASE_URL="mysql://symfony:symfony@db:3306/symfony?serverVersion=8&charset=utf8mb4"
3030
# DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=15&charset=utf8"
3131
###< doctrine/doctrine-bundle ###
3232

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use an official PHP image as your base image
2+
FROM php:8.2.0
3+
4+
# Install dependencies
5+
RUN apt-get update && apt-get install -y \
6+
git \
7+
unzip \
8+
libpq-dev \
9+
libzip-dev
10+
11+
# Install Composer globally
12+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
13+
14+
# Install symfony CLI
15+
RUN curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | bash \
16+
&& apt install symfony-cli
17+
18+
# Set the working directory
19+
WORKDIR /var/www/symfony
20+
21+
# Copy the Symfony application
22+
COPY . /var/www/symfony/
23+
24+
# Install dependencies and serve
25+
COPY docker-entrypoint.sh /usr/local/bin/
26+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
27+
ENTRYPOINT ["docker-entrypoint.sh"]

docker-compose.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: '3.8'
2+
3+
services:
4+
web:
5+
build:
6+
context: .
7+
ports:
8+
- "8000:8000"
9+
depends_on:
10+
- db
11+
db:
12+
image: mysql:8.0
13+
ports:
14+
- "3306:3306"
15+
environment:
16+
# MYSQL_DATABASE: symfony
17+
MYSQL_ROOT_PASSWORD: root
18+
MYSQL_USER: symfony
19+
MYSQL_PASSWORD: symfony
20+
phpmyadmin:
21+
image: phpmyadmin/phpmyadmin
22+
container_name: phpmyadmin
23+
environment:
24+
PMA_ARBITRARY: 1
25+
PMA_HOST: db
26+
PMA_USER: symfony
27+
PMA_PASSWORD: symfony
28+
PMA_PORT: 3306
29+
ports:
30+
- "8080:80"
31+
depends_on:
32+
- db

docker-entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# Install PDO MySQL extension
4+
docker-php-ext-install pdo_mysql
5+
6+
# Install dependencies
7+
composer install --no-scripts --no-interaction --prefer-dist
8+
9+
php bin/console sass:build
10+
php bin/console importmap:install
11+
12+
# Update DB
13+
php bin/console doctrine:schema:update --complete --force
14+
php bin/console doctrine:fixtures:load --no-interaction
15+
16+
# Start the PHP server
17+
symfony serve

0 commit comments

Comments
 (0)