#03 πŸ’» Membuat Project Laravel Baru menggunakan Docker Container

DPTSI ITS
26 May 202113:58

Summary

TLDRThis video tutorial guides viewers on developing a web-based application using Laravel, a popular PHP framework. It covers setting up a Docker container with a pre-configured Laravel environment provided by DPT. The script explains creating a new project, configuring 'docker-compose.yml', mapping directories, and setting environment variables for virtual hosting and SSL certificates. It also demonstrates accessing the application locally, troubleshooting permissions, and ensuring the application runs smoothly, providing a comprehensive guide for beginners in Laravel web development.

Takeaways

  • πŸ˜€ The video is a tutorial on how to develop a web-based application using files and containers provided by DPT.
  • πŸ”§ The tutorial uses a Docker image for Laravel web development, which is shared and available on docker.com.
  • πŸ’Ύ The video covers the setup of a new project with necessary files for a Laravel application, including a docker-compose file.
  • πŸ“ It explains the process of defining services in a docker-compose file, including the web development container named 'laravel.dev-example-web'.
  • πŸ–₯️ The tutorial mentions the need for a PHP version of at least 7.4 for Laravel 8, which is supported by the provided Docker image.
  • πŸ”„ The video shows how to map the 'src' directory to the 'www' directory within the Laravel web development container.
  • 🌐 It discusses the importance of setting environment variables for the virtual host, virtual port, and SSL certificate.
  • πŸ“‘ The tutorial includes instructions for configuring DNS settings and networks for the Laravel application container.
  • πŸš€ The video demonstrates how to execute the 'docker-compose up' command to start the Laravel application container.
  • πŸ” It shows troubleshooting steps, such as fixing permissions issues and setting the correct ownership for directories.
  • πŸ› οΈ The tutorial ends with accessing the Laravel application, making necessary configurations, and resolving permission denied errors.

Q & A

  • What is the main topic of the video?

    -The video is about explaining how to create and develop an informant to build a web-based application using files and running it on a Laravel web.dev container.

  • What is the provided docker image used for in the video?

    -The provided docker image is used for Laravel web development and it is shared and possibly hacked from docker.com.

  • Which PHP versions are supported by the Laravel web.dev image?

    -The Laravel web.dev image supports PHP versions starting from 7.3 up to 8.

  • What is the first step in setting up the project according to the video?

    -The first step is to ensure that Docker Desktop is running and the service engineers proxy is also running.

  • How should the project be named and where should it be placed?

    -The project should be named 'laravel-example' and it should be placed inside a folder named 'GTA'.

  • What is the purpose of the 'docker-compose.yml' file created in the video?

    -The 'docker-compose.yml' file is used to define and run the container for the Laravel web development environment.

  • What is the name of the service defined in the 'docker-compose.yml' file?

    -The service is named 'laravel.dev-example-web'.

  • What is the image used for the 'laravel.dev-example-web' service in the 'docker-compose.yml' file?

    -The image used is 'dpt/laravel.dev:sweep', which is provided by DPT.

  • What environment variables need to be defined in the 'docker-compose.yml' file for virtualhost and SSL?

    -The environment variables needed are 'VIRTUAL_HOST', 'VIRTUAL_PORT', 'SELF_SIGN_HOST', and 'VIRTUAL_PROTO'.

  • How can you access the Laravel application after setting up the container?

    -You can access the Laravel application by using the domain 'laravel.dev-example.com' after setting up the virtualhost and SSL certificate.

  • What command is used to start the services defined in the 'docker-compose.yml' file?

    -The command used to start the services is 'docker-compose up'.

  • What error occurred during the execution of 'docker-compose up' and how was it fixed?

    -An error occurred due to incorrect volume mapping which was fixed by correcting the volume directive from 'dot src.id' to 'volumes'.

  • How do you access the Laravel container after it's running?

    -You can access the Laravel container by executing the command 'docker exec -it [container_name] /bin/bash'.

  • What command is used to install Laravel project dependencies after entering the container?

    -The command used to install Laravel project dependencies is 'composer install'.

  • What issue was encountered with file permissions and how was it resolved?

    -A 'Permission Denied' error for the 'storage' directory was encountered, which was resolved by changing the ownership to 'www-data:nobody'.

Outlines

00:00

πŸ› οΈ Setting Up Laravel Web Development Environment

This paragraph outlines the process of setting up a web development environment using Laravel, a popular PHP framework. It starts by mentioning the availability of a Docker image for Laravel provided by the DPT, which includes support for PHP versions 7.3 to 8.0 and pre-installed libraries. The speaker instructs viewers to ensure Docker is running on their desktop and to navigate to a specific directory to create a new project named 'laravel-example'. The project will contain configuration files for Docker, managed through a 'docker-compose.yml' file. The setup involves defining services, mapping directories, and setting environment variables for virtual hosting and SSL certificates, all within the context of using Docker for local development.

05:03

πŸ”§ Configuring Docker Compose and Networking

The second paragraph delves into the configuration of Docker Compose, focusing on the services required to run the Laravel web development container. It explains the need to connect the Laravel container to the same network used by a DNS proxy, ensuring seamless integration. The speaker also discusses the importance of setting the correct DNS for internet connectivity and the process of defining environment variables for the virtual host, virtual port, and SSL certificate. The paragraph includes troubleshooting steps, such as correcting volume definitions and ensuring the proper execution of 'docker-compose up' to start the container. It concludes with the verification of the container's successful setup and the initial access to the Laravel application.

10:04

πŸš€ Accessing and Configuring the Laravel Project

In this paragraph, the speaker demonstrates how to access and configure the Laravel project within the Docker container. After entering the container using a terminal command, the speaker shows the process of downloading and setting up a new Laravel project using Composer. The paragraph highlights the importance of permissions, as files downloaded within the container need to be accessible by the correct user and group, which in this case are 'nobody:nobody'. The speaker also addresses a 'permission denied' error for the 'storage' directory and resolves it by changing the ownership to 'nobody:nobody'. The paragraph concludes with the successful access and configuration of the Laravel application, ready for further development.

Mindmap

Keywords

πŸ’‘Docker

Docker is a platform that enables developers to develop, deploy, and run applications in containers. In the video, Docker is used to create a containerized environment for Laravel web development, which simplifies the process of setting up the development environment and makes it consistent across different machines.

πŸ’‘Laravel

Laravel is a popular PHP web application framework known for its expressive and elegant syntax. The video is focused on setting up a Laravel project within a Docker container, which provides a streamlined development workflow and eliminates the need for local server setup.

πŸ’‘Docker Image

A Docker image is a read-only template that contains all the software needed to run an application as a container. In the script, the Docker image 'laravel.dev' is mentioned, which is pre-configured to run Laravel applications and is used to simplify the setup process.

πŸ’‘Docker Compose

Docker Compose is a tool for defining and running multi-container Docker applications. The script describes creating a 'docker-compose.yml' file, which is used to configure the services, networks, and volumes for the Laravel project running in a Docker container.

πŸ’‘PHP

PHP is a server-side scripting language used for web development. The video mentions PHP versions supported by the 'laravel.dev' image, which range from PHP 7.3 to 7.4, indicating the compatibility of the Docker image with different PHP versions.

πŸ’‘Virtual Host

A virtual host is a method of hosting multiple domain names on a single server. In the context of the video, setting up a virtual host allows the Laravel application to be accessed via a specific domain, such as 'laravel.dev.example.com', within the Docker container.

πŸ’‘SSL Certificate

SSL (Secure Sockets Layer) certificates are used to establish an encrypted link between a web server and a browser. The script discusses setting up an SSL certificate for the virtual host to ensure secure access to the Laravel application.

πŸ’‘Environment Variables

Environment variables are used to set configuration settings for applications. In the video, environment variables are defined in the 'docker-compose.yml' file to configure the virtual host, virtual port, and SSL certificate for the Laravel application.

πŸ’‘Composer

Composer is a dependency manager for PHP used to manage libraries and dependencies of PHP projects. The script describes using Composer to install the Laravel project within the Docker container, which involves downloading the necessary dependencies.

πŸ’‘Permissions

Permissions in the context of the video refer to the access rights granted to users or processes to perform certain operations on files and directories. The script mentions resolving permission issues by setting the correct ownership for files and directories within the Docker container.

πŸ’‘Volumes

In Docker, a volume is used to persist data generated by and used by Docker containers. The script discusses mapping a local directory to a directory inside the container using volumes, which allows the Laravel application's source files to be accessed and modified.

Highlights

The video explains how to develop an informant for building a web-based application using Laravel web.dev containers.

It mentions that the Docker image for Laravel web.dev is pre-configured with several PHP versions and libraries.

Ensures that Docker Desktop and the Engineers Proxy service are running before starting the project setup.

Guides on creating a new project directory and setting up the necessary files for the Laravel application.

Instructs on using Visual Studio Code to create a docker-compose.yml file for running Laravel containers.

Details defining the version of the docker-compose file and setting up services within it.

Explains the process of mapping the source directory to the Laravel web development container.

Discusses setting environment variables for the virtual host and SSL certificate within the docker-compose file.

Covers the configuration of DNS settings and networks for the Laravel application.

Demonstrates the execution of the docker-compose up command to start the Laravel container.

Mentions the potential need to download the Laravel image if it hasn't been done before.

Guides on accessing the Laravel application using a local domain after setting up the virtual host.

Explains how to enter the Laravel container using Docker commands to interact with the application.

Shows the process of initializing a new Laravel project using Composer within the container.

Addresses potential permission issues when accessing the storage directory of the Laravel application.

Provides a solution to change ownership of the storage directory to the correct user for proper access.

Concludes by summarizing the steps to create and run a new Laravel project within a Docker container.

Transcripts

play00:00

Indonesia pada video kali ini saya akan

play00:03

menjelaskan Bagaimana cara membuat

play00:07

develop an informant untuk membangun

play00:10

atau mengembangkan sebuah aplikasi

play00:12

berbasis web menggunakan file-file dan

play00:15

dijalankan diatas kontainer laravel

play00:18

web.dev yang telah disediakan oleh DPT

play00:20

si Ade edisi ini yang tampil di layar

play00:24

adalah docker image yang sudah di-share

play00:28

di-hack docker.com dimana laravel.dev

play00:32

ini bisa digunakan untuk laravel

play00:34

beberapa versi tidaknya 89 ya karena

play00:37

yang PHP yang disupport adalah mulai PHP

play00:40

7374 sampai ke-8 dan sudah ada beberapa

play00:43

library Disini yang sudah diinstall baik

play00:47

untuk memulai pertama pastikan dokter

play00:51

desktop sudah berjalan dan service

play00:55

engineers proxy juga sudah berjalan

play00:56

seperti ini kemudian

play01:00

ia pindah ke wesel kita dan masuk ke

play01:03

folder atau direktori kita disini kita

play01:06

akan membuat sebuah Project baru yang

play01:08

nanti di dalamnya akan ada file-file

play01:11

dari pramugara file dan juga file

play01:14

docker-compose yang digunakan untuk

play01:16

menjalankan kontainer dari laravel

play01:20

web.dev ini nah Project yang kita akan

play01:25

buat adalah Project dengan nama laravel

play01:29

example yang akan diletakkan di dalam

play01:34

folder GTA kita masuk ke sini dan kita

play01:40

buat super directory SRT yang akan

play01:43

menampung file-file dari laravel di

play01:46

folder src ini source Nah kita akan

play01:49

menggunakan fisik bantuan Visual Studio

play01:50

code untuk membuat file dokter kompos

play01:57

Hai nah disini sudah muncul Visual

play02:02

Studio code yang membuka folder level

play02:05

example yang di sini sudah ada folder

play02:08

src Nah kita akan membuat file

play02:10

docker-compose.yml Dirut direktorinya

play02:14

new file disini kita beri nama dokter

play02:17

Des kompos.me nah yang pertama kita bisa

play02:23

lakukan adalah pertama mendefinisikan

play02:25

versi dari Yaumul file-nya versi dari m

play02:29

avail.com posnya kemudian mendefinisikan

play02:33

Disini versi 3 kemudian kita

play02:35

mendefinisikan Services apa saja akan

play02:37

dijalankan oleh dokter kompos ini yang

play02:40

pertama tentu kita perlu membuat

play02:41

kontainer web development nya kita beri

play02:45

nama laravel.dev example Dash web dengan

play02:51

detail pertama kontennya kita beri nama

play02:54

sama dengan nama servicenya

play02:57

Hai laravel This example the Sweep

play03:00

kemudian imagenya nah ini saya ini kita

play03:03

menggunakan sudah diberikan oleh DPT

play03:05

yaitu DPT z-slash laravel.dev Sweep Eh

play03:10

iya de Sweep destef versinya kita pakai

play03:14

8.0 karena kita menggunakan level 8

play03:17

sehingga butuh PHP versi minimal 74 ya

play03:20

tapi kita pakai inversi 80 kemudian

play03:25

folder source kita yang ada di sini ini

play03:28

akan berisi file-file penduduk file-file

play03:31

dari level ini akan kita house jadi

play03:34

akan kita harus kita Mohon ke dalam

play03:37

kontainer ya jadi dot src.id berarti

play03:45

karena directory masuk ke direktori SFC

play03:48

kita mapping kan dengan flash www.ml

play03:53

jadi laravel web.dev ini menghusus

play03:56

search directory

play03:57

di Project laravel kita disrespects

play04:01

lewes html Kemudian untuk kepentingan

play04:06

virtualhost dan selesaiin SSL

play04:08

certificate kita perlu mempassing

play04:10

environment variable yang pertama adalah

play04:15

virtualhost ini adalah berisi nanti

play04:20

aplikasi laravel-excel kita ini akan

play04:22

diakses melalui virtual sapa atau domain

play04:25

nya apa gitu ya Nah ini kita Devil's aja

play04:28

nanti pakaiin file kita definisikan

play04:30

variabel Inv environment variable

play04:33

seperti ini kemudian Selain virtualhost

play04:35

Kita perlu juga mendefinisikan virtual

play04:37

keyboard virtual port Kemudian untuk SSL

play04:46

certificate ya kita definisikan variabel

play04:49

self sign house

play04:54

sel-sel house kemudian terkadang

play05:02

kita tidak bisa terkoneksi dengan domain

play05:07

alamat tertentu di internet Nah kita

play05:09

setting sekalian disini DNS nya disini

play05:12

kebetulan menggunakan DNS it's nah er

play05:16

dan semua bebas menggunakan DNS yang

play05:18

lain sebenarnya kemudian networks di

play05:31

sini nanti laravel in simple web ini

play05:35

akan terkoneksi dengan Network yang sama

play05:37

dengan Network yang dijalankan oleh DNS

play05:40

proxy Jadi kita pakai nothing sedih buat

play05:43

sebelumnya itu ndx proxy Network

play05:49

kelebihan es sini nah kita

play05:54

jika networknya networknya ini adalah

play06:07

engine.exe proxy Network gimana karena

play06:15

sudah didefinisikan sebelumnya di luar

play06:17

dari docker-compose ini maka kita tulis

play06:20

dia sebagai external true Oke kita cek

play06:24

terlebih dahulu docker-compose kita

play06:25

sudah jadi pertama versi 3 service esnya

play06:28

ada laravel-excel web dengan nama

play06:30

kontainer yang refleks sample web

play06:32

menggunakan image laravel web develop

play06:35

and titik nol memetingkan volume src ke

play06:38

Farewell html dan ini informal

play06:40

variabelnya dan Ini setting DNS dan Ini

play06:43

setting network nya oke karena ini kita

play06:45

masih punya tanggungan variabel disini

play06:47

kita buat infonya ya

play06:53

Hai Jadi yang pertama adalah virtual

play06:56

host kita akan memberikan domain

play07:00

laravel.dev example.com call virtual

play07:04

port nya karena default dari level web

play07:09

content adalah pembuluh kemudian self

play07:13

sign house in juga sama yang akan

play07:17

dijerat kan SSL certificate adalah

play07:19

domain laravel example.com call kefir

play07:25

Town House virtual port selesaiin house

play07:29

keep virtualhost without science is

play07:33

sudah sesuai SFC masih kosong nanti kita

play07:36

akan populer setelah kontainer nya jadi

play07:38

kita akan masuk ke kontainer nya dan

play07:40

menguat Project laravel ya Oke kita

play07:44

kembali ke websitenya disini sudah ada

play07:48

docker-compose.yml yang dibuat dari bisa

play07:50

video call sekarang kita eksekusi

play07:52

menggunakan

play07:53

dan kan dengan menggunakan perintah

play07:55

docker-compose up minde Oh maaf ada

play08:04

kesalahan di sini seharusnya volumes ya

play08:08

saya kurang sini oke nah kalau pertama

play08:16

Kak mungkin kalau rekan-rekan pertama

play08:19

kali melakukan docker-compose

play08:20

menggunakan image ini maka nanti akan

play08:23

ada proses pengunduhan the crimes lebih

play08:26

dahulu karena ini saya sudah pernah maka

play08:28

dia langsung terkait seperti ini kita

play08:32

lihat di dokter besok sudah ada laravel

play08:33

example kontainer laravel smpe berjalan

play08:36

Bagaimana cara mengaksesnya kita pakai

play08:42

laravel.com lokal tetapi ini masih

play08:47

domainnya belum ada kita setting dulu

play08:50

disini menggunakan house

play08:53

nah ini kita tambahkan saja disini Pasti

play08:55

karena saat ini Creator ya kan eh IP

play09:01

private kita dengan domain yang

play09:05

digunakan untuk virtualhost yaitu

play09:07

laravel example.com call-time Pinkan

play09:14

dengan IP private bisa 127001 atau

play09:18

menggunakan epifat nah ini ada perbedaan

play09:20

sebenarnya ketika kita misalnya

play09:22

membutuhkan Kernel ke diri sendiri maka

play09:25

ini saya menggunakan Adobe Premiere saja

play09:28

168 109 kita at kita save ya laravel.dev

play09:36

example.com kita coba tes di sini ping

play09:41

laravel.com example.com sudah terkoneksi

play09:48

kita coba akses menggunakan Google

play09:51

Chrome

play09:53

Hai laravel example.com ini masih nonton

play10:00

ya oke karena seharusnya belum ada nah

play10:04

sekarang kita masuk ke kontainernya

play10:08

menggunakan perintah dokter excek mint

play10:12

interaktif Terminal Mini temin sebagai

play10:14

root user Clara m kontainernya laravel

play10:20

example web dengan mengeksekusi bindes

play10:25

SH ya Oke kita sudah masuk dan kita

play10:29

lihat di sini masih kosong belum ada

play10:30

project laravel nya kita terlihat

play10:33

menggunakan perintah composer kriyep

play10:35

Dash Project laravel yang terbaru ya di

play10:41

karena directory kini proses pengunduhan

play10:47

Project laravel nya bisa kita lihat di

play10:50

sini composer sedang melakukan

play10:52

pengunduhan laravel

play10:53

ini definisi dependensi yang dibutuhkan

play10:56

Jika pernah mengunduh mungkin akan lebih

play10:59

jauh lebih cepat daripada proses ini key

play11:08

sambil menunggu kita lihat di sini nanti

play11:11

setelah Project yang terkait seperti ini

play11:17

ke ini juga kakinya juga dibuat Oke kita

play11:22

lihat di sini nah ini sudah apa namanya

play11:28

tergenerate nah ini kita coba akses Nah

play11:32

sudah berhasil aplikasi rela file-nya

play11:35

sudah bisa berjalan sehingga kalau kita

play11:39

lihat disini kita bisa setting beberapa

play11:43

Disini di RCTI mv-nya kita ganti menjadi

play11:46

laravel example.com

play11:54

porno

play11:56

di Indonesia jika teman-teman menemukan

play12:01

file to save Doddie MV One baterai

play12:03

berarti kita ada permission yang perlu

play12:06

kita perbaiki Kenapa karena disini kita

play12:11

lihat di sini eh karena kita tadi masuk

play12:17

sebagai root sehingga eh ketika kita

play12:22

melakukan pengunduhan itu mengunduh

play12:27

seluruh apa file owner sipnya masuk

play12:30

kerut diset kepada rute ini kita bisa

play12:34

pakai Kwon Min er kita set ke

play12:51

Hai Oh maaf karena sudah sudo ya ya di

play13:03

sini kita lihat kita sudah bisa mengedit

play13:06

mulai sini kita refresh tetapi ada error

play13:10

di sini permission Denied untuk storage

play13:13

nah yang Sturridge perlu kita kasih eh

play13:18

ownership khusus ke nobody nobody

play13:31

the lounge

play13:33

Hai storage kita cek

play13:40

the story flash Ya sudah bisa berjalan

play13:44

Oke jadi pada tutorial kali ini

play13:46

rekan-rekan sudah bisa membuat file

play13:50

membuat Project baru eh berbasis laravel

play13:55

dan dijalankan menggunakan laravel

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
Laravel DevelopmentWeb AppDocker ContainersPHP SupportDocker ComposeWeb DevelopmentVirtual HostSSL CertificateCoding TutorialProject SetupEnvironment Variables