Skip to content

Commit 5916925

Browse files
committed
feature: added docker sync, updated symfony to version 5.3 and make domain configurable
1 parent 3f969dc commit 5916925

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1415
-1208
lines changed

.devcontainer/devcontainer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
2+
{
3+
"name": "Symfony Docker",
4+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
5+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
6+
"dockerComposeFile": [
7+
"../.docker/docker-compose.yml"
8+
],
9+
// The 'service' property is the name of the service for the container that VS Code should
10+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
11+
"service": "php",
12+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
13+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
14+
"workspaceFolder": "/var/www/symfony",
15+
"shutdownAction": "none",
16+
// Use 'settings' to set *default* container specific settings.json values on container create.
17+
// You can edit these settings after create using File > Preferences > Settings > Remote.
18+
"settings": {
19+
// This will ignore your local shell user setting for Linux since shells like zsh are typically
20+
// not in base container images. You can also update this to an specific shell to ensure VS Code
21+
// uses the right one for terminals and tasks. For example, /bin/bash (or /bin/ash for Alpine).
22+
"terminal.integrated.shell.linux": null
23+
},
24+
// Uncomment the next line to have VS Code connect as an existing non-root user in the container. See
25+
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist.
26+
// "remoteUser": "vscode",
27+
// Uncomment the next line if you want start specific services in your Docker Compose config.
28+
// "runServices": [],
29+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
30+
// "shutdownAction": "none",
31+
// Uncomment the next line to run commands after the container is created - for example installing git.
32+
// "postCreateCommand": "apt-get install git openssh",
33+
// Add the IDs of extensions you want installed when the container is created in the array below.
34+
"extensions": [
35+
"bmewburn.vscode-intelephense-client",
36+
"junstyle.php-cs-fixer",
37+
"editorconfig.editorconfig",
38+
"neilbrayfield.php-docblocker",
39+
"kaiwood.insert-cursor-at-beginning-of-each-line-selected",
40+
"mykhailokushnir.vscode-php-getter-setter",
41+
"syler.sass-indented"
42+
]
43+
}

.docker/.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
COMPOSE_PROJECT_NAME=symfony_docker
2+
MYSQL_ROOT_PASSWORD=hello
3+
MYSQL_DATABASE=app_db
4+
MYSQL_USER=app_user
5+
MYSQL_PASSWORD=helloworld
6+
7+
TIMEZONE=Europe/Madrid

.docker/.env.nginx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NGINX_BACKEND_DOMAIN=''

docker-compose.yml renamed to .docker/docker-compose.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: "3"
22

33
services:
44
db:
@@ -17,26 +17,28 @@ services:
1717
- symfony
1818
php:
1919
build:
20-
context: .
21-
dockerfile: docker/php/Dockerfile
20+
context: ./php
2221
args:
2322
TIMEZONE: ${TIMEZONE}
2423
volumes:
25-
- ./symfony/:/var/www/symfony/
24+
- symfony_docker_app_sync:/var/www/symfony/
2625
networks:
2726
- symfony
2827
nginx:
2928
build:
30-
context: .
31-
dockerfile: docker/nginx/Dockerfile
29+
context: ./nginx
3230
volumes:
33-
- ./symfony/:/var/www/symfony/
31+
- symfony_docker_app_sync:/var/www/symfony/
3432
ports:
3533
- 80:80
3634
networks:
3735
- symfony
36+
env_file:
37+
- .env.nginx.local
3838

3939
volumes:
40+
symfony_docker_app_sync:
41+
external: true
4042
db_app:
4143

4244
networks:

.docker/docker-sync.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: "2"
2+
3+
options:
4+
compose-file-path: "docker-compose.yml"
5+
verbose: true
6+
7+
syncs:
8+
symfony_docker_app_sync:
9+
src: "../"
10+
sync_userid: "33"
11+
sync_excludes:
12+
- ".docker"
13+
- ".git"
14+
- "var"
15+
- "vendor"
16+
watch_excludes:
17+
- ".docker"
18+
- ".git"
19+
- "var"
20+
- "vendor"

.docker/nginx/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM nginx:1.21-alpine
2+
3+
COPY nginx.conf /etc/nginx/
4+
COPY templates /etc/nginx/templates/
5+
RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf
6+
7+
EXPOSE 80
8+
EXPOSE 443
File renamed without changes.

docker/nginx/default.conf renamed to .docker/nginx/templates/default.conf.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
server {
22
listen 80;
3-
server_name dev.symfony.com;
3+
server_name ${NGINX_BACKEND_DOMAIN};
44
root /var/www/symfony/public;
55

66
location / {

docker/php/Dockerfile renamed to .docker/php/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM php:7.4-fpm-buster
1+
FROM php:8.0-fpm-buster
22
ARG TIMEZONE
33

4-
COPY docker/php/php.ini /usr/local/etc/php/conf.d/docker-php-config.ini
4+
COPY php.ini /usr/local/etc/php/conf.d/docker-php-config.ini
55

66
RUN apt-get update && apt-get install -y \
77
gnupg \
File renamed without changes.

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
8+
9+
[*.{cs,js,sass,css,scss}]
10+
indent_size = 2
11+
12+
[*.json]
13+
indent_size = 2
14+
15+
[*.{html,twig}]
16+
indent_size = 2
17+
18+
[*.{php,yml,yaml}]
19+
indent_size = 4

.env

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
1-
MYSQL_ROOT_PASSWORD=hello
2-
MYSQL_DATABASE=app_db
3-
MYSQL_USER=app_user
4-
MYSQL_PASSWORD=helloworld
1+
COMPOSE_PROJECT_NAME=symfony_docker
2+
# In all environments, the following files are loaded if they exist,
3+
# the latter taking precedence over the former:
4+
#
5+
# * .env contains default values for the environment variables needed by the app
6+
# * .env.local uncommitted file with local overrides
7+
# * .env.$APP_ENV committed environment-specific defaults
8+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
9+
#
10+
# Real environment variables win over .env files.
11+
#
12+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
13+
#
14+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
15+
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
516

6-
TIMEZONE=Europe/Madrid
17+
###> symfony/framework-bundle ###
18+
APP_ENV=dev
19+
APP_SECRET=cb59b41603c2f9ee8360cb364f2dba1a
20+
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
21+
#TRUSTED_HOSTS='^localhost|example\.com$'
22+
###< symfony/framework-bundle ###
23+
24+
###> doctrine/doctrine-bundle ###
25+
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
26+
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
27+
# For a PostgreSQL database, use: "postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8"
28+
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
29+
DATABASE_URL=mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7
30+
###< doctrine/doctrine-bundle ###

symfony/.gitignore renamed to .gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/var/
88
/vendor/
99
###< symfony/framework-bundle ###
10+
/.docker/.env.nginx.local
File renamed without changes.

composer.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"type": "project",
3+
"license": "proprietary",
4+
"require": {
5+
"php": "^8.0",
6+
"ext-ctype": "*",
7+
"ext-iconv": "*",
8+
"composer/package-versions-deprecated": "1.11.99.4",
9+
"doctrine/doctrine-bundle": "^2",
10+
"doctrine/doctrine-migrations-bundle": "^2",
11+
"doctrine/orm": "^2",
12+
"symfony/console": "5.3.*",
13+
"symfony/dotenv": "5.3.*",
14+
"symfony/flex": "^1.3.1",
15+
"symfony/framework-bundle": "5.3.*",
16+
"symfony/yaml": "5.3.*"
17+
},
18+
"require-dev": {
19+
"symfony/maker-bundle": "^1.14"
20+
},
21+
"config": {
22+
"preferred-install": {
23+
"*": "dist"
24+
},
25+
"sort-packages": true
26+
},
27+
"autoload": {
28+
"psr-4": {
29+
"App\\": "src/"
30+
}
31+
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"App\\Tests\\": "tests/"
35+
}
36+
},
37+
"replace": {
38+
"paragonie/random_compat": "2.*",
39+
"symfony/polyfill-ctype": "*",
40+
"symfony/polyfill-iconv": "*",
41+
"symfony/polyfill-php72": "*",
42+
"symfony/polyfill-php71": "*",
43+
"symfony/polyfill-php70": "*",
44+
"symfony/polyfill-php56": "*"
45+
},
46+
"scripts": {
47+
"auto-scripts": {
48+
"cache:clear": "symfony-cmd",
49+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
50+
},
51+
"post-install-cmd": [
52+
"@auto-scripts"
53+
],
54+
"post-update-cmd": [
55+
"@auto-scripts"
56+
]
57+
},
58+
"conflict": {
59+
"symfony/symfony": "*"
60+
},
61+
"extra": {
62+
"symfony": {
63+
"allow-contrib": false,
64+
"require": "5.3.*"
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)