# Docker
# Build containers
# web
The web
container comes with nginx and php8.1-fpm.
docker build -t web . \
-f .docker/web/Dockerfile \
--build-arg "NOVA_USERNAME=" \
--build-arg "NOVA_LICENSE_KEY="
docker run --name web \
-p 80:80 \
-v "$(pwd)/.docker/web/app.conf:/etc/nginx/conf.d/app.conf" \
-v "$(pwd)/.env:/app/.env" \
web
# cli
The cli
container will run any command provided by the command
argument. By default the run/scheduler.sh
script will be executed. artisan queue:work
command.
docker build -t cli . \
-f .docker/queue/Dockerfile \
--build-arg "NOVA_USERNAME=" \
--build-arg "NOVA_LICENSE_KEY="
# Run cli as scheduler
docker run --name cli \
-v "$(pwd)/.env:/app/.env" \
queue \
run/scheduler.sh
# Run cli as queue
An additional QUEUE
environment variable can be passed to configure the queue name.
docker run --name cli \
-v "$(pwd)/.env:/app/.env" \
-e QUEUE=default \
cli \
run/queue.sh
# Docker Compose
# Production docker-compose.yml
Note: You will need to specify the following environment variables. See the Docker .env.example file for more information.
COMPOSE_PROJECT_NAME
REPOSITORY_URL
Container registry URL (___.dkr.ecr.___.amazonaws.com/repository
)DB_ROOT_PASSWORD
Initial root password for database containerDB_DATABASE
Database to be created on startup
# Start docker stack
docker-compose -f docker-compose.yml up
version: "3.9"
services:
web:
image: "${REPOSITORY_URL}/web:latest"
restart: unless-stopped
env_file:
- ./web/.env
volumes:
- ./web/app.conf:/etc/nginx/conf.d/app.conf
- ./web/.env:/app/.env
- ./storage/app:/app/storage/app
- ./storage/logs:/app/storage/logs
ports:
- "8000:80"
networks:
- app-network
queue:
image: "${REPOSITORY_URL}/cli:latest"
command: ["sh", "run/queue.sh"]
restart: unless-stopped
env_file:
- ./web/.env
environment:
QUEUE: default
volumes:
- ./web/.env:/app/.env
- ./storage/app:/app/storage/app
- ./storage/logs:/app/storage/logs
networks:
- app-network
depends_on:
- database
scheduler:
image: "${REPOSITORY_URL}/cli:latest"
command: ["sh", "run/scheduler.sh"]
restart: unless-stopped
env_file:
- ./web/.env
volumes:
- ./web/.env:/app/.env
- ./storage/app:/app/storage/app
- ./storage/logs:/app/storage/logs
networks:
- app-network
depends_on:
- database
database:
image: mariadb:latest
restart: unless-stopped
ports:
- "8001:3306"
volumes:
- ./database:/var/lib/mysql
environment:
MARIADB_ROOT_PASSWORD: $DB_ROOT_PASSWORD
MARIADB_ROOT_HOST: "%"
MARIADB_DATABASE: $DB_DATABASE
networks:
- app-network
redis:
image: redis:latest
restart: unless-stopped
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
backend-volume:
# Local docker-compose.yml
The local docker compose file uses the included Dockerfiles to build and spin up containers.
Note: You will need to specify the following environment variables. See the Docker .env.example file for more information.
COMPOSE_PROJECT_NAME
NOVA_USERNAME
Laravel Nova usernameNOVA_LICENSE_KEY
Laravel Nova password/API keyDB_ROOT_PASSWORD
Initial root password for database containerDB_DATABASE
Database to be created on startup
# Start docker stack
docker-compose -f docker-compose.local.yml up
docker-compose -f docker-compose.local.yml up --build
# Migrate database
docker exec -it web php artisan migrate
You should be able to access the skeleton at localhost:8000 (opens new window).
version: "3.9"
services:
web:
restart: unless-stopped
env_file:
- ./web/.env
build:
context: $LOCAL_PROJECT_PATH
dockerfile: .docker/web/Dockerfile
args:
NOVA_USERNAME: $NOVA_USERNAME
NOVA_LICENSE_KEY: $NOVA_LICENSE_KEY
volumes:
- ./web/app.conf:/etc/nginx/conf.d/app.conf
- ./web/.env:/app/.env
- ./storage/app:/app/storage/app
- ./storage/logs:/app/storage/logs
ports:
- "8000:80"
networks:
- app-network
queue:
command: ["sh", "run/queue.sh"]
restart: unless-stopped
env_file:
- ./web/.env
build:
context: $LOCAL_PROJECT_PATH
dockerfile: .docker/queue/Dockerfile
args:
NOVA_USERNAME: $NOVA_USERNAME
NOVA_LICENSE_KEY: $NOVA_LICENSE_KEY
environment:
QUEUE: default
volumes:
- ./web/.env:/app/.env
- ./storage/app:/app/storage/app
- ./storage/logs:/app/storage/logs
networks:
- app-network
depends_on:
- database
scheduler:
command: ["sh", "run/scheduler.sh"]
restart: unless-stopped
env_file:
- ./web/.env
build:
context: $LOCAL_PROJECT_PATH
dockerfile: .docker/scheduler/Dockerfile
args:
NOVA_USERNAME: $NOVA_USERNAME
NOVA_LICENSE_KEY: $NOVA_LICENSE_KEY
volumes:
- ./web/.env:/app/.env
- ./storage/app:/app/storage/app
- ./storage/logs:/app/storage/logs
networks:
- app-network
depends_on:
- database
database:
image: mariadb:latest
restart: unless-stopped
ports:
- "8001:3306"
volumes:
- ./database:/var/lib/mysql
environment:
MARIADB_ROOT_PASSWORD: $DB_ROOT_PASSWORD
MARIADB_ROOT_HOST: "%"
MARIADB_DATABASE: $DB_DATABASE
networks:
- app-network
redis:
image: redis:latest
restart: unless-stopped
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
backend-volume:
← Frontend Deployment →