From d4bfbf8f0185d2914c655fdb8a61bac6f03f3057 Mon Sep 17 00:00:00 2001 From: M Farrel Danendra Rachim <13521048@std.stei.itb.ac.id> Date: Wed, 27 Sep 2023 08:44:35 +0700 Subject: [PATCH] update: update gitignore --- .env.example | 2 ++ .gitignore | 3 +++ Dockerfile | 7 ++++++- README.md | 36 ++++++++++++++++++++++++++++++++++++ docker-compose.yml | 17 +++++++++++++++++ php.ini | 3 +++ 6 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 php.ini diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..95ccfc5 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +POSTGRES_USER= +POSTGRES_PASSWORD= \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e10641 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +db/ +.env +.DS_Store \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2e3ddd6..08018e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1,6 @@ -FROM php:8.0-apache \ No newline at end of file +FROM php:8.0-apache + +RUN apt-get update && apt-get install -y libpq-dev +RUN docker-php-ext-install pdo pdo_pgsql +COPY ./php.ini /usr/local/etc/php/php.ini +RUN a2enmod rewrite \ No newline at end of file diff --git a/README.md b/README.md index 1132afa..d3c5315 100644 --- a/README.md +++ b/README.md @@ -1 +1,37 @@ # Drawl + +## Development + +## Running App + +This guide is primarily intended for Windows users. For Linux users please adjust according to your setup. + +1. (For Windows) Install the Desktop version of docker. For installation guide please visit the link: https://bobbyhadz.com/blog/docker-is-not-recognized-as-internal-or-external-command +2. (For Linux) Install Docker from terminal. For installation guide please visit the link: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04 +3. Open your preferred terminal navigate towards the main "drawl" folder. +4. Type `bash scripts/build-image.sh` to run the script file. +5. Run `docker compose up` (+ another flag like `-d` (optional)) +6. Add `.env` file on root dir. The format is same like `.env.example` +7. Add `.env` file on the `.src/server`. The format is same like `.env.example` on that folder. Make sure that the "DB_NAME" parameter is filled with an existing database (e.g. fill it with "postgres") +8. Open the web on `localhost:8008` and the database admin on `localhost:8080` +9. On database admin, select `postgresql` as the system, and get the username and password from `.env`, then write a table name or left it blank + +## Development (Temporary) + +### Create new Page + +1. Tambah file `.php` baru di `src/server/app/View` (sebaiknya taruh dalam folder juga sesuai fungsionalitas) +2. Buat controller atau pake yang udah ada di `src/server/app/Controller`. Basic formatnya kaya yang di `HomeController.php`. +3. Daftarin route baru di `src/server/routes/view.php`. Formatnya, + +```php +Router::add('{http method}', '{path}, '{controller name}', '{function name}', '{middlewares}') +``` + +4. File CSS bisa ditambah di `src/public/css`, trus jangan lupa import di fungsi render di controller pagenya. Contohnya kaya di `HomeController.php` +5. Harusnya pagenya udah bisa muncul. + +## Version Control + +There is a backup for this project on a remote repo `backup`. +So, when pushing changes, push it to the remote `origin` and `backup`. diff --git a/docker-compose.yml b/docker-compose.yml index 7c5e0ae..c6c25d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,5 +2,22 @@ version: '3.3' services: web: image: tubes-1:latest + volumes: + - ./src/server:/var/www + - ./src/public:/var/www/html ports: - 8008:80 + db: + image: postgres:latest + restart: always + volumes: + - "./db:/var/lib/postgresql/data" + ports: + - "5432:5432" + env_file: + - .env + adminer: + image: adminer:latest + restart: always + ports: + - "8080:8080" diff --git a/php.ini b/php.ini new file mode 100644 index 0000000..4e75d5f --- /dev/null +++ b/php.ini @@ -0,0 +1,3 @@ +file_uploads = On +upload_max_filesize = 100M +post_max_size = 100M \ No newline at end of file -- GitLab