diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000000000000000000000000000000000..95ccfc5a77b10f1afdc3f266334df8e71f02122e --- /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 0000000000000000000000000000000000000000..7e10641fc4e7aca641c85458f9f2b1a1429d4473 --- /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 2e3ddd6d8b2132e3c4b53de7ba0e9ce61e60670a..08018e27836989ec35c8bf0ac2f0b1b491b5556f 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 1132afae3862a26173197e27c2d754967e6a953d..d3c5315e3a2147152ea6d5187c09d0872c9f46a3 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 7c5e0aeeb93e6ef1a07efefaf9b94d87a8878aad..c6c25d1309a63c2afb8da8e3656e6fdfa9179258 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 0000000000000000000000000000000000000000..4e75d5fcb6dcc57e1506a0cb77065d1f06886980 --- /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