I am unable to setup build for my laravel project with mysql db.
I’m sorry to hear that.
(I guess you intended to show us your Circle config and any error messages you get - unfortunately my crystal ball has run out of batteries, so we’re just going to have to help the non-supernatural way).
Can you share your config and any error messages that you get? Please take a look at this post for how to get help faster in the future.
version: 2
jobs:
build:
docker:
- image: circleci/php:7.1-node-browsers
environment:
MYSQL_HOST: 127.0.0.1
MYSQL_DB: mate
MYSQL_USER: root
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_PASSWORD:
- image: mysql:5.7
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --innodb-large-prefix=true --innodb-file-format=Barracuda
environment:
MYSQL_USER: root
MYSQL_ALLOW_EMPTY_PASSWORD: true
working_directory: ~/laravel
steps:
- checkout
- run: sudo apt install -y libsqlite3-dev zlib1g-dev
- run: sudo docker-php-ext-install zip
- run: sudo composer self-update
- restore_cache:
keys:
- composer-v1-{{ checksum "composer.lock" }}
- composer-v1-
- run: composer install --dev --ignore-platform-reqs
- save_cache:
key: composer-v1-{{ checksum "composer.lock" }}
paths:
- vendor
- run:
name: Mysql database
command: mysql -h 127.0.0.1 -u root -e "create database mate;"
- run: cp .env.travis .env
- run: php artisan key:generate
- run: php artisan migrate
- run: mkdir -p build/logs
- run: php vendor/bin/phpunit tests/ --coverage-clover build/logs/clover.xml
- run: php vendor/bin/phpcbf --standard=ruleset.xml app/
- run: php vendor/bin/phpcs --standard=ruleset.xml app/
It shows the error mysql
not found and can you pls let me know how to write code for continuous deployment on DigitalOcean droplet.
I’m guessing the answer is in the manual (see the bolded part):
It is possible to specify multiple images for your job. Specify multiple images if, for example, you need to use a database for your tests or for some other required service. In a multi-image configuration job, all steps are executed in the container created by the first image listed.
So, you are trying to run the mysql
binary on the first container, when MySQL is installed only on the second container.
To solve this, add a new run
line after checkout
which does something like:
sudo apt install -y mysql-client
You only need the client here, rather than a full server.
Thanks alot, It works and please help me in deployment on digitalocean droplet.
Great!
That’s not a question, that’s a request for free private tuition
My answer is “no”, of course, but if you make a solid effort to try getting a CD working based on the excellent documentation, and then ask a specific and focussed question if you have exhausted every other avenue, then someone will be pleased to help.
Good luck!
Update
While the following advice was written for Stack Overflow, it is a a very worthwhile read, even if it is a bit hyperbolic: How much research effort is expected of Stack Overflow users? I think it is relevant to all volunteer-powered fora on the web.
We now have docs explaining how to use MySQL with CircleCI
https://circleci.com/docs/2.0/postgres-config/#example-ruby-project-with-mysql-and-dockerize
As our docs are open-source, suggestions and improvements are welcome. There is a link at the bottom of every page to open a PR or Issue.