github.com/drud/ddev@v1.21.5-alpha1.0.20230226034409-94fcc4b94453/pkg/ddevapp/app_compose_template.yaml (about)

     1  name: ${COMPOSE_PROJECT_NAME}
     2    {{ .DdevGenerated }}
     3  services:
     4    {{ if not .OmitDB }}
     5    db:
     6      container_name: {{ .Plugin }}-${DDEV_SITENAME}-db
     7      build:
     8        context: '{{ .DBBuildContext }}'
     9        args:
    10          BASE_IMAGE: $DDEV_DBIMAGE
    11          username: '{{ .Username }}'
    12          uid: '{{ .UID }}'
    13          gid: {{ if ne .DBType "postgres" }} {{ .GID }} {{ else }} "999" {{ end }}
    14      image: ${DDEV_DBIMAGE}-${DDEV_SITENAME}-built
    15      cap_add:
    16        - SYS_NICE
    17      stop_grace_period: 60s
    18      working_dir: "{{ .DBWorkingDir }}"
    19      volumes:
    20        - type: "volume"
    21          source: "database"
    22          target: "{{ .DBMountDir }}"
    23          volume:
    24            nocopy: true
    25        {{ if .NoBindMounts }}
    26        - ddev-config:/mnt/ddev_config
    27        - snapshots:/mnt/snapshots
    28        {{ else }} {{/* if .NoBindMounts */}}
    29        - .:/mnt/ddev_config
    30        - ./db_snapshots:/mnt/snapshots
    31        {{ end }} {{/* end if .NoBindMounts */}}
    32        - ddev-global-cache:/mnt/ddev-global-cache
    33      restart: "{{ if .AutoRestartContainers }}always{{ else }}no{{ end }}"
    34  
    35      # The postgres image is set up for user 999, we won't try to change that.
    36      user: {{ if ne .DBType "postgres" }} '$DDEV_UID:$DDEV_GID' {{ else }} "999:999" {{end}}
    37      hostname: {{ .Name }}-db
    38      ports:
    39        - "{{ .DockerIP }}:$DDEV_HOST_DB_PORT:{{ .DBPort }}"
    40      labels:
    41        com.ddev.site-name: ${DDEV_SITENAME}
    42        com.ddev.platform: {{ .Plugin }}
    43        com.ddev.app-type: {{ .AppType }}
    44        com.ddev.approot: $DDEV_APPROOT
    45      environment:
    46        - COLUMNS
    47        - DDEV_DATABASE
    48        - DDEV_HOSTNAME
    49        - DDEV_PHP_VERSION
    50        - DDEV_PRIMARY_URL
    51        - DDEV_PROJECT
    52        - DDEV_PROJECT_TYPE
    53        - DDEV_ROUTER_HTTP_PORT
    54        - DDEV_ROUTER_HTTPS_PORT
    55        - DDEV_SITENAME
    56        - DDEV_TLD
    57        - DOCKER_IP={{ .DockerIP }}
    58        - GOARCH
    59        - GOOS
    60        - HOST_DOCKER_INTERNAL_IP={{ .HostDockerInternalIP }}
    61        - IS_DDEV_PROJECT=true
    62        - LINES
    63        - MYSQL_HISTFILE=/mnt/ddev-global-cache/mysqlhistory/${DDEV_SITENAME}-db/mysql_history
    64        - MYSQL_PWD=db
    65        - PGDATABASE=db
    66        - PGHOST=127.0.0.1
    67        - PGPASSWORD=db
    68        - PGUSER=db
    69        - POSTGRES_PASSWORD=db
    70        - POSTGRES_USER=db
    71        - POSTGRES_DB=db
    72        - TZ={{ .Timezone }}
    73        - USER={{ .Username }}
    74      command: ${DDEV_DB_CONTAINER_COMMAND}
    75      healthcheck:
    76        {{ if eq .DBType "postgres" }}
    77        test: ["CMD-SHELL", "/postgres_healthcheck.sh"]
    78        {{ end }}
    79        interval: 1s
    80        retries: 120
    81        start_period: 120s
    82        timeout: 120s
    83    {{ end }} {{/* end if not .OmitDB */}}
    84  
    85    web:
    86      container_name: {{ .Plugin }}-${DDEV_SITENAME}-web
    87      build:
    88        context: '../'
    89        dockerfile: './.ddev/.webimageBuild/Dockerfile'
    90        args:
    91          BASE_IMAGE: $DDEV_WEBIMAGE
    92          username: '{{ .Username }}'
    93          uid: '{{ .UID }}'
    94          gid: '{{ .GID }}'
    95          DDEV_PHP_VERSION: ${DDEV_PHP_VERSION}
    96      image: ${DDEV_WEBIMAGE}-${DDEV_SITENAME}-built
    97      {{ if .EnvFile }}
    98      env_file: '{{ .EnvFile }}'
    99      {{ end }}
   100  
   101      {{ if .UseHostDockerInternalExtraHosts }}
   102      extra_hosts:
   103        - "host.docker.internal:host-gateway"
   104      {{ end }}
   105      networks: ["default", "ddev_default"]
   106      cap_add:
   107        - SYS_PTRACE
   108      working_dir: "{{ .WebWorkingDir }}"
   109  
   110      {{ .WebExtraExposedPorts }}
   111  
   112      volumes:
   113        {{ if and (not .MutagenEnabled) (not .NoProjectMount) }}
   114        - type: {{ .MountType }}
   115          source: {{ .WebMount }}
   116          target: /var/www/html
   117          {{ if eq .MountType "volume" }}
   118          volume:
   119            nocopy: true
   120          {{ else }} {{/* if eq .MountType "volume"*/}}
   121          consistency: cached
   122          {{ end }} {{/* end if eq .MountType "volume" */}}
   123        {{ end }} {{/* end if and (not .MutagenEnabled) (not .NoProjectMount)*/}}
   124        {{ if and .MutagenEnabled (not .NoProjectMount) }}
   125        # For mutagen, mount a directory higher in /var/www so that we can use
   126        # stageMode: "neighboring"
   127        - type: volume
   128          source: project_mutagen
   129          target: /var/www
   130          volume:
   131            nocopy: true
   132        # /var/tmp/html mount is there only so project can be accessed as bind-mount during
   133        # start.sh
   134        - "{{ .WebMount }}:/var/tmp/html:ro"
   135        # This second mutagen mount is only to make just the volume available so it can be chowned
   136        # without accidentally also hitting docker mounts
   137        - type: volume
   138          source: project_mutagen
   139          target: /tmp/project_mutagen
   140          volume:
   141            nocopy: true
   142  
   143        {{ end }}
   144        {{ if .NoBindMounts }}
   145        - "ddev-config:/mnt/ddev_config"
   146        {{ else }}
   147        - ".:/mnt/ddev_config:ro"
   148        - "./xhprof:/usr/local/bin/xhprof:ro"
   149          {{ if .MutagenEnabled }}
   150            {{ if .ContainerUploadDir }}
   151        - {{ .HostUploadDir }}:{{ .ContainerUploadDir }}:rw
   152            {{ end }} {{/* end if .ContainerUploadDir */}}
   153            {{ if .GitDirMount }}
   154        - ../.git:/var/www/html/.git:rw
   155            {{ end }} {{/* end if .GitDirMount */}}
   156          {{ end }} {{/* end if .MutagenEnabled */}}
   157        {{ end }} {{/* end else of if .NoBindMounts */}}
   158        - "ddev-global-cache:/mnt/ddev-global-cache"
   159        {{ if not .OmitSSHAgent }}
   160        - "ddev-ssh-agent_socket_dir:/home/.ssh-agent"
   161        {{ end }}
   162  
   163      restart: "{{ if .AutoRestartContainers }}always{{ else }}no{{ end }}"
   164      user: '$DDEV_UID:$DDEV_GID'
   165      hostname: {{ .Name }}-web
   166  
   167      ports:
   168        - "{{ .DockerIP }}:$DDEV_HOST_WEBSERVER_PORT:80"
   169        - "{{ .DockerIP }}:$DDEV_HOST_HTTPS_PORT:443"
   170      {{ if .HostMailhogPort }}
   171        - "{{ .DockerIP }}:{{ .HostMailhogPort }}:8025"
   172      {{ end }}
   173      environment:
   174      - COLUMNS
   175      - DOCROOT=${DDEV_DOCROOT}
   176      - DDEV_COMPOSER_ROOT
   177      - DDEV_DATABASE
   178      - DDEV_DOCROOT
   179      - DDEV_HOSTNAME
   180      - DDEV_MUTAGEN_ENABLED
   181      - DDEV_PHP_VERSION
   182      - DDEV_PRIMARY_URL
   183      - DDEV_PROJECT
   184      - DDEV_PROJECT_TYPE
   185      - DDEV_ROUTER_HTTP_PORT
   186      - DDEV_ROUTER_HTTPS_PORT
   187      - DDEV_SITENAME
   188      - DDEV_TLD
   189      - DDEV_FILES_DIR
   190      - DDEV_WEBSERVER_TYPE
   191      - DDEV_XDEBUG_ENABLED
   192      - DDEV_VERSION
   193      - DEPLOY_NAME=local
   194      {{ if not .DisableSettingsManagement }}
   195      - DRUSH_OPTIONS_URI=$DDEV_PRIMARY_URL
   196      {{ end }}
   197      - DRUSH_ALLOW_XDEBUG=1
   198      - DOCKER_IP={{ .DockerIP }}
   199      - GOARCH
   200      - GOOS
   201      - HOST_DOCKER_INTERNAL_IP={{ .HostDockerInternalIP }}
   202      # HTTP_EXPOSE allows for ports accepting HTTP traffic to be accessible from <site>.ddev.site:<port>
   203      # To expose a container port to a different host port, define the port as hostPort:containerPort
   204      - HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}:{{ .MailhogPort }}{{ .WebExtraHTTPPorts }}
   205      # You can optionally expose an HTTPS port option for any ports defined in HTTP_EXPOSE.
   206      # To expose an HTTPS port, define the port as securePort:containerPort.
   207      - HTTPS_EXPOSE=${DDEV_ROUTER_HTTPS_PORT}:80,${DDEV_MAILHOG_HTTPS_PORT}:{{ .MailhogPort }}{{ .WebExtraHTTPSPorts }}
   208      - IS_DDEV_PROJECT=true
   209      - LINES
   210      - MYSQL_HISTFILE=/mnt/ddev-global-cache/mysqlhistory/${DDEV_SITENAME}-web/mysql_history
   211      - MYSQL_PWD=db
   212      - NODE_EXTRA_CA_CERTS=/mnt/ddev-global-cache/mkcert/rootCA.pem
   213      - npm_config_cache=/mnt/ddev-global-cache/npm
   214      - PGDATABASE=db
   215      - PGHOST=db
   216      - PGPASSWORD=db
   217      - PGUSER=db
   218      - PHP_IDE_CONFIG=serverName=${DDEV_SITENAME}.${DDEV_TLD}
   219      - SSH_AUTH_SOCK=/home/.ssh-agent/socket
   220      - TZ={{ .Timezone }}
   221      - USER={{ .Username }}
   222      - VIRTUAL_HOST=${DDEV_HOSTNAME}
   223      {{ range $env := .WebEnvironment }}- "{{ $env }}"
   224      {{ end }}
   225      labels:
   226        com.ddev.site-name: ${DDEV_SITENAME}
   227        com.ddev.platform: {{ .Plugin }}
   228        com.ddev.app-type: {{ .AppType }}
   229        com.ddev.approot: $DDEV_APPROOT
   230  
   231        {{ if .HostDockerInternalIP }}
   232      extra_hosts: [ "host.docker.internal:{{ .HostDockerInternalIP }}" ]
   233        {{ end }}
   234        {{ if not .OmitRouter }}
   235      external_links:
   236        {{ range $hostname := .Hostnames }}- "ddev-router:{{ $hostname }}"
   237        {{ end }}
   238        {{ end }}
   239      healthcheck:
   240        interval: 1s
   241        retries: 120
   242        start_period: 120s
   243        timeout: 120s
   244  
   245    {{ if not .OmitDBA }}
   246    dba:
   247      container_name: ddev-${DDEV_SITENAME}-dba
   248      image: $DDEV_DBAIMAGE
   249      working_dir: "{{ .DBAWorkingDir }}"
   250      restart: "{{ if .AutoRestartContainers }}always{{ else }}no{{ end }}"
   251      labels:
   252        com.ddev.site-name: ${DDEV_SITENAME}
   253        com.ddev.platform: {{ .Plugin }}
   254        com.ddev.app-type: {{ .AppType }}
   255        com.ddev.approot: $DDEV_APPROOT
   256      expose:
   257        - "80"
   258      {{ if .HostPHPMyAdminPort }}
   259      ports:
   260        - "{{ .DockerIP }}:{{ .HostPHPMyAdminPort }}:80"
   261      {{ end }} {{/* end if .HostPHPMyAdminPort */}}
   262      hostname: {{ .Name }}-dba
   263      environment:
   264      - PMA_USER=root
   265      - PMA_PASSWORD=root
   266      - VIRTUAL_HOST=$DDEV_HOSTNAME
   267      - UPLOAD_LIMIT=1024M
   268      - TZ={{ .Timezone }}
   269      # HTTP_EXPOSE allows for ports accepting HTTP traffic to be accessible from <site>.ddev.site:<port>
   270      - HTTP_EXPOSE=${DDEV_PHPMYADMIN_PORT}:{{ .DBAPort }}
   271      - HTTPS_EXPOSE=${DDEV_PHPMYADMIN_HTTPS_PORT}:{{ .DBAPort }}
   272      healthcheck:
   273        interval: 120s
   274        timeout: 2s
   275        retries: 1
   276      {{ end }}{{/* end if not .OmitDBA */}}
   277  networks:
   278    ddev_default:
   279      name: ddev_default
   280      external: true
   281    {{if .IsGitpod}}{{/* see https://github.com/drud/ddev/issues/3766 */}}
   282    default:
   283      driver_opts:
   284        com.docker.network.driver.mtu: 1440
   285    {{end}}
   286  
   287  volumes:
   288    {{if and (not .OmitDB) (ne .DBType "postgres") }}
   289    database:
   290      name: "{{ .MariaDBVolumeName}}"
   291      external: true
   292    {{ end }} {{/* end if and (not .OmitDB) (ne .DBType postgres) */}}
   293    
   294    {{if and (not .OmitDB) ( eq .DBType "postgres") }}
   295    database:
   296      name: "{{ .PostgresVolumeName }}"
   297      external: true
   298    {{ end }} {{/* end if and (not .OmitDB) ( ne .DBType postgres) */}}
   299  
   300    {{ if not .OmitSSHAgent }}
   301    ddev-ssh-agent_socket_dir:
   302      external: true
   303    {{ end }}{{/* end if not .OmitSSHAgent */}}
   304    ddev-global-cache:
   305      name: ddev-global-cache
   306      external: true
   307    {{ if .NoBindMounts }}
   308    ddev-config:
   309      name: ${DDEV_SITENAME}-ddev-config
   310      external: true
   311    snapshots:
   312      name: ddev-${DDEV_SITENAME}-snapshots
   313      external: true
   314    {{ end }}{{/* end if .NoBindMounts */}}
   315    {{ if and .NFSMountEnabled (not .NoProjectMount) }}
   316    nfsmount:
   317      name: "{{ .NFSMountVolumeName }}"
   318      driver: local
   319      driver_opts:
   320        type: nfs
   321        o: "addr={{ .NFSServerAddr }},hard,nolock,rw,wsize=32768,rsize=32768"
   322        device: ':{{ .NFSSource }}'
   323    {{ end }}{{/* end if and .NFSMountEnabled (not .NoProjectMount) */}}
   324    {{ if and .MutagenEnabled (not .NoProjectMount) }}
   325    project_mutagen:
   326      name: {{ .MutagenVolumeName }}
   327      external: true
   328  
   329    {{ end }}{{/* end if and .MutagenEnabled (not .NoProjectMount) */}}