diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..191381ee --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f9d6c3e6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM php:8.1 + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + libzip-dev \ + zip \ + git + +# Install php extensions +RUN docker-php-ext-install mysqli pdo pdo_mysql + +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install composer +RUN curl -sS https://getcomposer.org/installer | php -- \ + --install-dir=/usr/bin --filename=composer + +COPY . /app + +RUN composer install --ignore-platform-reqs + +# Give execute permission to startup script +RUN chmod +x /app/docker-startup.sh + +ENTRYPOINT [ "/app/docker-startup.sh" ] \ No newline at end of file diff --git a/README.md b/README.md index 08a114ce..15b58d7e 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,14 @@ > **Important Note:** "Triangle POS" uses Laravel Snappy Package for PDFs. If you are using Linux then no configuration is needed. But in other Operating Systems please refer to [Laravel Snappy Documentation](https://github.com/barryvdh/laravel-snappy). +# Docker Installation + +This will start the application along with the mysql database using docker compose. Note that the `DB_HOST` variable must be the mysql docker container name, in this case `db`. + +- run `` docker build -t triangle-pos . `` +- run `` docker compose up `` +- then visit `` http://localhost:8000 or http://127.0.0.1:8000 ``. + # Admin Credentials > Email: super.admin@test.com || Password: 12345678 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..0beb913a --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,31 @@ +services: + web: + image: triangle-pos:latest + build: + context: . + env_file: + - .env + ports: + - "9000:8000" + volumes: + - .:/var/www/html + depends_on: + - db + + db: + platform: "linux/amd64" + image: mysql:5.7 + env_file: + - .env + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: ${DB_DATABASE} + MYSQL_USER: ${DB_USERNAME} + MYSQL_PASSWORD: ${DB_PASSWORD} + ports: + - "3306:3306" + volumes: + - dbdata:/var/lib/mysql + +volumes: + dbdata: diff --git a/docker-startup.sh b/docker-startup.sh new file mode 100644 index 00000000..4db9c304 --- /dev/null +++ b/docker-startup.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +php artisan key:generate +php artisan migrate --seed +php artisan storage:link +php artisan serve --host 0.0.0.0 \ No newline at end of file