I have a Laravel and several Vue apps. I'm trying to deploy them on Digital Ocean using docker and nginx.
I've never deployed apps before, so I poorly understand the process. I've already deployed Laravel backend and I am thinking of deploying my vue apps in separate docker containers, but I dont actually understand how should I configure my nginx server.
I've found out I could build my frontend app into the Laravel's public folder, but this approach works with a single Vue app, while I have several.
I'd use some help on how to manage this. Thanks in advance!
Here's my docker-compose.yml(without vue yet) :
version: '3'
services:
nginx:
image: nginx:alpine
container_name: shop_nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./:/var/www/shop/backend
- ./nginx/conf.d/:/etc/nginx/conf.d/
- ./nginx/ssl/:/etc/nginx/ssl/
networks:
- shop
laravel:
container_name: shop_laravel
restart: unless-stopped
build:
context: .
dockerfile: Dockerfile
volumes:
- '.:/var/www/shop/backend'
networks:
- shop
depends_on:
- pgsql
- redis
pgsql:
container_name: shop_postgres
restart: unless-stopped
image: 'postgres:14'
ports:
- '5432:5432'
environment:
PGPASSWORD: 'shop'
POSTGRES_DB: 'shop'
POSTGRES_USER: 'shop'
POSTGRES_PASSWORD: 'shop'
volumes:
- 'shop-pgsql:/var/lib/postgresql/data'
networks:
- shop
redis:
container_name: shop_redis
restart: unless-stopped
image: 'redis:alpine'
ports:
- '6379:6379'
volumes:
- 'shop-redis:/data'
networks:
- shop
networks:
shop:
driver: bridge
volumes:
shop-pgsql:
driver: local
shop-redis:
driver: local
And nginx configuration:
server {
listen 80;
listen [::]:80;
server_name shop.laravel;
root /var/www/shop/backend/public;
index index.php;
charset utf-8;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass laravel:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}