mirror of
https://github.com/gabrielkheisa/tugas-pjpb.git
synced 2024-11-23 20:13:14 +07:00
add docker installation
This commit is contained in:
parent
ee1422184d
commit
87df38541f
88
README.md
88
README.md
@ -15,7 +15,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Back end: PHP 7.2 (vanilla)</li>
|
<li>Back end: PHP 7.2 (vanilla)</li>
|
||||||
<li>Database: MySQL</li>
|
<li>Database: MySQL</li>
|
||||||
<li>Hosting: DigitalOcean, bare metal</li>
|
<li>Hosting: DigitalOcean</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
@ -23,6 +23,92 @@
|
|||||||
|
|
||||||
<h2>Video demonstrasi dan penjelasan: <a href="https://drive.google.com/drive/u/1/folders/1L0w71TZnqa41XFDGfoZ3mM8ILZQeZeXE">https://drive.google.com/drive/u/1/folders/1L0w71TZnqa41XFDGfoZ3mM8ILZQeZeXE</a></h2>
|
<h2>Video demonstrasi dan penjelasan: <a href="https://drive.google.com/drive/u/1/folders/1L0w71TZnqa41XFDGfoZ3mM8ILZQeZeXE">https://drive.google.com/drive/u/1/folders/1L0w71TZnqa41XFDGfoZ3mM8ILZQeZeXE</a></h2>
|
||||||
|
|
||||||
|
<h2>Instalasi menggunakan <a href="https://github.com/adhocore/docker-lemp">Docker LEMP Stack</a>:</h2>
|
||||||
|
<h3>1. Buat file dengan nama <b>docker-compose.yml</b>, isi file dengan konfigurasi berikut:</h3>
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# ./docker-compose.yml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: adhocore/lemp:7.4
|
||||||
|
# For different app you can use different names. (eg: )
|
||||||
|
container_name: some-app
|
||||||
|
volumes:
|
||||||
|
# app source code
|
||||||
|
- ./web:/var/www/html
|
||||||
|
# db data persistence
|
||||||
|
- db_data:/var/lib/mysql
|
||||||
|
# Here you can also volume php ini settings
|
||||||
|
# - /path/to/zz-overrides:/usr/local/etc/php/conf.d/zz-overrides.ini
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: supersecurepwd
|
||||||
|
MYSQL_DATABASE: appdb
|
||||||
|
MYSQL_USER: dbusr
|
||||||
|
MYSQL_PASSWORD: securepwd
|
||||||
|
# for postgres you can pass in similar env as for mysql but with PGSQL_ prefix
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db_data: {}
|
||||||
|
```
|
||||||
|
|
||||||
|
<h3>2. Kemudian, compose </h3>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
docker-compose up -d
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>3. Navigasi menuju folder <b>web</b> </h3>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
cd web
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h3>4. Clone repository berikut, kemudian ganti branch ke <b>docker</b> </h3>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
git clone https://github.com/gabrielkheisa/tugas-pjpb.git
|
||||||
|
cd tugas-pjpb
|
||||||
|
git checkout docker
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h3>5. Bash ke container untuk melakukan beberapa konfigurasi database: </h3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
docker exec -u root -t -i some-app /bin/bash
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h3>6. Login ke MySQL sebagai <b>root</b> dengan password <b>supersecurepwd</b></h3>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
mysql -u root -p
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h3>7. Tambahkan tabel berikut, beserta user Admin:</h3>
|
||||||
|
<pre>
|
||||||
|
USE appdb;
|
||||||
|
CREATE TABLE `user_pjpb` (
|
||||||
|
`nama` VARCHAR(30),
|
||||||
|
`email` VARCHAR(30),
|
||||||
|
`hash` VARCHAR(70),
|
||||||
|
`public_key` VARCHAR(70),
|
||||||
|
`url` TEXT(70),
|
||||||
|
`id` INT(11) AUTO_INCREMENT,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
);
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h3>7. Berikan akses <b>dbusr</b> ke <b>appdb</b>:</h3>
|
||||||
|
<pre>
|
||||||
|
GRANT ALL PRIVILEGES ON appdb.* TO 'dbusr'@'localhost' WITH GRANT OPTION;
|
||||||
|
exit;
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h3>Aplikasi dapat diakses melalui <b>http://{ip-address}:8080/login.php</b>, untuk registrasi melalui <b>http://{ip-address}:8080/register.php</b></h3>
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Database credentials. Assuming you are running MySQL
|
/* Database credentials. Assuming you are running MySQL
|
||||||
server with default setting (user 'root' with no password) */
|
server with default setting (user 'root' with no password) */
|
||||||
define('DB_SERVER', '');
|
define('DB_SERVER', '127.0.0.1');
|
||||||
define('DB_USERNAME', '');
|
define('DB_USERNAME', 'dbusr');
|
||||||
define('DB_PASSWORD', '');
|
define('DB_PASSWORD', 'securepwd');
|
||||||
define('DB_NAME', '');
|
define('DB_NAME', 'appdb');
|
||||||
|
|
||||||
/* Attempt to connect to MySQL database */
|
/* Attempt to connect to MySQL database */
|
||||||
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
|
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
|
||||||
|
Loading…
Reference in New Issue
Block a user