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