sintonia docker fix: dev container startup
This commit is contained in:
parent
f17ee781a2
commit
18ad58fd68
7 changed files with 223 additions and 103 deletions
105
Dockerfile
105
Dockerfile
|
@ -284,7 +284,7 @@ ENV LIBRETIME_VERSION=$LIBRETIME_VERSION
|
|||
#======================================================================================#
|
||||
|
||||
# Use PHP as the base
|
||||
FROM php:8.2-cli AS sintonia-webapp
|
||||
FROM php:8.2-cli AS sintonia-webapp-base
|
||||
|
||||
# Arguments defined in docker-compose-dev.yml
|
||||
ARG sintonia_user=$SINTONIA_USER
|
||||
|
@ -292,8 +292,6 @@ ARG sintonia_uid=$SINTONIA_UID
|
|||
ARG sintonia_node_version=$SINTONIA_NODE_VERSION
|
||||
ARG sintonia_production=$SINTONIA_PRODUCTION
|
||||
|
||||
ENV sintonia_laravel_port $SINTONIA_LARAVEL_PORT
|
||||
ENV sintonia_vite_port $SINTONIA_VITE_PORT
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install Additional System Dependencies and PHP Extensions
|
||||
|
@ -309,26 +307,27 @@ RUN set -eux && \
|
|||
libzip-dev \
|
||||
libpng-dev \
|
||||
git \
|
||||
libonig-dev && \
|
||||
docker-php-ext-configure zip && \
|
||||
docker-php-ext-configure gd --with-freetype --with-jpeg && \
|
||||
docker-php-ext-install gd exif pcntl bcmath mysqli pdo_mysql mbstring && \
|
||||
if [ ! "$sintonia_production" ]; then \
|
||||
pecl install xdebug; docker-php-ext-enable xdebug; \
|
||||
fi && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
libonig-dev \
|
||||
libpq-dev
|
||||
|
||||
COPY ./sintonia_webapp /var/www/sintonia
|
||||
RUN docker-php-ext-configure zip && \
|
||||
docker-php-ext-configure gd --with-freetype --with-jpeg
|
||||
|
||||
RUN docker-php-ext-install gd exif pcntl bcmath mysqli pdo_mysql mbstring && \
|
||||
docker-php-ext-install pdo_pgsql pgsql && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create system user to run Composer and Artisan Commands
|
||||
RUN set -eux && useradd -G www-data -u $sintonia_uid -d /home/$sintonia_user $sintonia_user && \
|
||||
mkdir -p /home/$sintonia_user/.composer && \
|
||||
mkdir -p /var/www/sintonia && \
|
||||
mkdir -p /var/www/sintonia_webapp && \
|
||||
chown -R $sintonia_user:$sintonia_user /home/$sintonia_user && \
|
||||
chown -R $sintonia_user:$sintonia_user /var/www/sintonia
|
||||
chown -R $sintonia_user:$sintonia_user /var/www/sintonia_webapp
|
||||
|
||||
USER "$sintonia_user"
|
||||
WORKDIR /home/$sintonia_user
|
||||
# Install composer
|
||||
RUN set -eux && curl -sS https://getcomposer.org/installer | php -- --filename=composer
|
||||
|
||||
# node and composer installation
|
||||
# Download and install nvm:
|
||||
|
@ -338,24 +337,72 @@ RUN curl -fsSL https://nodejs.org/dist/v$sintonia_node_version/node-v$sintonia_n
|
|||
|
||||
ENV PATH="/home/$sintonia_user/node-v$sintonia_node_version-linux-x64/bin:/home/$sintonia_user/composer:${PATH}"
|
||||
|
||||
# Install composer
|
||||
RUN set -eux && curl -sS https://getcomposer.org/installer | php -- --install-dir=/home/$sintonia_user/ --filename=composer
|
||||
#Build
|
||||
FROM sintonia-webapp-base AS sintonia-webapp-build-common
|
||||
ARG sintonia_config_filepath=$SINTONIA_CONFIG_FILEPATH
|
||||
ARG libretime_config_filepath=$LIBRETIME_CONFIG_FILEPATH
|
||||
|
||||
WORKDIR /var/www/sintonia
|
||||
USER root
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && apt-get install yq -y
|
||||
USER "$sintonia_user"
|
||||
|
||||
WORKDIR $HOME
|
||||
COPY --chown=$sintonia_user:$sintonia_user ./tools/populate-laravel-env-file.sh /home/$sintonia_user/
|
||||
COPY --chown=$sintonia_user:$sintonia_user $sintonia_config_filepath /home/$sintonia_user/
|
||||
COPY --chown=$sintonia_user:$sintonia_user $libretime_config_filepath /home/$sintonia_user/
|
||||
RUN chmod +x ./populate-laravel-env-file.sh && \
|
||||
./populate-laravel-env-file.sh /home/$sintonia_user/config.yml /home/$sintonia_user/.env
|
||||
|
||||
# DEV
|
||||
FROM sintonia-webapp-build-common AS sintonia-webapp-dev
|
||||
|
||||
ARG sintonia_laravel_port
|
||||
ARG sintonia_vite_port
|
||||
|
||||
ENV sintonia_laravel_port=${sintonia_laravel_port}
|
||||
ENV sintonia_vite_port=${sintonia_vite_port}
|
||||
|
||||
USER root
|
||||
RUN pecl install xdebug && docker-php-ext-enable xdebug;
|
||||
USER $sintonia_user
|
||||
|
||||
WORKDIR /var/www/sintonia_webapp
|
||||
#COPY --chown=$sintonia_user:$sintonia_user ./sintonia_webapp/ ./
|
||||
|
||||
#Package installation
|
||||
RUN git config --global --add safe.directory /var/www/sintonia && \
|
||||
/home/$sintonia_user/composer install --no-progress --no-interaction --no-dev --no-autoloader && \
|
||||
set -eux && \
|
||||
/home/$sintonia_user/composer --no-cache dump-autoload --no-interaction --no-dev && \
|
||||
npm i
|
||||
#RUN git config --global --add safe.directory /var/www/sintonia_webapp && \
|
||||
# /home/$sintonia_user/composer install --no-progress --no-interaction --no-dev --no-autoloader && \
|
||||
# set -eux && \
|
||||
# npm i
|
||||
|
||||
##
|
||||
#RUN php artisan ziggy:generate && mv ziggy.js resources/utils/ziggy.js
|
||||
#RUN cp $HOME/.env ./
|
||||
ENV sintonia_user=${sintonia_user}
|
||||
### Start server
|
||||
CMD if [ ! $sintonia_production ]; then \
|
||||
cd /var/www/sintonia; \
|
||||
npx vite --port $sintonia_vite_port --host & \
|
||||
php artisan serve --host=0.0.0.0 --port=$sintonia_laravel_port & \
|
||||
sleep infinity; \
|
||||
fi;
|
||||
CMD git config --global --add safe.directory /var/www/sintonia_webapp && \
|
||||
/home/$sintonia_user/composer install --no-progress --no-interaction --no-dev --no-autoloader && \
|
||||
/home/$sintonia_user/composer --no-cache dump-autoload --no-interaction --no-dev && \
|
||||
php artisan key:generate && \
|
||||
set -eux && \
|
||||
npm i && \
|
||||
npx vite --port $sintonia_vite_port --host & \
|
||||
php artisan serve --host=0.0.0.0 --port=$sintonia_laravel_port & \
|
||||
sleep infinity
|
||||
|
||||
|
||||
|
||||
FROM sintonia-webapp-build-common AS sintonia-webapp-production
|
||||
|
||||
RUN git clone https://git.congegni.net/sintonia_webapp && \
|
||||
cd sintonia_webapp && \
|
||||
php artisan ziggy:generate && \
|
||||
php artisan key:generate && \
|
||||
mv ziggy.js resources/utils/ziggy.js && \
|
||||
npx vite build && \
|
||||
cp -r dist/build/* /var/www/html/ && \
|
||||
rm -rf /var/www/sintonia_webapp/node_modules /var/www/sintonia_webapp/.npm /var/www/sintonia_webapp/.composer /var/www/sintonia_webapp/.git && \
|
||||
rm -rf /home/$sintonia_user/node* /home/$sintonia_user/composer
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue