Skip to content

Commit

Permalink
first version of docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
tolry committed Oct 25, 2024
1 parent 0cbc6d5 commit 1659dce
Show file tree
Hide file tree
Showing 14 changed files with 537 additions and 167 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ DATABASE_URL="mysql://mental_note:SOME_SECRET@127.0.0.1:3306/mental_note?serverV
APP_ENV=dev
APP_SECRET=5c5e72737c8468479c674ad5ff7f0dd7
###< symfony/framework-bundle ###
MEMCACHED_HOST=memcached
37 changes: 0 additions & 37 deletions app/config/config.yml

This file was deleted.

20 changes: 0 additions & 20 deletions app/config/config_dev.yml

This file was deleted.

19 changes: 0 additions & 19 deletions app/config/config_prod.yml

This file was deleted.

23 changes: 0 additions & 23 deletions app/config/config_test.yml

This file was deleted.

23 changes: 0 additions & 23 deletions app/config/parameters.yml.dist

This file was deleted.

14 changes: 0 additions & 14 deletions app/config/routing_dev.yml

This file was deleted.

40 changes: 20 additions & 20 deletions config/packages/cache.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
framework:
cache:
default_memcached_provider: "memcached://%session_memcache_host%:%session_memcache_port%"
system: cache.adapter.memcached
pools:
app.cache.pool.metainfo:
adapter: cache.adapter.memcached
public: false
# Unique name of your app: used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name
cache:
default_memcached_provider: "memcached://%env(MEMCACHED_HOST)%:11212"
system: cache.adapter.memcached
pools:
app.cache.pool.metainfo:
adapter: cache.adapter.memcached
public: false
# Unique name of your app: used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name

# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
# Other options include:
# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
# Other options include:

# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost
# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost

# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu

# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: null
# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: null
29 changes: 18 additions & 11 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
session_memcache_host: localhost
session_memcache_host: "%env(MEMCACHED_HOST)%"
session_memcache_port: 11211
session_memcache_prefix: mn_sess
session_memcache_expire: 604800 # 1 week
Expand All @@ -14,29 +14,29 @@ parameters:
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/'
resource: "../src/"
exclude:
- '../src/DependencyInjection/'
- '../src/Kernel.php'
- '../src/{Entity,Migrations,Tests,App}/'
- "../src/DependencyInjection/"
- "../src/Kernel.php"
- "../src/{Entity,Migrations,Tests,App}/"

# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller/'
tags: ['controller.service_arguments']
resource: "../src/Controller/"
tags: ["controller.service_arguments"]

pagerfanta.view.twitter_bootstrap4:
class: "Pagerfanta\\View\\TwitterBootstrap4View"
public: false
tags:
- {name: "pagerfanta.view", alias: "twitter_bootstrap4"}
- { name: "pagerfanta.view", alias: "twitter_bootstrap4" }

app.form.entry_type:
class: "App\\Form\\Type\\EntryType"
Expand All @@ -63,10 +63,17 @@ services:
app.memcached:
class: Memcached
calls:
- [ addServer, [ "%session_memcache_host%", "%session_memcache_port%" ]]
- [addServer, ["%session_memcache_host%", "%session_memcache_port%"]]

Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler:
arguments: [ "@app.memcached", { prefix: "%session_memcache_prefix%", expiretime: "%session_memcache_expire%" } ]
arguments:
[
"@app.memcached",
{
prefix: "%session_memcache_prefix%",
expiretime: "%session_memcache_expire%",
},
]

# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
web:
build:
context: .
dockerfile: docker/nginx/Dockerfile
ports:
- "8080:80"
volumes:
- .:/app/
links:
- php

php:
build:
context: .
dockerfile: docker/php/Dockerfile
volumes:
- .:/app/

memcached:
image: memcached:latest
links:
- php
7 changes: 7 additions & 0 deletions docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM nginx:1.17.8-alpine

# Copy the public directory
COPY ./public/ /app/public/

# Copy the nginx config file
COPY ./docker/nginx/nginx.conf /etc/nginx/conf.d/default.conf
20 changes: 20 additions & 0 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
server_tokens off;

root /app/public;
index index.php;

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

18 changes: 18 additions & 0 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM php:8.3.13-fpm-alpine

RUN docker-php-ext-install -j"$(nproc)" pdo pdo_mysql


RUN apk add --update --no-cache libmemcached-dev autoconf g++ make zlib-dev

RUN pecl install igbinary && docker-php-ext-enable igbinary
RUN pecl install memcached && docker-php-ext-enable memcached


# Copy the php config file
COPY ./docker/php/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf

# Copy the application code
COPY . /app

VOLUME ["/app"]
Loading

0 comments on commit 1659dce

Please sign in to comment.