Set symfony cache directory in options

I am creating a docker environment for a Symfony application. I have a container for each application with an attached data container for the web root that is associated with the application server. As part of simplifying security for the infrastructure, these data containers are read-only to prevent any remote code exploits. Each application also has a side car container that allows you to record magazines.

Symfony is currently writing cache cache_dirto the default location

${web_root}/app/cache/${env}

What is in the read-only data container

when I try to download the application, I get this error

Unable to write to cache directory

Obviously this will happen in a write-only container

I found that my log_path is set in parameters outside the read-only container in the sidecar read-write logging container

/data/logs/symfony

which works great.

I read a cookbook Symfony book on how to move around in the directory structure, but it only suggests how to do it in AppKernal.phpthat I do not want to do, because the path may vary depending on local/uat/prodthe environment.

We pass Symfony various parameters from our build server, depending on the environment in which we are deploying, so it makes sense to include this configuration here.

Does anyone know if it is possible to override it in the cache directory and not edit it AppKernal.php

+3
source share
2

yml docker-compose, , 2 sidecar : rw-, ,

-Compose-base.yml

version: '2.0'

# maintainer james.kirkby@sonyatv.com
# @big narstie said "dont f*** up the #base"

services:

  # web server
  pitchapp-web:
    hostname: pitchapp-web
    depends_on:
      - pitchapp-dc   
      - pitchapp-log-sc
      - pitchapp-cache-sc
      - pitchapp-fpm
    volumes_from:
      - pitchapp-dc
      - pitchapp-log-sc:rw
      - pitchapp-cache-sc:rw
    links:
      - pitchapp-fpm
    build:
      args: 
        - APP_NAME=pitchapp  
        - FPM_POOL=pitchapp-fpm
        - FPM_PORT=9001
        - PROJECT=pitch
        - APP_VOL_DIR=/data/www
        - CONFIG_FOLDER=app/config
        - ENVIRONMENT=dev
        - ENV_PATH=dev   
      context: ./pitch
      dockerfile: Dockerfile
    ports:
      - "8181:80"
    extends:
      file: "shared/dev-common.yml"
      service: dev-common-env
    env_file: 
      - env/dev.env

  # web data-container
  pitchapp-dc: 
    volumes:
      - /data/tmp:/data/tmp:rw      
      - /Sites/pitch/pitchapp:/data/www/dev/pitch/pitchapp/current:ro
    hostname: pitchapp-dc
    container_name: pitchapp-dc       
    extends:
      file: "shared/data-container-common.yml"
      service: data-container-common-env
    read_only: true
    working_dir: /data/www                      

  # web cache sidecar
  pitchapp-cache-sc:
    volumes:
      - /data/cache/pitchapp:/data/www/dev/pitch/pitchapp/current/app/cache/dev:rw
    hostname: pitchapp-cache-sc
    container_name: pitchapp-cache-sc
    extends:
      file: "shared/data-container-common.yml"
      service: data-container-common-env              
    read_only: false
    working_dir: /data/cache    

  # web log sidecar
  pitchapp-log-sc: 
volumes:
  - /data/log/pitchapp:/data/log:rw   
  - /data/log/pitchapp/symfony:/data/www/dev/pitch/pitchapp/current/app/logs:rw   
    build:
      args:
        - APP_NAME=pitchapp          
        - TARGET_SERVICE=pitchapp
    hostname: pitchapp-log-sc
    container_name: pitchapp-log-sc
    extends:
      file: "shared/logging-common.yml"
      service: logging-common-env       

-common.yml

version: '2.0'

services:
  data-container-common-env:
    build:
      context: ./docker-data-container
      dockerfile: Dockerfile 
    image: jkirkby91/docker-data-container   
    env_file: 
      - env/data.env           
    restart: always
    privileged: false 
    tty: false
    shm_size: 64M
    stdin_open: true

common.yml

version: '2.0'

services:
  logging-common-env:
    build:
      context: ./logging
      dockerfile: Dockerfile
    image: jkirkby91/docker-data-container    
    env_file: 
      - env/logging.env           
    restart: always
    working_dir: /data/log
    privileged: false 
    tty: false
    shm_size: 64M
    stdin_open: true       
    read_only: false     
+1

-v

$DIR -

htdocs,

docker run -d \
   -v $DIR/htdocs:/var/www/html \
   -v $DIR/cache_folder:/var/www/html/app/cache

, cache_folder. , - , . /var/www/html/app/cache

, , ,

chmod -R 777 ${web_root}/app/cache/${env}
+3

All Articles