Coder Social home page Coder Social logo

docker-laravel-setup's Introduction

How to create a docker

Lets suppose the project folder is laravel and the laravel folder is inside the project

  1. Copy all the files of this folder to the project folder

  2. Go to the project folder and open terminal using (ctl+shift+T) and type the below command

divya@ubuntu:~/project$ git clone https://github.com/laravel/laravel.git laravel
(this command will create the clone of the laravel project from the github)

divya@ubuntu:~/project$ sudo chown -R $USER:$USER laravel
(this command will grant permission to the user to acces the folder )

divya@ubuntu:~/project$ cd laravel
( this command will helps you to enter the laravel folder)

divya@ubuntu:~/project/laravel$ docker run --rm -v $(pwd):/app composer install
(this command will is to install the vendor file)

divya@ubuntu:~/project/laravel$ code .
(this will open the project on visual code editor)

  1. Open the docker-compose.yml and find the MYSQL_DATABASE and MYSQL_ROOT_PASSWORD & provide a new one for example i am using laravel password

MYSQL_DATABASE: laravel
MYSQL_USER: laravel
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password

  1. Now copy the env-example to .env using below command

divya@ubuntu:~/project/laravel$ cp .env.example .env

  1. Now edit the newly created .env file value

DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=password\

  1. Now run the below command to create a docker image

divya@ubuntu:~/project/laravel$ docker-compose up -d

  1. As a final step, visit http://your_server_ip in the browser. You will see the following home page for your Laravel application:(if you are using in the locall http://localhost) if you change the port in the ports of webserver then :ports_no will be added.For my localhost http://localhost:8000 and for the phpmyadmin http://localhost:8001change the port no and username, password and try it

  2. Some of the usefull commands

divya@ubuntu:~/project/laravel$ docker ps => to check the currently running docker
divya@ubuntu:~/project/laravel$ docker-compose up -d => to create docker container
divya@ubuntu:~/project/laravel$ docker-compose exec app php artisan key:generate => to generate the artisan php key
divya@ubuntu:~/project/laravel$ docker-compose exec app php artisan config:cache => to clear the configuration

  1. For docker aliases

divya@ubuntu: gedit ~/.bashrc and then add the below command

# some aliases for docker
alias docker-run='sudo docker-compose run --rm app'

# for bundle command
alias docker-bundle='sudo docker-compose run --rm app bundle'
alias docker-bundle-rubocop='sudo docker-compose run --rm app rubocop'
alias docker-bundle-rspec='sudo docker-compose run --rm app rspec'
alias docker-yarn-install='sudo docker-compose run --rm app bundle'

# for db command
alias docker-db-drop='sudo docker-compose run --rm app bundle exec rails db:drop'
alias docker-db-create='sudo docker-compose run --rm app bundle exec rails db:create'
alias docker-db-migrate='sudo docker-compose run --rm app bundle exec rails db:migrate'
alias docker-db-seed='sudo docker-compose run --rm app bundle exec rails db:seed'

For more informatrion please click here

docker-laravel-setup's People

Contributors

anilnabin25 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.