From 4e661682c2e3b6383d3f80da1eb88e82993c8797 Mon Sep 17 00:00:00 2001 From: Manuel Riel Date: Sun, 13 Mar 2022 20:09:50 +0000 Subject: [PATCH 1/2] Add Dockerfile, fix https --- Dockerfile | 14 ++++++++++++++ app/Providers/RouteServiceProvider.php | 3 +++ run.sh | 21 +++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 Dockerfile create mode 100755 run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d2e4f60 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM php:8.1-fpm-alpine + +RUN docker-php-ext-install pdo pdo_mysql sockets +RUN curl -sS https://getcomposer.org/installer | php -- \ + --install-dir=/usr/local/bin --filename=composer + +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +WORKDIR /app +COPY . . +RUN composer install && \ + cp .env.example .env + +ENTRYPOINT ["/app/run.sh"] diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index ca027ea..3ee2b67 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -35,6 +35,9 @@ class RouteServiceProvider extends ServiceProvider */ public function boot() { + if (config('app.env') === 'production') { + \Illuminate\Support\Facades\URL::forceScheme('https'); + } $this->configureRateLimiting(); $this->routes(function () { diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..98daf76 --- /dev/null +++ b/run.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# TODO: global env vars aren't used. +cat > /app/.env.production << EOF +APP_NAME=MyIdlers +APP_DEBUG=true +APP_KEY= + +DB_CONNECTION=mysql +DB_HOST=${DB_HOST} +DB_DATABASE=${DB_DATABASE} +DB_USERNAME=${DB_USERNAME} +DB_PASSWORD=${DB_PASSWORD} +APP_URL=${APP_URL} +ASSET_URL=${ASSET_URL} +EOF + +# TODO: only run this once +php artisan key:generate +php artisan migrate:fresh --seed --force +php artisan serve --host=0.0.0.0 --port=8000 --env=production From 416d28c3df3e33f42fa1d3d9a2d7f32612593e86 Mon Sep 17 00:00:00 2001 From: Manuel Riel Date: Sun, 13 Mar 2022 20:19:24 +0000 Subject: [PATCH 2/2] debug to false --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 98daf76..598be83 100755 --- a/run.sh +++ b/run.sh @@ -3,7 +3,7 @@ # TODO: global env vars aren't used. cat > /app/.env.production << EOF APP_NAME=MyIdlers -APP_DEBUG=true +APP_DEBUG=false APP_KEY= DB_CONNECTION=mysql