- person Penulis:
-
Dimas Maryanto
PT. Tabeldata Informatika
- account_balance_wallet Donasi via:
- Saweria a/n Dimas Maryanto
- lock_open Join Premium Members:
- Udemy.com
-
Daftar Materi
-
1. Pengenalan Docker 8
-
2. Docker Registry 3
-
3. Docker Container CLI 8
-
1. Docker CLI (Command Line Interface)
2. Management Docker Container
3. Management Docker Images
4. Run a command in a running container
5. Expose services to outside using ports
6. Copying files/content between container and filesystem
7. Logging, Inspect, & Resource Usage Statistics Containers
8. Run a Container using Environtment File
-
4. Docker Networks 7
-
5. Docker Volumes 5
-
6. Dockerfile 15
-
1. Build Docker Image Overview
2. Usage docker build
3. FROM Instruction
4. Environtment Replacement
5. Copying Resources
6. Excluding files/directories
7. Label Instruction
8. Execution Instruction
9. CMD vs ENTRYPOINT?
10. Exposing Ports
11. User, Volumes and Working Directory
12. Health Check Instruction
13. Multiple Stage Builds
14. Best practices for writing Dockerfiles
15. Best practices for scanning images
-
7. Study Kasus: Build docker image 14
-
1. Build specific docker image by programming languages
2. Build Docker Image for Java Webapp
3. Build Java Web using maven-docker-plugin
4. Build docker image for spring-boot
5. Springboot - using Environtment
6. Springboot - where data such as files/images we stored?
7. Springboot - Using Database
8. Build docker image for Angular Project
9. Angular - Access Rest API
10. Angular - Proxy to backend
11. Build docker image for PHP
12. Build Docker image for Laravel Framework
13. Laravel - Using Frontend & Rest API
14. Laravel - Using Database
-
8. Docker Compose 19
-
1. Overview of Docker Compose
2. Get started with Docker Compose
3. Overview of docker-compose CLI
4. Compose file specification and syntax
5. Environment variables in Compose
6. Volume in Compose
7. Share data between Containers in Compose
8. Using sshfs for share data in Compose
9. Using NFS for share data in Compose
10. Networking Overview in Compose file
11. Network links in Compose file
12. Specify custom networks in Compose file
13. Dependency between services in Compose file
14. Build docker image using Compose file
15. Using profiles with Compose file
16. Multiple Compose files to Add & Override attribute
17. Example use case of multiple compose files
18. Scale services using compose command
19. Use Compose in production
-
9. Study Kasus: Docker Compose 7
-
10. Docker Context 8
-
11. Study Kasus: Docker for CI 8
-
1. Overview of Study Cases using docker for CI
2. Setup environment for CI using Gitlab & Nexus OSS
3. The `.gitlab-ci.yml` file
4. Pipeline: PHP deployment using Gitlab CI
5. Pipeline: Java Web deployment using Gitlab CI
6. Pipeline: spring-boot deploy with Gitlab CI
7. Pipeline: Angular deploy with Gitlab CI
8. Pipeline: Laravel deploy with Gitlab CI
-
12. Docker Machine 7
-
13. Study Kasus: Ansible for Docker 4
-
14. Docker Swarm
- Materi: belum tersedia...
-
15. Study Kasus: Docker Swarm
- Materi: belum tersedia...
-
16. Docker on Cloud using GCP
- Materi: belum tersedia...
- Lastest Posts
- 09 Apr 23 Working with Deployment object
- 26 Feb 23 Study cases: Microservice apps (...
- 05 Feb 23 Welcome to the Nutanix HCF (Hybr...
- 04 Feb 23 Silabus SRE - Nutanix AHV: Pemul...
- 17 Jan 23 What is Workload Resources?
- 17 Jan 23 Overview Kubernetes Workloads re...
- 15 Jan 23 Getting started with Transaction...
- 14 Jan 23 Overview of Concurrency Control
- 14 Jan 23 Time your practice (part 3)
- 08 Jan 23 Cleanup Data from Table
Build Docker image for Laravel Framework
Hai semuanya, di materi kali ini kita akan membahas Build docker image untuk PHP Framework yang paling popular yaitu Laravel v8.x. Supaya pembahasannya tidak terlalu panjang kita bagi menjadi beberapa section diantaranya:
- Setup SDK Local environment
- Deployment using Apache2/Httpd
- Build & Running docker image
- Cleanup
Setup SDK Local environment
Untuk meng-setup Software Development project Laravel sebetulnya ada banyak cara seperti yang di Official Documentation Laravel Seperti contohnya
- Within WSL2
- Docker
- Sail Service
- Composer
- Laravel Installer
Klo saya sendiri lebih sering menggunakan Composer. Sebelum kita membuat project Laravel dengan Composer kita harus configure dulu PHP environtmennya seperti
- PHP >= 7.3
- BCMath PHP Extension
- Ctype PHP Extension
- Fileinfo PHP Extension
- JSON PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
- mcrypt PHP Extension
Setelah kita configure engine PHP nya, selanjutnya kita install untuk package managernya yaitu menggunakan Composer, Selantutnya kita buat project dengan menggunakan perintah seperti berikut:
Setelah itu kita bisa config dulu system Laravelnya seperti
Copy .env.example
menjadi.env
menggunakan perintah berikut:php -r "file_exists('.env') || copy('.env.example', '.env');"
- Set
APP_KEY
denganphp artisan package:discover --ansi && php artisan key:generate --ansi
Kemudian kita bisa jalankan sebagai development mode yaitu menggunakan perintah seperti berikut
Jika di jalankan, maka hasilnya seperti berikut:
➜ docker-laravel php artisan serve
Starting Laravel development server: http://127.0.0.1:8000
[Sat Jul 24 11:33:08 2021] PHP 8.0.7 Development Server (http://127.0.0.1:8000) started
Kemudian kita akses di browser dengan url di atas, hasilnya seperti berikut:
Deployment using Apache2/Httpd
Ok setelah kita membuat project kemudian kita menjalankan development mode, sekarang kita akan deploy ke Server (Production Mode). Untuk deploy production mode ada beberapa cara yaitu
- Nginx (PHP-FPM)
- Httpd/Apache2
Jadi kali ini kita akan menggunakan Web Server Httpd/Apache dan OS Ubuntu Server. Langsung aja berikut yang harus kita install di server
Setelah kita install, sekarang kita upload source-codenya ke server menggunakan tools seperti scp
atau git
. Berikut perintahnya:
scp -r * username@your-server.hostname:/var/www/php && \
scp env.example username@your-server.hostname:/var/www/php
Setelah itu kita edit apache2 confignya pada file /etc/apache2/sites-enabled/000-default.conf
untuk mengarahkan ROOT Document ke /var/www/php/public
seperti berikut:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/php/public
<Directory /var/www/php/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Kemudian kita restart server apache2 dengan perintah seperti berikut:
Kemudian kita build sourcenya menjadi production mode sesuai dengan arahan dari official website nya. seperti berikut
Sekarang kita coba access menggunakan browser ke http://your-server.hostname maka hasilnya seperti berikut:
Build & Running docker image
Ok setelah kita mencoba manual deployment menggunakan Apache2 di Ubuntu Server, sekarang kita buat Docker imagenya. Seperti biasanya untuk membuat docker image kita pilih dulu base image yang mau digunakan, jadi karena kita menggunakan Apache2 untuk web-servernya dan versi PHP 8 maka kita pilih php:8.0-apache
jadi berikut adalah Dockerfile
Serta berikut file .dockerignore
nya:
Jika di jalankan maka outputnya seperti berikut:
➜ docker-laravel git:(master) docker build -t dimmaryanto93/docker-laravel:2021.07.24.19.43-release .
[+] Building 13.2s (14/14) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.49kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 35B 0.0s
=> [internal] load metadata for docker.io/library/php:8.0-apache 3.2s
=> [php_laravel 1/4] FROM docker.io/library/php:8.0-apache@sha256:bc3bf769aff70e8f81 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 19.75kB 0.0s
=> CACHED [php_laravel 2/4] RUN apt-get update && apt-get install -y curl git 0.0s
=> CACHED [php_laravel 3/4] RUN pecl install mcrypt-1.0.4 && docker-php-ext-instal 0.0s
=> CACHED [php_laravel 4/4] RUN curl -sS https://getcomposer.org/installer | php -- 0.0s
=> CACHED [executeable 1/5] WORKDIR /var/www/php 0.0s
=> [executeable 2/5] RUN sed -i "s|DocumentRoot /var/www/html|DocumentRoot /var/www/" 0.2s
=> [executeable 3/5] COPY . . 0.1s
=> [executeable 4/5] RUN mkdir -p public/storage && chmod -R 777 storage/* && chmod 0.2s
=> [executeable 5/5] RUN php -r "file_exists('.env') || copy('.env.example', '.env')" 9.0s
=> exporting to image 0.4s
=> => exporting layers 0.4s
=> => writing image sha256:14d3276fc4f91d338994fc50c50261df00593d12688ea43ded32afab6 0.0s
=> => naming to docker.io/dimmaryanto93/docker-laravel:2021.07.24.19.43-release
Sekarang jika kita jalankan containernya dengan perintah seperti berikut:
Maka hasilnya seperti berikut:
Cleanup
Seperti biasa setelah kita mencoba schenario studi kasus tersebut. sekarang kita bersih-bersih dulu ya berikut perintahnya:
For Bash script:
For Powershell script:
Yuk simak juga videonya,
Dan jika temen-temen belajar hal baru kali ini jangan lupa buat Like, Subcribe, dan Share ke temen kalian. Terimakasih!!!