Last active
          March 19, 2020 15:04 
        
      - 
      
- 
        Save TimoDJatomika/a8f81ef2b22a7e81af0de5b36b9fbfaf to your computer and use it in GitHub Desktop. 
Revisions
- 
        TimoDJatomika revised this gist Mar 19, 2020 . 1 changed file with 16 additions and 25 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,52 +1,42 @@ # Using Laravel and Docker by Timo Stankowitz <[email protected]> The latest version of Laravel with Apache webserver in just one Docker container. If you have any questions of any suggestions just reach out to me. ## Create a new project with composer Don't create an extra directory. Comperser will do this for you. The folder name will be *project-name* (change to your actual project name). Make sure you have the latest version of the composer docker image: `docker pull composer` `docker run -u 1000 --rm -v $(pwd):/app composer create-project --prefer-dist laravel/laravel *project-name*` This can take up to 5 minutes. ## start your application with artisan The simplest way is to create a `Dockerfile` in you root directory with `touch Dockerfile`. Copy and paste the following content: ``` FROM php:7.4-apache LABEL maintainer="Timo Stankowitz <[email protected]>" RUN a2enmod rewrite COPY config/apache.conf /etc/apache2/sites-available/000-default.conf RUN rmdir /var/www/html COPY ./ /var/www/ # update permission RUN chown -R www-data: /var/www/bootstrap/cache/ RUN chmod -R 777 /var/www/storage/ RUN chmod -R 777 /var/www/bootstrap/cache/ ``` ### Create `docker-compose.yml` Replace *project-name* with your actually project name. ``` version: '3' @@ -73,4 +63,5 @@ networks: and run `docker-compose up` Open a webbrowser and open [localhost](http://localhost) 
- 
        TimoDJatomika revised this gist Mar 19, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,7 +57,8 @@ services: - project-name ports: - 80:8000 working_dir: "/mount" entrypoint: ["php", "artisan", "serve", "--host=0.0.0.0"] volumes: - ./:/mount 
- 
        TimoDJatomika revised this gist Mar 19, 2020 . 1 changed file with 16 additions and 4 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ This is required. Otherwise your application will not start. Use `php artisan` f ```bash cd project-name docker run --rm -v (pwd):/mount php:7.4 php /mount/artisan key:generate --ansi ``` ## set the currect folder permission @@ -47,15 +47,27 @@ If you want to change the port just replace the list line with this: `ENTRYPOINT ### create `docker-compose.yml` Replace *project-name* with your actually project name. ``` version: '3' services: project-name: image: php:7.4 networks: - project-name ports: - 80:8000 endpoint: ["php", "artisan", "serve", "--host=0.0.0.0"] volumes: - ./:/mount networks: project-name: driver: bridge ipam: driver: default config: - subnet: 172.29.1.0/24 ``` and run `docker-compose up` 
- 
        TimoDJatomika revised this gist Mar 19, 2020 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,9 @@ If you have any questions of any suggestions just reach out to me. Don't create an extra directory. Comperser will do this for you. The folder name will be *project-name* (change to your actual project name). Make sure you have the latest version of the composer docker image: `docker pull composer` `docker run -u 1000 --rm -v $(pwd):/app composer create-project --prefer-dist laravel/laravel *project-name*` This can take you up to 5 minutes. 
- 
        TimoDJatomika revised this gist Jul 28, 2019 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,10 @@ This can take you up to 5 minutes. ## create an application encryption key This is required. Otherwise your application will not start. Use `php artisan` for that: ```bash cd project-name docker run --rm -v (pwd):/mount php:7.3 php /mount/artisan key:generate --ansi ``` ## set the currect folder permission upcomming 
- 
        TimoDJatomika revised this gist Oct 22, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ If you have any questions of any suggestions just reach out to me. Don't create an extra directory. Comperser will do this for you. The folder name will be *project-name* (change to your actual project name). `docker run -u 1000 --rm -v $(pwd):/app composer/composer create-project --prefer-dist laravel/laravel *project-name*` This can take you up to 5 minutes. 
- 
        TimoDJatomika revised this gist Aug 18, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,7 +38,7 @@ ENTRYPOINT ["php", "artisan", "serve"] Per default your application will run on port **8000**. Just go to [http://localhost:8000](http://localhost:8000) to check if your application is running. If you want to change the port just replace the list line with this: `ENTRYPOINT ["php", "artisan", "serve", "--port=80"]`. In this example your application will be running on port *80*. ### create `docker-compose.yml` 
- 
        TimoDJatomika revised this gist Aug 18, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ The simplest way is to create a `Dockerfile` in you root directory with `touch D ``` FROM php LABEL maintainer="Timo Stankowitz <laravel@brainoftimo.com>" COPY ./ /mount 
- 
        TimoDJatomika created this gist Aug 18, 2018 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ # Using Laravel and Docker by Timo Stankowitz <[email protected]> If you have any questions of any suggestions just reach out to me. ## create a new project with composer Don't create an extra directory. Comperser will do this for you. The folder name will be *project-name* (change to your actual project name). `docker run -u 1000 ---rm -v $(pwd):/app composer/composer create-project --prefer-dist laravel/laravel *project-name*` This can take you up to 5 minutes. ## create an .env file `cp .env.example .env` You can copy and paste the first part of the example file. ## create an application encryption key This is required. Otherwise your application will not start. Use `php artisan` for that: `docker run --rm -v $(pwd):/mount php php /mount/artisan key:generate` ## set the currect folder permission upcomming ## start your application with artisan The simplest way is to create a `Dockerfile` in you root directory with `touch Dockerfile`. Copy and paste the following content: ``` FROM php LABEL maintainer="Timo Stankowitz <[email protected]>" COPY ./ /mount WORKDIR /mount ENTRYPOINT ["php", "artisan", "serve"] ``` Per default your application will run on port **8000**. Just go to [http://localhost:8000](http://localhost:8000) to check if your application is running. If you want to change the port just replace the list line with this: `ENTRYPOINT ["php", "artisan", "serve", "--port=80"]`. In this example your port will be *80*. ### create `docker-compose.yml` ``` version: '3' services: project-name: build: . network_mode: 'host' volumes: - ./:/mount ``` and run `docker-compose up`