Skip to content

Instantly share code, notes, and snippets.

@jafar260698
Created June 5, 2024 15:06
Show Gist options
  • Save jafar260698/d3d85e4a035c47744f1cedaea3dabfa2 to your computer and use it in GitHub Desktop.
Save jafar260698/d3d85e4a035c47744f1cedaea3dabfa2 to your computer and use it in GitHub Desktop.
FROM php:8.2-apache
# 1. Install development packages and clean up apt cache.
RUN apt-get update && apt-get install -y \
curl \
g++ \
git \
libonig-dev \
libbz2-dev \
libfreetype6-dev \
libicu-dev \
libjpeg-dev \
libmcrypt-dev \
libpng-dev \
libreadline-dev \
sudo \
unzip \
zip \
&& rm -rf /var/lib/apt/lists/*
# 2. Apache configs + document root.
RUN echo "ServerName laravel-app.local" >> /etc/apache2/apache2.conf
ENV APACHE_DOCUMENT_ROOT=/var/www/html
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers
# 4. Start with base PHP config, then add extensions.
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
RUN COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
RUN docker-php-ext-install \
bcmath \
bz2 \
calendar \
iconv \
intl \
mbstring \
opcache \
pdo \
pdo_mysql
WORKDIR /var/www/html
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
# Install Composer and dependencies (ensure you handle your application’s dependencies here)
# Make the entrypoint script executable
RUN chmod +x /usr/local/bin/entrypoint.sh
# Use the entry script as the entry point
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 80
EXPOSE 443
stages:
- build
- deploy
build-dev:
stage: build
only:
- dev
tags:
- dev-app-backend
#when: manual
script:
- docker build --rm -t app_backend:$CI_PIPELINE_IID .
- docker tag app_backend:$CI_PIPELINE_IID app_backend:latest
deploy-dev:
stage: deploy
only:
- dev
tags:
- dev-app-backend
#when: manual
script:
- docker service update --with-registry-auth --image app_backend:$CI_PIPELINE_IID app_backend
# - docker ps | grep app_backend | awk '{print $12}' > export.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment