Skip to content

Commit

Permalink
Revert "Add support for vite builds" (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
smortexa committed Sep 17, 2023
1 parent 74f1b02 commit 11de140
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 122 deletions.
210 changes: 89 additions & 121 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,6 @@ ARG COMPOSER_VERSION=latest
# Accepted values: swoole - roadrunner
ARG OCTANE_SERVER="swoole"

###########################################
# Build frontend assets with NPM
###########################################

ARG NODE_VERSION=18-bullseye-slim

FROM node:${NODE_VERSION} as build

ENV ROOT=/var/www/html

WORKDIR $ROOT

RUN npm config set update-notifier false && npm set progress=false

COPY package*.json ./

RUN if [ -f $ROOT/package-lock.json ]; \
then \
NODE_ENV=production npm ci --no-optional --loglevel=error --no-audit; \
elif [ -f $ROOT/package.json ]; \
then \
NODE_ENV=production npm install --no-optional --loglevel=error --no-audit; \
fi

COPY . .

RUN if [ -f $ROOT/package.json ] || [ -f $ROOT/package-lock.json ]; \
then \
npm run build; \
fi

###########################################
# PHP dependencies
###########################################
Expand All @@ -61,11 +30,11 @@ RUN composer install \
###########################################

RUN if [ ${OCTANE_SERVER} = "roadrunner" ]; then \
if composer show | grep spiral/roadrunner-cli >/dev/null; then \
./vendor/bin/rr get-binary; else \
echo "spiral/roadrunner-cli package is not installed. exiting..."; exit 1; \
fi \
fi
if composer show | grep spiral/roadrunner-cli >/dev/null; then \
./vendor/bin/rr get-binary; else \
echo "spiral/roadrunner-cli package is not installed. exiting..."; exit 1; \
fi \
fi

###########################################

Expand All @@ -86,53 +55,53 @@ ARG APP_WITH_HORIZON=false
ARG APP_WITH_SCHEDULER=false

ENV DEBIAN_FRONTEND=noninteractive \
TERM=xterm-color \
CONTAINER_MODE=${CONTAINER_MODE} \
APP_WITH_HORIZON=${APP_WITH_HORIZON} \
APP_WITH_SCHEDULER=${APP_WITH_SCHEDULER} \
OCTANE_SERVER=${OCTANE_SERVER}
TERM=xterm-color \
CONTAINER_MODE=${CONTAINER_MODE} \
APP_WITH_HORIZON=${APP_WITH_HORIZON} \
APP_WITH_SCHEDULER=${APP_WITH_SCHEDULER} \
OCTANE_SERVER=${OCTANE_SERVER}

ENV ROOT=/var/www/html
WORKDIR $ROOT

SHELL ["/bin/bash", "-eou", "pipefail", "-c"]

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
&& echo $TZ > /etc/timezone

RUN apt-get update; \
apt-get upgrade -yqq; \
pecl -q channel-update pecl.php.net; \
apt-get install -yqq --no-install-recommends --show-progress \
apt-utils \
gnupg \
gosu \
git \
curl \
wget \
libcurl4-openssl-dev \
ca-certificates \
supervisor \
libmemcached-dev \
libz-dev \
libbrotli-dev \
libpq-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev \
libssl-dev \
libwebp-dev \
libmcrypt-dev \
libonig-dev \
libzip-dev zip unzip \
libargon2-1 \
libidn2-0 \
libpcre2-8-0 \
libpcre3 \
libxml2 \
libzstd1 \
procps \
libbz2-dev
apt-get upgrade -yqq; \
pecl -q channel-update pecl.php.net; \
apt-get install -yqq --no-install-recommends --show-progress \
apt-utils \
gnupg \
gosu \
git \
curl \
wget \
libcurl4-openssl-dev \
ca-certificates \
supervisor \
libmemcached-dev \
libz-dev \
libbrotli-dev \
libpq-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev \
libssl-dev \
libwebp-dev \
libmcrypt-dev \
libonig-dev \
libzip-dev zip unzip \
libargon2-1 \
libidn2-0 \
libpcre2-8-0 \
libpcre3 \
libxml2 \
libzstd1 \
procps \
libbz2-dev


###########################################
Expand Down Expand Up @@ -164,11 +133,11 @@ RUN docker-php-ext-install mbstring;
###########################################

RUN docker-php-ext-configure gd \
--prefix=/usr \
--with-jpeg \
--with-webp \
--with-freetype \
&& docker-php-ext-install gd;
--prefix=/usr \
--with-jpeg \
--with-webp \
--with-freetype \
&& docker-php-ext-install gd;

###########################################
# OPcache
Expand All @@ -177,7 +146,7 @@ RUN docker-php-ext-configure gd \
ARG INSTALL_OPCACHE=true

RUN if [ ${INSTALL_OPCACHE} = true ]; then \
docker-php-ext-install opcache; \
docker-php-ext-install opcache; \
fi

###########################################
Expand All @@ -187,9 +156,9 @@ RUN if [ ${INSTALL_OPCACHE} = true ]; then \
ARG INSTALL_PHPREDIS=true

RUN if [ ${INSTALL_PHPREDIS} = true ]; then \
pecl -q install -o -f redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis; \
pecl -q install -o -f redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis; \
fi

###########################################
Expand All @@ -199,7 +168,7 @@ RUN if [ ${INSTALL_PHPREDIS} = true ]; then \
ARG INSTALL_PCNTL=true

RUN if [ ${INSTALL_PCNTL} = true ]; then \
docker-php-ext-install pcntl; \
docker-php-ext-install pcntl; \
fi

###########################################
Expand All @@ -209,7 +178,7 @@ RUN if [ ${INSTALL_PCNTL} = true ]; then \
ARG INSTALL_BCMATH=true

RUN if [ ${INSTALL_BCMATH} = true ]; then \
docker-php-ext-install bcmath; \
docker-php-ext-install bcmath; \
fi

###########################################
Expand All @@ -219,9 +188,9 @@ RUN if [ ${INSTALL_BCMATH} = true ]; then \
ARG INSTALL_RDKAFKA=true

RUN if [ ${INSTALL_RDKAFKA} = true ]; then \
apt-get install -yqq --no-install-recommends --show-progress librdkafka-dev \
&& pecl -q install -o -f rdkafka \
&& docker-php-ext-enable rdkafka; \
apt-get install -yqq --no-install-recommends --show-progress librdkafka-dev \
&& pecl -q install -o -f rdkafka \
&& docker-php-ext-enable rdkafka; \
fi

###########################################
Expand All @@ -231,9 +200,9 @@ RUN if [ ${INSTALL_RDKAFKA} = true ]; then \
ARG SERVER=swoole

RUN if [ ${OCTANE_SERVER} = "swoole" ]; then \
apt-get install -yqq --no-install-recommends --show-progress libc-ares-dev \
&& pecl -q install -o -f -D 'enable-openssl="yes" enable-http2="yes" enable-swoole-curl="yes" enable-mysqlnd="yes" enable-cares="yes"' ${SERVER} \
&& docker-php-ext-enable ${SERVER}; \
apt-get install -yqq --no-install-recommends --show-progress libc-ares-dev \
&& pecl -q install -o -f -D 'enable-openssl="yes" enable-http2="yes" enable-swoole-curl="yes" enable-mysqlnd="yes" enable-cares="yes"' ${SERVER} \
&& docker-php-ext-enable ${SERVER}; \
fi

###########################################################################
Expand All @@ -243,9 +212,9 @@ RUN if [ ${OCTANE_SERVER} = "swoole" ]; then \
ARG INSTALL_INTL=true

RUN if [ ${INSTALL_INTL} = true ]; then \
apt-get install -yqq --no-install-recommends --show-progress zlib1g-dev libicu-dev g++ \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl; \
apt-get install -yqq --no-install-recommends --show-progress zlib1g-dev libicu-dev g++ \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl; \
fi

###########################################
Expand All @@ -255,7 +224,7 @@ RUN if [ ${INSTALL_INTL} = true ]; then \
ARG INSTALL_MEMCACHED=false

RUN if [ ${INSTALL_MEMCACHED} = true ]; then \
pecl -q install -o -f memcached && docker-php-ext-enable memcached; \
pecl -q install -o -f memcached && docker-php-ext-enable memcached; \
fi

###########################################
Expand All @@ -265,7 +234,7 @@ RUN if [ ${INSTALL_MEMCACHED} = true ]; then \
ARG INSTALL_MYSQL_CLIENT=true

RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \
apt-get install -yqq --no-install-recommends --show-progress default-mysql-client; \
apt-get install -yqq --no-install-recommends --show-progress default-mysql-client; \
fi

###########################################
Expand All @@ -275,7 +244,7 @@ RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \
ARG INSTALL_PDO_PGSQL=false

RUN if [ ${INSTALL_PDO_PGSQL} = true ]; then \
docker-php-ext-install pdo_pgsql; \
docker-php-ext-install pdo_pgsql; \
fi

###########################################
Expand All @@ -285,7 +254,7 @@ RUN if [ ${INSTALL_PDO_PGSQL} = true ]; then \
ARG INSTALL_PGSQL=false

RUN if [ ${INSTALL_PGSQL} = true ]; then \
docker-php-ext-install pgsql; \
docker-php-ext-install pgsql; \
fi

###########################################
Expand All @@ -296,44 +265,43 @@ ARG INSTALL_PG_CLIENT=false
ARG INSTALL_POSTGIS=false

RUN if [ ${INSTALL_PG_CLIENT} = true ]; then \
apt-get install -yqq gnupg \
&& . /etc/os-release \
&& echo "deb http://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& curl -sL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt-get update -yqq \
&& apt-get install -yqq --no-install-recommends --show-progress postgresql-client-12 postgis; \
if [ ${INSTALL_POSTGIS} = true ]; then \
apt-get install -yqq --no-install-recommends --show-progress postgis; \
fi \
&& apt-get purge -yqq gnupg; \
apt-get install -yqq gnupg \
&& . /etc/os-release \
&& echo "deb http://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& curl -sL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt-get update -yqq \
&& apt-get install -yqq --no-install-recommends --show-progress postgresql-client-12 postgis; \
if [ ${INSTALL_POSTGIS} = true ]; then \
apt-get install -yqq --no-install-recommends --show-progress postgis; \
fi \
&& apt-get purge -yqq gnupg; \
fi

###########################################
# Laravel scheduler
###########################################

RUN if [ ${CONTAINER_MODE} = 'scheduler' ] || [ ${APP_WITH_SCHEDULER} = true ]; then \
wget -q "https://github.com/aptible/supercronic/releases/download/v0.2.26/supercronic-linux-amd64" \
-O /usr/bin/supercronic \
&& chmod +x /usr/bin/supercronic \
&& mkdir -p /etc/supercronic \
&& echo "*/1 * * * * php ${ROOT}/artisan schedule:run --verbose --no-interaction" > /etc/supercronic/laravel; \
wget -q "https://github.com/aptible/supercronic/releases/download/v0.2.26/supercronic-linux-amd64" \
-O /usr/bin/supercronic \
&& chmod +x /usr/bin/supercronic \
&& mkdir -p /etc/supercronic \
&& echo "*/1 * * * * php ${ROOT}/artisan schedule:run --verbose --no-interaction" > /etc/supercronic/laravel; \
fi

###########################################

RUN groupadd --force -g $WWWGROUP octane \
&& useradd -ms /bin/bash --no-log-init --no-user-group -g $WWWGROUP -u $WWWUSER octane
&& useradd -ms /bin/bash --no-log-init --no-user-group -g $WWWGROUP -u $WWWUSER octane

RUN apt-get clean \
&& docker-php-source delete \
&& pecl clear-cache \
&& rm -R /tmp/pear \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& rm /var/log/lastlog /var/log/faillog
&& docker-php-source delete \
&& pecl clear-cache \
&& rm -R /tmp/pear \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& rm /var/log/lastlog /var/log/faillog

COPY . .
COPY --from=build ${ROOT}/public public
COPY --from=vendor ${ROOT}/vendor vendor
COPY --from=vendor ${ROOT}/rr* ${ROOT}/composer.json ./

Expand All @@ -352,7 +320,7 @@ COPY deployment/octane/.rr.prod.yaml ./.rr.yaml

RUN chmod +x deployment/octane/entrypoint.sh
RUN if [ -f "rr" ]; then \
chmod +x rr; \
chmod +x rr; \
fi
RUN cat deployment/octane/utilities.sh >> ~/.bashrc

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Also, some useful Bash functions and aliases are added in `utilities.sh` that ma
## ToDo
- [x] Add support for Horizon
- [x] Add support for RoadRunner
- [x] Add support for the full-stack apps (Front-end assets)
- [ ] Add support for the full-stack apps (Front-end assets)
- [ ] Add support `testing` environment and CI
- [x] Add support for the Laravel scheduler
- [ ] Add support for Laravel Dusk
Expand Down

0 comments on commit 11de140

Please sign in to comment.