From 76dc9c74d8cc2ebea0ec4031032e3174ade37795 Mon Sep 17 00:00:00 2001 From: Carlos Villavicencio Date: Fri, 5 Jun 2020 08:54:02 -0500 Subject: [PATCH] Add Docker deployment --- .dockerignore | 3 +++ Dockerfile | 23 +++++++++++++++++++++++ Makefile | 1 - composer.json | 2 +- docker-compose.yml | 8 ++++++++ readme.md | 9 +++++++++ 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9bdc99d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +vendor +node_modules +.sqlite diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..165b4bb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM php:7.4 + +WORKDIR /usr/src/app + +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y git + +COPY composer* ./ +RUN curl --silent --show-error https://getcomposer.org/installer | php +RUN mv composer.phar /usr/local/bin/composer + + +COPY . . +RUN touch database/database.sqlite +RUN composer install --no-interaction + +RUN php artisan key:generate --force +RUN php artisan migrate --force + +EXPOSE 8000 + +CMD [ "php", "artisan", "serve", "--host=0.0.0.0" ] diff --git a/Makefile b/Makefile index 96afd80..ab76831 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,6 @@ install: composer install php artisan key:generate --force php artisan migrate --force - php artisan db:seed --force serve-setup: php artisan serve --host=127.0.0.1 diff --git a/composer.json b/composer.json index 8cbb6cb..8571ae0 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "TwilioDevEd/airtng-laravel", + "name": "twilio-deved/airtng-laravel", "description": "The Laravel Framework.", "keywords": ["twilio", "workflow", "airtng"], "license": "MIT", diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..aa966fe --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: "3.8" +services: + app: + container_name: app + restart: always + build: . + ports: + - "8000:8000" diff --git a/readme.md b/readme.md index d6354ee..5586279 100644 --- a/readme.md +++ b/readme.md @@ -104,6 +104,15 @@ After the above requirements have been met: That's it! +### Docker + +If you have [Docker](https://www.docker.com/) already installed on your machine, you can use our `docker-compose.yml` to setup your project. + +1. Make sure you have the project cloned. +2. Setup the `.env` file as outlined in the [Local Development](#local-development) steps. +3. Run `docker-compose up`. +4. Follow the steps in [Local Development](#local-development) on how to expose your port to Twilio using a tool like [ngrok](https://ngrok.com/) and configure the remaining parts of your application. + ### Unit and Integration Tests First, run the migrations for the testing database.