Soy nueva en docker y estoy configurando el entorno para mi api. Tengo mi archivo docker-compose yml y otras dos carpetas necesarias para mi proyecto (nginx y php). Cuando ejecuto make run, solo se me crea una imagen, pero el volumen, el container y la carpeta de la base de datos NO se me crearon. Tambien tengo el error "unable to prepare context: path "./docker/database" not found"
- archivo docker-compose yml
version: '3.5'
# --------------------- SERVICIOS PARA LA WEB --------------------------- #
services:
symfony-api-platform-web:
container_name: symfony-api-platform-web
build:
context: ./docker/nginx
args:
UID: $U_ID
ports:
- 250:80
volumes:
- ./public:/appdata/www/public
depends_on:
- symfony-api-platform-be
networks:
- symfony-api-platform-network
# ----------------------------------------------------------------------- #
#--------------------- SERVICIOS DEL INTERPRETE DE PHP ----------------- #
symfony-api-platform-be:
container_name: symfony-api-platform-be
build:
context: docker/php
args:
UID: $U_ID
environment:
PHP_IDE_CONFIG: serverName=Docker
PHP_XDEBUG_ENABLED: 1
XDEBUG_CONFIG: remote_host=172.17.0.1 remote_port=9005 # Linux users
# XDEBUG_CONFIG: remote_host=host.docker.internal remote_port=9005 # MacOS users
volumes:
- ./:/appdata/www
- ./docker/php/xdebug-linux.ini:/usr/local/etc/php/conf.d/xdebug.ini
# - ./docker/php/xdebug-macos.ini:/usr/local/etc/php/conf.d/xdebug.ini
- ~/.ssh/id_rsa:/home/appuser/.ssh/id_rsa
depends_on:
- symfony-api-platform-db
networks:
- symfony-api-platform-network
# ---------------------------------------------------------------------- #
# ------------------------- SERVICIOS PARA LA BD ------------------------ #
symfony-api-platform-db:
container_name: symfony-api-platform-db
image: mysql:8.0
build:
context: ./docker/database
ports:
- 36000:3306
# el primer puerto es LOCAL , el segundo del CONTENEDOR
environment:
MYSQL_DATABASE: symfony_db
MYSQL_USER: root
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: root
command: mysqld --sql_mode="STRICT_ALL_TABLES,NO_ENGINE_SUBSTITUTION"
volumes:
- symfony-api-platform-db-data:/var/lib/mysql
networks:
- symfony-api-platform-network
# ---------------------------------------------------------------------- #
volumes:
symfony-api-platform-db-data:
networks:
symfony-api-platform-network:
external: true
- archivo Makefile
DOCKER_BE = symfony-api-platform-be
OS := $(shell uname)
ifeq ($(OS),Darwin)
UID = $(shell id -u)
else ifeq ($(OS),Linux)
UID = $(shell id -u)
else
UID = 1000
endif
help: ## Show this help message
@echo 'usage: make [target]'
@echo
@echo 'targets:'
@egrep '^(.+)\:\ ##\ (.+)' ${MAKEFILE_LIST} | column -t -c 2 -s ':#'
run: ## Start the containers
docker network create symfony-api-platform-network || true
U_ID=${UID} docker-compose up -d
stop: ## Stop the containers
U_ID=${UID} docker-compose stop
restart: ## Restart the containers
$(MAKE) stop && $(MAKE) run
build: ## Rebuilds all the containers
U_ID=${UID} docker-compose build
prepare: ## Runs backend commands
$(MAKE) composer-install
# Backend commands
composer-install: ## Installs composer dependencies
U_ID=${UID} docker exec --user ${UID} -it ${DOCKER_BE} composer install --no-scripts --no-interaction --optimize-autoloader
migrations: ## Runs the migrations
U_ID=${UID} docker exec -it --user ${UID} ${DOCKER_BE} bin/console doctrine:migrations:migrate -n
be-logs: ## Tails the Symfony dev log
U_ID=${UID} docker exec -it --user ${UID} ${DOCKER_BE} tail -f var/log/dev.log
# End backend commands
ssh-be: ## ssh's into the be container
U_ID=${UID} docker exec -it --user ${UID} ${DOCKER_BE} bash
code-style: ## Runs php-cs to fix code styling following Symfony rules
U_ID=${UID} docker exec -it --user ${UID} ${DOCKER_BE} php-cs-fixer fix src --rules=@Symfony
U_ID=${UID} docker exec -it --user ${UID} ${DOCKER_BE} php-cs-fixer fix tests --rules=@Symfony
generate-ssh-keys: ## Generates SSH keys for the JWT library
U_ID=${UID} docker exec -it --user ${UID} ${DOCKER_BE} mkdir -p config/jwt
U_ID=${UID} docker exec -it --user ${UID} ${DOCKER_BE} openssl genrsa -passout pass:767b453a97ac019714eb7ccbce781d16 -out config/jwt/private.pem -aes256 4096
U_ID=${UID} docker exec -it --user ${UID} ${DOCKER_BE} openssl rsa -pubout -passin pass:767b453a97ac019714eb7ccbce781d16 -in config/jwt/private.pem -out config/jwt/public.pem