Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Inpanic4's avatar

Deploy multiple laravel apps to digital ocean droplet using Docker

Hello, ive been struggling all day what is the appropiate way to deploy multiple apps on a single droplet using docker. I successfully deployed 1 app but what about deploying a second on same droplet? Should i use a reserve proxy? Should i use 1 nginx and mysql container for all apps, or every app has its own? Should i make ssl certificate for every app or can i make only 1 for all apps? Can not find anywhere a video showcasing this scenario.

server {
    listen 443 ssl;

    index index.php index.html;
    server_name mydomain.com;
    root /var/www/html/public;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
}

DockerFile:

networks:
  laravel:
    name: laravel

services:
  nginx:
    build:
      context: .
      dockerfile: nginx.prod.dockerfile
    container_name: nginx
    volumes:
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    depends_on:
      - php
      - mysql
    ports:
      - 80:80
      - 443:443
    networks:
      - laravel

  php:
    build:
      context: .
      dockerfile: php.prod.dockerfile
    container_name: php
    networks:
      - laravel

  mysql:
    image: mysql:8.3.0
    container_name: mysql
    ports:
      - 4306:3306
    environment:
      MYSQL_DATABASE: laraveldb
      MYSQL_USER: laravel
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: secret
    networks:
      - laravel

  composer:
    image: composer:latest
    container_name: composer
    volumes:
      - ./src:/var/www/html
    working_dir: /var/www/html
    networks:
      - laravel

  artisan:
    build:
      context: .
      dockerfile: php.prod.dockerfile
    container_name: artisan
    working_dir: /var/www/html
    entrypoint: ["php", "artisan"]
    networks:
      - laravel

  npm:
    image: node:latest
    container_name: npm
    volumes: 
      - ./src:/var/www/html
    working_dir: /var/www/html
    entrypoint: ["npm"]
    networks:
      - laravel

  certbot:
    image: certbot/certbot
    volumes:
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
0 likes
0 replies

Please or to participate in this conversation.