From c52b1e15ed5b23f26860a68a7fc730eb6aa3a09d Mon Sep 17 00:00:00 2001 From: Joao Patricio Date: Wed, 31 May 2023 19:33:59 +0100 Subject: [PATCH] Add infrastructure --- .dockerignore | 5 ++++ docker/prod-ssu/Dockerfile | 30 +++++++++++++++++++ .../etc/s6-overlay/s6-rc.d/db-migration/type | 1 + .../etc/s6-overlay/s6-rc.d/db-migration/up | 2 ++ .../s6-rc.d/user/contents.d/db-migration | 0 docker/prod-ssu/nginx.conf | 4 +++ 6 files changed, 42 insertions(+) create mode 100644 .dockerignore create mode 100644 docker/prod-ssu/Dockerfile create mode 100644 docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/type create mode 100644 docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/up create mode 100644 docker/prod-ssu/etc/s6-overlay/s6-rc.d/user/contents.d/db-migration create mode 100644 docker/prod-ssu/nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d12908e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +vendor +.git +.idea + diff --git a/docker/prod-ssu/Dockerfile b/docker/prod-ssu/Dockerfile new file mode 100644 index 0000000..a8ec921 --- /dev/null +++ b/docker/prod-ssu/Dockerfile @@ -0,0 +1,30 @@ +FROM node:19 as static-assets +WORKDIR /app +COPY . . +RUN npm install +RUN npm run build + +FROM serversideup/php:8.2-fpm-nginx +WORKDIR /var/www/html +ARG POSTGRES_VERSION=15 +RUN apt-get update && apt-get install -y php-pgsql +RUN apt-get -y autoremove && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + +COPY composer.json composer.lock ./ +RUN composer install --no-dev --no-interaction --no-plugins --no-scripts --prefer-dist + +COPY --chown=9999:9999 . . +RUN composer dump-autoload + +COPY --from=static-assets --chown=9999:9999 /app/public/build ./public/build +#COPY --chmod=755 docker/prod-ssu/etc/s6-overlay/ /etc/s6-overlay/ + +RUN php artisan route:cache +RUN php artisan view:cache + +RUN echo "alias ll='ls -al'" >>/etc/bash.bashrc +RUN echo "alias a='php artisan'" >>/etc/bash.bashrc +RUN echo "alias mfs='php artisan migrate:fresh --seed'" >>/etc/bash.bashrc +RUN echo "alias cda='composer dump-autoload'" >>/etc/bash.bashrc +RUN echo "alias run='./scripts/run'" >>/etc/bash.bashrc +RUN echo "alias logs='tail -f storage/logs/laravel.log'" >>/etc/bash.bashrc diff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/type b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/type @@ -0,0 +1 @@ +oneshot diff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/up b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/up new file mode 100644 index 0000000..250d5d8 --- /dev/null +++ b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/up @@ -0,0 +1,2 @@ +#!/command/execlineb -P +php /var/www/html/artisan migrate --force --isolated diff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/user/contents.d/db-migration b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/user/contents.d/db-migration new file mode 100644 index 0000000..e69de29 diff --git a/docker/prod-ssu/nginx.conf b/docker/prod-ssu/nginx.conf new file mode 100644 index 0000000..60e1f96 --- /dev/null +++ b/docker/prod-ssu/nginx.conf @@ -0,0 +1,4 @@ +# Custom nginx configuration + +# Disable access logs +access_log off; \ No newline at end of file