chore: clean up dockerfile and entrypoint script

This commit is contained in:
hackerESQ
2024-12-19 21:34:58 -06:00
parent bde399f589
commit 138e71107e
2 changed files with 8 additions and 8 deletions
+53
View File
@@ -0,0 +1,53 @@
FROM php:8.3-fpm
ENV DEBIAN_FRONTEND=noninteractive
# Install common php extension dependencies
RUN apt-get update && apt-get install -y \
libfreetype-dev \
libjpeg62-turbo-dev \
libpng-dev \
zlib1g-dev \
libzip-dev \
unzip \
libicu-dev \
git \
curl \
supervisor \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
gd \
zip \
pdo_mysql \
mysqli \
intl
# Set the working directory
COPY . /var/www/app
WORKDIR /var/www/app
# Install Node.js and npm
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm@latest
# Copy over supervisor configuration
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Set permissions
RUN chown -R www-data:www-data . \
&& chmod -R 775 ./storage \
&& chmod +x ./docker/entrypoint.sh
# Install composer
COPY --from=composer:2.6.5 /usr/bin/composer /usr/local/bin/composer
# Serve on port 80
EXPOSE 80
# Set up healthcheck
HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -f http://localhost || exit 1
# Run everything else
ENTRYPOINT ["/bin/bash", "./docker/entrypoint.sh"]
CMD ["./docker/entrypoint.sh"]
+8 -8
View File
@@ -2,17 +2,17 @@
cd /var/www/app
echo "====================== Running entrypoint script... ====================== "
echo -e "\n====================== Running entrypoint script... ====================== "
if [ ! -f ".env" ]; then
echo " > Ope, gotta create an .env file!"
cp .env.example .env
fi
echo "====================== Installing Composer dependencies... ====================== "
echo -e "\n====================== Installing Composer dependencies... ====================== "
/usr/local/bin/composer install
echo "====================== Validating environment... ====================== "
echo -e "\n====================== Validating environment... ====================== "
if [ $(stat -c '%U' .) != "www-data" ]; then
echo " > Setting correct permissions for pwd..."
chown -R www-data:www-data .
@@ -30,11 +30,11 @@ if [ ! -L "public/storage" ]; then
/usr/local/bin/php artisan storage:link
fi
echo "====================== Installing NPM dependencies and building frontend... ====================== "
echo -e "\n====================== Installing NPM dependencies and building frontend... ====================== "
/usr/bin/npm install
/usr/bin/npm run build
echo "====================== Running migrations... ====================== "
echo -e "\n====================== Running migrations... ====================== "
run_migrations() {
/usr/local/bin/php artisan migrate --force
}
@@ -43,12 +43,12 @@ DELAY=5
until run_migrations; do
RETRIES=$((RETRIES-1))
if [ $RETRIES -le 0 ]; then
echo "Database is not ready after multiple attempts. Exiting..."
echo " > Database is not ready after multiple attempts. Exiting..."
exit 1
fi
echo "Waiting for database to be ready... retrying in $DELAY seconds."
echo " > Waiting for database to be ready... retrying in $DELAY seconds."
sleep $DELAY
done
echo "====================== Spinning up Supervisor daemon... ====================== "
echo -e "\n====================== Spinning up Supervisor daemon... ====================== "
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf