Git Product home page Git Product logo

belajar-docker-php's Introduction

Sharing dengan teman-teman di team network untuk development app dengan docker on premise

  • Perbedaan VM dengan Docker
  • Perbedaan instalasi PHP environment diantara keduanya, asumsi kita belum menggunakan database, dan menggunakan web server bawaan php

Local / VM way

Panduan lengkap memasang PHP Environtment langsung di dalam host Local Machine bisa dilihat di Digital Ocean

Namun untuk sharing ini, supaya simple, berikut caranya:

Langkah 1, Instalasi PHP Environment

sudo apt install git
sudo apt install php php-cli php-mbstring unzip

Langkah 2, Instalasi Composer as Dependency manager

cd ~
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
HASH=`curl -sS https://composer.github.io/installer.sig`
echo $HASH
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
composer

Kemudian clone project dari Github sebagai contoh project. https://github.com/ahmadfadlydziljalal/belajar-docker-php

Setelah berhasil download, running project dengan cara:

  1. cd belajar-docker-php
  2. composer install
  3. composer serve
  4. Running di browser, ketik url: http://localhost:8080

Seharusnya seperti ini lah kita deploy php project di Server Ubuntu.


Docker Way

Instalasi Docker

curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
docker --version

Instalasi docker compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose -v

Running docker tanpa sudo

sudo usermod -aG docker ${USER}
su - ${USER}
id -nG
sudo usermod -aG docker ${USER}

Sampai sejauh ini docker environment sudah siap digunakan. Sekarang mari kita konsentrasi ke file DockerFile, dan docker-compose.yml

  • Untuk running menggunakan docker, berikut langkahnya
docker build -t belajar-docker-php .
  • Docker akan membuat image dari aplikasi kita, Cek dengan perintah:
docker image ls | grep 'belajar-docker-php'
  • Sekarang, kita akan running, aplikasi tersebut dengan perintah
docker run -it -p 8080:8080 --name=container-saya belajar-docker-php
  • Cek dengan perintah
docker ps
  • Sekarang kita akan running di browser, dengan mengetikkan localhost:8080

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.