From 87df38541f6627686a153009c4c8e055395a8844 Mon Sep 17 00:00:00 2001 From: gabrielkheisa Date: Wed, 26 Oct 2022 17:00:26 +0700 Subject: [PATCH] add docker installation --- README.md | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++- config.php | 8 ++--- 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b5e0a7b..4841b39 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ @@ -23,6 +23,92 @@

Video demonstrasi dan penjelasan: https://drive.google.com/drive/u/1/folders/1L0w71TZnqa41XFDGfoZ3mM8ILZQeZeXE

+

Instalasi menggunakan Docker LEMP Stack:

+

1. Buat file dengan nama docker-compose.yml, isi file dengan konfigurasi berikut:

+ +```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: {} +``` + +

2. Kemudian, compose

+ +
+docker-compose up -d
+
+ + +

3. Navigasi menuju folder web

+ +
+cd web
+
+ +

4. Clone repository berikut, kemudian ganti branch ke docker

+ +
+git clone https://github.com/gabrielkheisa/tugas-pjpb.git
+cd tugas-pjpb
+git checkout docker
+
+ +

5. Bash ke container untuk melakukan beberapa konfigurasi database:

+
+docker exec -u root -t -i some-app /bin/bash
+
+ +

6. Login ke MySQL sebagai root dengan password supersecurepwd

+ +
+mysql -u root -p
+
+ +

7. Tambahkan tabel berikut, beserta user Admin:

+
+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`)
+);
+
+ +

7. Berikan akses dbusr ke appdb:

+
+GRANT ALL PRIVILEGES ON appdb.* TO 'dbusr'@'localhost' WITH GRANT OPTION;
+exit;
+
+ +

Aplikasi dapat diakses melalui http://{ip-address}:8080/login.php, untuk registrasi melalui http://{ip-address}:8080/register.php

+ diff --git a/config.php b/config.php index 5348dc8..fc77c44 100644 --- a/config.php +++ b/config.php @@ -1,10 +1,10 @@